DrawBinaryConnectionLine.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using PaintDotNet.Annotation.Enum;
  2. using PaintDotNet.Annotation.Label;
  3. using System.Drawing;
  4. using System.Drawing.Drawing2D;
  5. using System.Windows.Forms;
  6. namespace PaintDotNet.Annotation.Other
  7. {
  8. /// <summary>
  9. /// 二值提取 - 交互操作 - 分割 - 直线
  10. /// </summary>
  11. public class DrawBinaryConnectionLine : DrawObject
  12. {
  13. public DrawBinaryConnectionLine(ISurfaceBox surfaceBox, int x, int y, int x1, int y1) : base()
  14. {
  15. this.objectType = DrawClass.Interaction;
  16. this.drawToolType = DrawToolType.BinaryConnectionLine;
  17. this.ISurfaceBox = surfaceBox;
  18. startPoint.X = x;
  19. startPoint.Y = y;
  20. endPoint.X = x1;
  21. endPoint.Y = y1;
  22. Initialize();
  23. }
  24. public override DrawObject Clone()
  25. {
  26. return null;
  27. }
  28. public override void Draw(Graphics g)
  29. {
  30. g.SmoothingMode = SmoothingMode.AntiAlias;
  31. Pen pen = new Pen(Color.Red, this.ISurfaceBox.GetConnectionWidth());
  32. pen.DashStyle = DashStyle.Dash;
  33. g.DrawLine(pen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
  34. pen.Dispose();
  35. }
  36. public override RectangleF GetBoundingBox()
  37. {
  38. return rectangle;
  39. }
  40. public override void MoveHandleTo(Point point, int handleNumber)
  41. {
  42. if (handleNumber == 1)
  43. startPoint = point;
  44. else
  45. endPoint = point;
  46. }
  47. }
  48. }