Click here to Skip to main content
12,062,966 members (30,089 online)
   

C#

 
QuestionWhat is the best tool to create UML diagrams? Pin
Vijay Kanda19-Nov-12 9:29
memberVijay Kanda19-Nov-12 9:29 
AnswerRe: What is the best tool to create UML diagrams? Pin
Pete O'Hanlon19-Nov-12 9:36
protectorPete O'Hanlon19-Nov-12 9:36 
GeneralRe: What is the best tool to create UML diagrams? Pin
Vijay Kanda19-Nov-12 9:54
memberVijay Kanda19-Nov-12 9:54 
AnswerRe: What is the best tool to create UML diagrams? Pin
Bernhard Hiller19-Nov-12 22:57
memberBernhard Hiller19-Nov-12 22:57 
AnswerRe: What is the best tool to create UML diagrams? Pin
gilvani20-Nov-12 2:02
membergilvani20-Nov-12 2:02 
QuestionC# PAINT for school procet Pin
mibetty19-Nov-12 8:07
membermibetty19-Nov-12 8:07 
AnswerRe: C# PAINT for school procet Pin
Richard MacCutchan19-Nov-12 9:04
mvpRichard MacCutchan19-Nov-12 9:04 
AnswerRe: C# PAINT for school procet Pin
Pete O'Hanlon19-Nov-12 9:14
protectorPete 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 Pin
mibetty19-Nov-12 12:06
membermibetty19-Nov-12 12:06 
AnswerRe: C# PAINT for school procet Pin
Pascal Ganaye19-Nov-12 9:36
memberPascal Ganaye19-Nov-12 9:36 
GeneralRe: C# PAINT for school procet Pin
Pete O'Hanlon19-Nov-12 9:54
protectorPete O'Hanlon19-Nov-12 9:54 
AnswerRe: C# PAINT for school procet Pin
@AmitGajjar20-Nov-12 20:40
member@AmitGajjar20-Nov-12 20:40 
GeneralRe: C# PAINT for school procet Pin
Pete O'Hanlon20-Nov-12 21:26
protectorPete O'Hanlon20-Nov-12 21:26 
GeneralRe: C# PAINT for school procet Pin
@AmitGajjar20-Nov-12 21:47
member@AmitGajjar20-Nov-12 21:47 
GeneralRe: C# PAINT for school procet Pin
Pete O'Hanlon20-Nov-12 21:51
protectorPete O'Hanlon20-Nov-12 21:51 
GeneralRe: C# PAINT for school procet Pin
@AmitGajjar20-Nov-12 21:53
member@AmitGajjar20-Nov-12 21:53 
GeneralRe: C# PAINT for school procet Pin
Pete O'Hanlon20-Nov-12 21:55
protectorPete O'Hanlon20-Nov-12 21:55 
GeneralRe: C# PAINT for school procet Pin
@AmitGajjar20-Nov-12 21:58
member@AmitGajjar20-Nov-12 21:58 
QuestionDecrypt E-Mail address Pin
Sanjeev991819-Nov-12 3:55
memberSanjeev991819-Nov-12 3:55 
AnswerRe: Decrypt E-Mail address Pin
Eddy Vluggen19-Nov-12 4:08
memberEddy Vluggen19-Nov-12 4:08 
AnswerRe: Decrypt E-Mail address Pin
Pete O'Hanlon19-Nov-12 4:14
protectorPete O'Hanlon19-Nov-12 4:14 
AnswerRe: Decrypt E-Mail address Pin
J4amieC19-Nov-12 5:01
memberJ4amieC19-Nov-12 5:01 
AnswerRe: Decrypt E-Mail address Pin
cansino19-Nov-12 7:14
membercansino19-Nov-12 7:14 
GeneralRe: Decrypt E-Mail address Pin
Dave Kreskowiak19-Nov-12 18:31
mvpDave Kreskowiak19-Nov-12 18:31 
AnswerRe: Decrypt E-Mail address Pin
Clifford Nelson19-Nov-12 7:17
memberClifford Nelson19-Nov-12 7: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.


Advertise | Privacy | Mobile
Web02 | 2.8.160204.4 | Last Updated 5 Feb 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid