DrawEllipse.cs 987 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Windows.Forms;
  3. using System.Drawing;
  4. namespace DrawTools
  5. {
  6. /// <summary>
  7. /// Ellipse graphic object
  8. /// </summary>
  9. class DrawEllipse : DrawTools.DrawRectangle
  10. {
  11. public DrawEllipse() : this(0, 0, 1, 1)
  12. {
  13. }
  14. public DrawEllipse(int x, int y, int width, int height) : base()
  15. {
  16. Rectangle = new Rectangle(x, y, width, height);
  17. Initialize();
  18. }
  19. /// <summary>
  20. /// Clone this instance
  21. /// </summary>
  22. public override DrawObject Clone()
  23. {
  24. DrawEllipse drawEllipse = new DrawEllipse();
  25. drawEllipse.Rectangle = this.Rectangle;
  26. FillDrawObjectFields(drawEllipse);
  27. return drawEllipse;
  28. }
  29. public override void Draw(Graphics g)
  30. {
  31. Pen pen = new Pen(Color, PenWidth);
  32. g.DrawEllipse(pen, DrawRectangle.GetNormalizedRectangle(Rectangle));
  33. pen.Dispose();
  34. }
  35. }
  36. }