T
Tony Johansson
Hello!
Below I have a method Form1_Paint that does some drawing on the screen.
Now to my question what is the point to have a method AddRectangle in class
GraphicsPath when
class Graphics have the method DrawRectangle. In my example rows marked
with 1 and 2 in the code draw
identically rectangle. So why have methods in classes that is not necessary
because in this case we already have
DrawRectangle in class Graphics.
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Pen p = new Pen(Color.Red, 7);
GraphicsPath graphPath = new GraphicsPath();
Point myPoint = new Point(1, 1);
Size mySize = new Size(100, 200);
1 graphPath.AddRectangle(new Rectangle(myPoint, mySize));
1 g.DrawPath(p, graphPath);
2 g.DrawRectangle(p, new Rectangle(myPoint, mySize));
}
//Tony
Below I have a method Form1_Paint that does some drawing on the screen.
Now to my question what is the point to have a method AddRectangle in class
GraphicsPath when
class Graphics have the method DrawRectangle. In my example rows marked
with 1 and 2 in the code draw
identically rectangle. So why have methods in classes that is not necessary
because in this case we already have
DrawRectangle in class Graphics.
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Pen p = new Pen(Color.Red, 7);
GraphicsPath graphPath = new GraphicsPath();
Point myPoint = new Point(1, 1);
Size mySize = new Size(100, 200);
1 graphPath.AddRectangle(new Rectangle(myPoint, mySize));
1 g.DrawPath(p, graphPath);
2 g.DrawRectangle(p, new Rectangle(myPoint, mySize));
}
//Tony