Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
QuestionWhat is the best tool to create UML diagrams? Pin
Vijay Kanda19-Nov-12 8:29
Vijay Kanda19-Nov-12 8:29 
AnswerRe: What is the best tool to create UML diagrams? Pin
Pete O'Hanlon19-Nov-12 8:36
mvePete O'Hanlon19-Nov-12 8:36 
GeneralRe: What is the best tool to create UML diagrams? Pin
Vijay Kanda19-Nov-12 8:54
Vijay Kanda19-Nov-12 8:54 
AnswerRe: What is the best tool to create UML diagrams? Pin
Bernhard Hiller19-Nov-12 21:57
Bernhard Hiller19-Nov-12 21:57 
AnswerRe: What is the best tool to create UML diagrams? Pin
gilvani20-Nov-12 1:02
gilvani20-Nov-12 1:02 
QuestionC# PAINT for school procet Pin
mibetty19-Nov-12 7:07
mibetty19-Nov-12 7:07 
AnswerRe: C# PAINT for school procet Pin
Richard MacCutchan19-Nov-12 8:04
mveRichard MacCutchan19-Nov-12 8:04 
AnswerRe: C# PAINT for school procet Pin
Pete O'Hanlon19-Nov-12 8:14
mvePete O'Hanlon19-Nov-12 8: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:
C
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 Pin
mibetty19-Nov-12 11:06
mibetty19-Nov-12 11:06 
AnswerRe: C# PAINT for school procet Pin
Pascal Ganaye19-Nov-12 8:36
Pascal Ganaye19-Nov-12 8:36 
GeneralRe: C# PAINT for school procet Pin
Pete O'Hanlon19-Nov-12 8:54
mvePete O'Hanlon19-Nov-12 8:54 
AnswerRe: C# PAINT for school procet Pin
AmitGajjar20-Nov-12 19:40
professionalAmitGajjar20-Nov-12 19:40 
GeneralRe: C# PAINT for school procet Pin
Pete O'Hanlon20-Nov-12 20:26
mvePete O'Hanlon20-Nov-12 20:26 
GeneralRe: C# PAINT for school procet Pin
AmitGajjar20-Nov-12 20:47
professionalAmitGajjar20-Nov-12 20:47 
GeneralRe: C# PAINT for school procet Pin
Pete O'Hanlon20-Nov-12 20:51
mvePete O'Hanlon20-Nov-12 20:51 
GeneralRe: C# PAINT for school procet Pin
AmitGajjar20-Nov-12 20:53
professionalAmitGajjar20-Nov-12 20:53 
GeneralRe: C# PAINT for school procet Pin
Pete O'Hanlon20-Nov-12 20:55
mvePete O'Hanlon20-Nov-12 20:55 
GeneralRe: C# PAINT for school procet Pin
AmitGajjar20-Nov-12 20:58
professionalAmitGajjar20-Nov-12 20:58 
QuestionDecrypt E-Mail address Pin
Sanjeev991819-Nov-12 2:55
Sanjeev991819-Nov-12 2:55 
AnswerRe: Decrypt E-Mail address Pin
Eddy Vluggen19-Nov-12 3:08
professionalEddy Vluggen19-Nov-12 3:08 
AnswerRe: Decrypt E-Mail address Pin
Pete O'Hanlon19-Nov-12 3:14
mvePete O'Hanlon19-Nov-12 3:14 
AnswerRe: Decrypt E-Mail address Pin
J4amieC19-Nov-12 4:01
J4amieC19-Nov-12 4:01 
AnswerRe: Decrypt E-Mail address Pin
cansino19-Nov-12 6:14
cansino19-Nov-12 6:14 
GeneralRe: Decrypt E-Mail address Pin
Dave Kreskowiak19-Nov-12 17:31
mveDave Kreskowiak19-Nov-12 17:31 
AnswerRe: Decrypt E-Mail address Pin
Clifford Nelson19-Nov-12 6:17
Clifford Nelson19-Nov-12 6:17 

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

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