I know how to draw shapes such as circles, rectangles and other stuff, but what would be the best way to draw groups of shapes as one shape object?
I currently have a class that has three methods, two return rectangle shapes and one that returns a Pen.
My WinForm uses this data to draw a rectangle with another rectangle inside it, and uses the pen as its Pen.
What would be a better way to structure this?
Loading
Danatas GerviPosted Aug 26, 2009, 3:22 AM
You can collect all shapes in one graphic path obgect:
GraphicsPath grPath = new GraphicsPath();
GraphicsPath rectPath = new GraphicsPath();
rectPath.AddRectangle(new Rectangle(30, 30, 30, 30));
GraphicsPath piePath = new GraphicsPath();
piePath.AddPie(new Rectangle(40,40,40,40), 50,50);
grPath.AddPath(rectPath,true);
grPath.AddPath(piePath, true);
CreateGraphics().DrawPath(new Pen(Brushes.Blue), grPath);