Click here to Skip to main content
       

C#

 
GeneralRe: C# and BitBLT PinmemberGerry Schmitz20-Nov-12 12:50 
QuestionHow can i get the innertext from div which hasnt id PinmemberGokce Sezgin19-Nov-12 10:17 
AnswerRe: How can i get the innertext from div which hasnt id PinprotectorPete O'Hanlon19-Nov-12 10:18 
JokeRe: How can i get the innertext from div which hasnt id PinmemberPeter_in_278019-Nov-12 12:18 
AnswerRe: How can i get the innertext from div which hasnt id Pinmemberaskwjun19-Nov-12 21:42 
AnswerRe: How can i get the innertext from div which hasnt id PinmemberBernhard Hiller19-Nov-12 22:55 
QuestionWhat is the best tool to create UML diagrams? PinmemberVijay Kanda19-Nov-12 9:29 
AnswerRe: What is the best tool to create UML diagrams? PinprotectorPete O'Hanlon19-Nov-12 9:36 
GeneralRe: What is the best tool to create UML diagrams? PinmemberVijay Kanda19-Nov-12 9:54 
AnswerRe: What is the best tool to create UML diagrams? PinmemberBernhard Hiller19-Nov-12 22:57 
AnswerRe: What is the best tool to create UML diagrams? Pinmembergilvani20-Nov-12 2:02 
QuestionC# PAINT for school procet Pinmembermibetty19-Nov-12 8:07 
AnswerRe: C# PAINT for school procet PinmvpRichard MacCutchan19-Nov-12 9:04 
AnswerRe: C# PAINT for school procet PinprotectorPete O'Hanlon19-Nov-12 9:14 
Errm, it's OOP not POO - POO concepts are something completely different.
 
If you understand OO, then breaking down your requirements becomes a lot easier. As an example, let's take the fact that you are going to want to draw multiple items, and they are probably going to be of different types. This suggests to me that you are going to have something to manage the collection of items, and that these items will share some common base.
 
When you consider OOP, you understand that OOP relies on encapsulation, so that everything to do with an item should belong to that item. So, we could figure out that we want to position the item somewhere, and that we want it to have a width and a height. Also, rather than having the code to paint these items on the screen in the paint handler of the application, we should consider that each item should know how to paint itself. So, we have some requirements for these objects - they all share some commonality, and they all have some operations that they must perform, but these operations will depend entirely on the item being drawn. So, I would consider that the X, Y, Width and Height were common (hey, if only .NET provided a handy Rectangle class to do this). The way you paint a rectangle would be different to the way you draw a circle though, so perhaps this should be abstract and require each draw able item to implement it.
 
As a first pass, I've now got something like this:
public class CanvasManager
{
  private List<Shape> shapes = new List<Shape>();
 
  public void AddShape(Shape shape)
  {
    shapes.Add(shape);
  }
 
  public void Paint()
  {
    foreach (Shape shape in shapes)
    {
      shape.Draw();
    }
  }
}
 
public abstract class Shape
{
  public Shape(int x, int y, int width, int height)
  {
    Bounds = new Rectangle(x, y, width, height);
  }
  public Rectangle Bounds { get; set; }
 
  public abstract Draw();
}
That should give you more than enough to get started, and good luck. Just break your problem down using words and you'll soon get the hang of it.

*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

"Mind bleach! Send me mind bleach!" - Nagy Vilmos

CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

GeneralRe: C# PAINT for school procet Pinmembermibetty19-Nov-12 12:06 
AnswerRe: C# PAINT for school procet PinmemberPascal Ganaye19-Nov-12 9:36 
GeneralRe: C# PAINT for school procet PinprotectorPete O'Hanlon19-Nov-12 9:54 
AnswerRe: C# PAINT for school procet Pinmember@AmitGajjar20-Nov-12 20:40 
GeneralRe: C# PAINT for school procet PinprotectorPete O'Hanlon20-Nov-12 21:26 
GeneralRe: C# PAINT for school procet Pinmember@AmitGajjar20-Nov-12 21:47 
GeneralRe: C# PAINT for school procet PinprotectorPete O'Hanlon20-Nov-12 21:51 
GeneralRe: C# PAINT for school procet Pinmember@AmitGajjar20-Nov-12 21:53 
GeneralRe: C# PAINT for school procet PinprotectorPete O'Hanlon20-Nov-12 21:55 
GeneralRe: C# PAINT for school procet Pinmember@AmitGajjar20-Nov-12 21:58 
QuestionDecrypt E-Mail address PinmemberSanjeev991819-Nov-12 3:55 
AnswerRe: Decrypt E-Mail address PinmemberEddy Vluggen19-Nov-12 4:08 
AnswerRe: Decrypt E-Mail address PinprotectorPete O'Hanlon19-Nov-12 4:14 
AnswerRe: Decrypt E-Mail address PinmemberJ4amieC19-Nov-12 5:01 
AnswerRe: Decrypt E-Mail address Pinmembercansino19-Nov-12 7:14 
GeneralRe: Decrypt E-Mail address PinmvpDave Kreskowiak19-Nov-12 18:31 
AnswerRe: Decrypt E-Mail address PinmemberClifford Nelson19-Nov-12 7:17 
AnswerRe: Decrypt E-Mail address PinmemberMathlab19-Nov-12 9:48 
GeneralRe: Decrypt E-Mail address PinmvpDave Kreskowiak20-Nov-12 7:04 
GeneralRe: Decrypt E-Mail address [modified] PinmemberMathlab20-Nov-12 8:38 
GeneralRe: Decrypt E-Mail address PinmvpDave Kreskowiak20-Nov-12 9:00 
GeneralRe: Decrypt E-Mail address PinmemberMathlab20-Nov-12 9:07 
GeneralRe: Decrypt E-Mail address PinmemberMathlab20-Nov-12 9:08 
GeneralRe: Decrypt E-Mail address PinmvpDave Kreskowiak20-Nov-12 9:13 
GeneralRe: Decrypt E-Mail address PinmemberMathlab20-Nov-12 9:16 
GeneralRe: Decrypt E-Mail address PinmvpDave Kreskowiak20-Nov-12 9:50 
GeneralRe: Decrypt E-Mail address PinmemberMathlab20-Nov-12 9:55 
GeneralRe: Decrypt E-Mail address PinmemberMathlab20-Nov-12 9:14 
GeneralRe: Decrypt E-Mail address PinmvpDave Kreskowiak20-Nov-12 9:16 
GeneralRe: Decrypt E-Mail address PinmemberMathlab20-Nov-12 9:19 
AnswerRe: Decrypt E-Mail address Pinmemberharold aptroot19-Nov-12 23:53 
QuestionGet data back from windows process Pinmembertdcmystere19-Nov-12 3:42 
AnswerRe: Get data back from windows process PinmemberEddy Vluggen19-Nov-12 4:10 
GeneralRe: Get data back from windows process Pinmembertdcmystere19-Nov-12 4:19 
GeneralRe: Get data back from windows process PinmemberEddy Vluggen19-Nov-12 4:42 
GeneralRe: Get data back from windows process Pinmembertdcmystere19-Nov-12 5:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 23 Nov 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid