ToolMeasureDistanceLine.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. using SmartCoalApplication.Annotation.Enum;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows.Forms;
  9. namespace SmartCoalApplication.Annotation.Measure
  10. {
  11. public class ToolMeasureDistanceLine : ToolMeasureObject
  12. {
  13. private static MeasureDistanceLine line;
  14. private static bool moved = false;
  15. public static void OnMouseDown(ISurfaceBox drawArea, MouseEventArgs e)
  16. {
  17. if (e.Button == MouseButtons.Left && e.Clicks != 2)
  18. {
  19. Point pointscroll = GetEventPointInArea(drawArea, e.Location);
  20. if (line == null)
  21. {
  22. line = new MeasureDistanceLine(drawArea, new Point(pointscroll.X, pointscroll.Y), new Point(pointscroll.X + 1, pointscroll.Y + 1));
  23. line.ISurfaceBox = drawArea;
  24. AddNewObject(drawArea, line);
  25. }
  26. }
  27. else
  28. {
  29. line = null;
  30. if (!drawArea.ContinuousDrawingMeasure())
  31. {
  32. drawArea.ActiveTool = DrawToolType.Pointer;
  33. }
  34. OnMouseNotLeftDown(drawArea, line);
  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. 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. line = null;
  81. if (!drawArea.ContinuousDrawingMeasure())
  82. {
  83. drawArea.ActiveTool = DrawToolType.Pointer;
  84. }
  85. OnMouseUpTwo(drawArea, e);
  86. }
  87. }
  88. public static void OnMouseClick(ISurfaceBox drawArea, MouseEventArgs e)
  89. {
  90. }
  91. /// <summary>
  92. /// 鼠标左键双击
  93. /// </summary>
  94. /// <param name="drawArea"></param>
  95. /// <param name="e"></param>
  96. public static void OnMouseLeftDoubleClick(ISurfaceBox surfacebox, MouseEventArgs e)
  97. {
  98. }
  99. /// <summary>
  100. /// 删除按键
  101. /// </summary>
  102. /// <param name="surfacebox"></param>
  103. /// <param name="e"></param>
  104. public static void OnDelKeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  105. {
  106. }
  107. /// <summary>
  108. /// 删除划痕处理&污迹处理选择区域的痕迹
  109. /// </summary>
  110. /// <param name="surfacebox"></param>
  111. /// <param name="e"></param>
  112. public static void OnDel2KeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  113. {
  114. }
  115. /// <summary>
  116. /// 清空全部时调用该方法,将可能未绘制完的对象清空
  117. /// </summary>
  118. public static void beginWithNewObject()
  119. {
  120. }
  121. }
  122. }