ToolMeasureHLine.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using PaintDotNet.Annotation.Command;
  2. using PaintDotNet.Annotation.Enum;
  3. using PaintDotNet.Base.CommTool;
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7. namespace PaintDotNet.Annotation.Measure
  8. {
  9. /// <summary>
  10. /// 测量->直线->直线
  11. /// </summary>
  12. public class ToolMeasureHLine : ToolMeasureObject
  13. {
  14. private static MeasureHLine line;
  15. private static bool moved = false;
  16. public static void OnMouseDown(ISurfaceBox drawArea, MouseEventArgs e)
  17. {
  18. if (e.Button == MouseButtons.Left && e.Clicks != 2)
  19. {
  20. Point pointscroll = GetEventPointInArea(drawArea, e.Location);
  21. line = new MeasureHLine(drawArea, new Point(pointscroll.X, pointscroll.Y), new Point(pointscroll.X + 1, pointscroll.Y));
  22. line.ISurfaceBox = drawArea;
  23. AddNewObject(drawArea, line);
  24. }
  25. else
  26. {
  27. if (!drawArea.ContinuousDrawingMeasure())
  28. {
  29. drawArea.ActiveTool = DrawToolType.Pointer;
  30. }
  31. if (e.Button == MouseButtons.Right && e.Clicks == 1)
  32. {
  33. OnMouseNotLeftDown(drawArea, null);
  34. }
  35. }
  36. }
  37. public static void OnMouseMove(ISurfaceBox drawArea, MouseEventArgs e)
  38. {
  39. if (e.Button == MouseButtons.Left)
  40. {
  41. Point pointscroll = GetEventPointInArea(drawArea, e.Location);
  42. if (e.Button == MouseButtons.Left)
  43. {
  44. if (line != null)
  45. line.moved = true;
  46. moved = true;
  47. if (drawArea.GraphicsList[0] != null)
  48. {
  49. drawArea.GraphicsList[0].MoveHandleTo(pointscroll, 2);
  50. drawArea.Refresh();
  51. drawArea.GraphicsList.Dirty = true;
  52. }
  53. }
  54. }
  55. }
  56. public static void OnMouseUp(ISurfaceBox drawArea, MouseEventArgs e)
  57. {
  58. if (e.Button == MouseButtons.Left)
  59. {
  60. if (!moved)
  61. {
  62. if (line != null)
  63. {
  64. for (int i = 0; i < drawArea.GraphicsList.Count; i++)
  65. {
  66. if (drawArea.GraphicsList[i].drawToolType == line.drawToolType)
  67. {
  68. drawArea.GraphicsList.RemoveAt(i);
  69. break;
  70. }
  71. }
  72. }
  73. }
  74. moved = false;
  75. if (line != null)
  76. {
  77. line.pointChange = false;
  78. line.mouseUpPointChange = false;
  79. }
  80. if (!drawArea.ContinuousDrawingMeasure())
  81. drawArea.ActiveTool = DrawToolType.Pointer;
  82. OnMouseUpTwo(drawArea, e);
  83. }
  84. }
  85. public static void OnMouseClick(ISurfaceBox surfacebox, MouseEventArgs e)
  86. {
  87. }
  88. /// <summary>
  89. /// 鼠标左键双击
  90. /// </summary>
  91. /// <param name="drawArea"></param>
  92. /// <param name="e"></param>
  93. public static void OnMouseLeftDoubleClick(ISurfaceBox surfacebox, MouseEventArgs e)
  94. {
  95. }
  96. /// <summary>
  97. /// 删除按键
  98. /// </summary>
  99. /// <param name="surfacebox"></param>
  100. /// <param name="e"></param>
  101. public static void OnDelKeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  102. {
  103. }
  104. /// <summary>
  105. /// 删除划痕处理&污迹处理选择区域的痕迹
  106. /// </summary>
  107. /// <param name="surfacebox"></param>
  108. /// <param name="e"></param>
  109. public static void OnDel2KeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  110. {
  111. }
  112. /// <summary>
  113. /// 清空全部时调用该方法,将可能未绘制完的对象清空
  114. /// </summary>
  115. public static void beginWithNewObject()
  116. {
  117. }
  118. }
  119. }