Click here to Skip to main content
       

C#

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionC# PAINT for school procetmembermibetty19 Nov '12 - 7:07 
Hello everyone!
 
I need to do a paint software in C# for the university.
 
I need to use polimorphysm,abstract class,overriding, POO concepts.
 
I have very dificultties in programmiing so im trying to find something nice to help me here ,but i just find codes for paint without using classes and POO concepts.
 
Do have something that can helps me?Confused | :confused:
AnswerRe: C# PAINT for school procetmvpRichard MacCutchan19 Nov '12 - 8:04 
mibetty wrote:
I need to use polimorphysm,abstract class,overriding, POO concepts.
I assume you mean OOP here, I don't now what POO is in your language but ...
The use of these features in your program requires you to do the design. It is not possible to provide a standard set that will do the work for you. You can also find lots of useful suggestions in the CodeProject Articles section[^].
One of these days I'm going to think of a really clever signature.

AnswerRe: C# PAINT for school procetprotectorPete 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:
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 procetmembermibetty19 Nov '12 - 11:06 
Thanks very much all for your awnsewers.
 
Yes i meant OOP , sorry!
 
I already look at the code of that "Simple Paint" and others , but the problem is that i need to do a paint using several classes , not only one, i need to use a main class and than others that inherit from the main class.
 
I also need to use polymorfism , abstract class, overiding,lists..
 
For example teacher said that i need to have a main class "shape" and than a class for square , rectangle, etc that inherit from shape.
 
Maybe its something like Pete O'Hanlon wrote, i will try do here something with that Sniff | :^)
 
Thanks for trying to help me Smile | :)
AnswerRe: C# PAINT for school procetmemberPascal Ganaye19 Nov '12 - 8:36 
Very Simple Paint[^]
GeneralRe: C# PAINT for school procetprotectorPete O'Hanlon19 Nov '12 - 8:54 
Have you looked at the code in there? It's not a great example. Everything is done, pretty much, in one class.

*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

AnswerRe: C# PAINT for school procetmember@AmitGajjar20 Nov '12 - 19:40 
The simplest way,
 
Understand the concept with simple example. try with more real life example. and then start working on your project.
 
best luck Smile | :)
Thanks
-Amit Gajjar (MinterProject)

GeneralRe: C# PAINT for school procetprotectorPete O'Hanlon20 Nov '12 - 20:26 
That really doesn't add much to the discussion, so why bother posting it? The poster has already indicated that he has made some effort here, and that he just needs some pointers. Your answer was the equivalent of, when somebody asks you for directions to some place, you saying, first you should practice driving up and down this street.

*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 procetmember@AmitGajjar20 Nov '12 - 20:47 
I am just motivating him.... sometimes people need little bit more effort to get the result and those needs some motivation. And i believe so...
 
I am sorry if this should not be answer.
Thanks
-Amit Gajjar (MinterProject)

GeneralRe: C# PAINT for school procetprotectorPete O'Hanlon20 Nov '12 - 20:51 
If the question is clear, and not a request for you to write all the code, then you should offer practical advice. Being given the piece of information you need to solve a problem is a much better motivator and is more help for a poster.

*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

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


Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 24 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid