ToolMeasureVLine.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 ToolMeasureVLine : ToolMeasureObject
  13. {
  14. private static MeasureVLine 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 MeasureVLine(drawArea, new Point(pointscroll.X, pointscroll.Y), new Point(pointscroll.X, pointscroll.Y+1));
  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. if (line != null)
  42. line.moved = true;
  43. moved = true;
  44. Point pointscroll = GetEventPointInArea(drawArea, e.Location);
  45. if (e.Button == MouseButtons.Left)
  46. {
  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. /// <summary>
  57. /// 鼠标抬起事件
  58. /// </summary>
  59. /// <param name="drawArea"></param>
  60. /// <param name="e"></param>
  61. public static void OnMouseUp(ISurfaceBox drawArea, MouseEventArgs e)
  62. {
  63. if (e.Button == MouseButtons.Left)
  64. {
  65. if (!moved)
  66. {
  67. if (line != null)
  68. {
  69. for (int i = 0; i < drawArea.GraphicsList.Count; i++)
  70. {
  71. if (drawArea.GraphicsList[i].drawToolType == line.drawToolType)
  72. {
  73. drawArea.GraphicsList.RemoveAt(i);
  74. break;
  75. }
  76. }
  77. }
  78. }
  79. moved = false;
  80. if (line != null)
  81. {
  82. line.pointChange = false;
  83. line.mouseUpPointChange = false;
  84. }
  85. if (!drawArea.ContinuousDrawingMeasure())
  86. drawArea.ActiveTool = DrawToolType.Pointer;
  87. OnMouseUpTwo(drawArea, e);
  88. }
  89. }
  90. public static void OnMouseClick(ISurfaceBox drawArea, MouseEventArgs e)
  91. {
  92. }
  93. /// <summary>
  94. /// 鼠标左键双击
  95. /// </summary>
  96. /// <param name="drawArea"></param>
  97. /// <param name="e"></param>
  98. public static void OnMouseLeftDoubleClick(ISurfaceBox surfacebox, MouseEventArgs e)
  99. {
  100. }
  101. /// <summary>
  102. /// 删除按键
  103. /// </summary>
  104. /// <param name="surfacebox"></param>
  105. /// <param name="e"></param>
  106. public static void OnDelKeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  107. {
  108. }
  109. /// <summary>
  110. /// 删除划痕处理&污迹处理选择区域的痕迹
  111. /// </summary>
  112. /// <param name="surfacebox"></param>
  113. /// <param name="e"></param>
  114. public static void OnDel2KeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  115. {
  116. }
  117. /// <summary>
  118. /// 清空全部时调用该方法,将可能未绘制完的对象清空
  119. /// </summary>
  120. public static void beginWithNewObject()
  121. {
  122. }
  123. }
  124. }