ToolMeasureHLine.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using SmartCoalApplication.Annotation.Command;
  2. using SmartCoalApplication.Annotation.Enum;
  3. using SmartCoalApplication.Base.CommTool;
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7. namespace SmartCoalApplication.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. double unit = drawArea.getUnitNum();
  21. string name = drawArea.getAliasName();
  22. if (line == null)
  23. {
  24. Point pointscroll = GetEventPointInArea(drawArea, e.Location);
  25. line = new MeasureHLine(drawArea, new Point(pointscroll.X, pointscroll.Y), new Point(pointscroll.X + 1, pointscroll.Y), name, unit);
  26. line.ISurfaceBox = drawArea;
  27. AddNewObject(drawArea, line);
  28. }
  29. }
  30. else
  31. {
  32. if (!drawArea.ContinuousDrawingMeasure())
  33. {
  34. drawArea.ActiveTool = DrawToolType.Pointer;
  35. }
  36. if (e.Button == MouseButtons.Right && e.Clicks == 1)
  37. {
  38. OnMouseNotLeftDown(drawArea, null);
  39. }
  40. }
  41. }
  42. public static void OnMouseMove(ISurfaceBox drawArea, MouseEventArgs e)
  43. {
  44. Point pointscroll = GetEventPointInArea(drawArea, e.Location);
  45. if (line != null)
  46. {
  47. line.moved = true;
  48. moved = true;
  49. if (drawArea.GraphicsList[0] != null)
  50. {
  51. drawArea.GraphicsList[0].MoveHandleTo(pointscroll, 2);
  52. drawArea.Refresh();
  53. drawArea.GraphicsList.Dirty = true;
  54. }
  55. }
  56. }
  57. public static void OnMouseUp(ISurfaceBox drawArea, MouseEventArgs e)
  58. {
  59. if (e.Button == MouseButtons.Left)
  60. {
  61. if (line != null)
  62. {
  63. Point pointscroll = GetEventPointInArea(drawArea, e.Location);
  64. if ((pointscroll.X == line.startPoint.X && pointscroll.Y == line.startPoint.Y))
  65. {
  66. return;
  67. }
  68. line.endPoint = new PointF(pointscroll.X, line.startPoint.Y);
  69. if (!moved)
  70. {
  71. if (line != null)
  72. {
  73. for (int i = 0; i < drawArea.GraphicsList.Count; i++)
  74. {
  75. if (drawArea.GraphicsList[i].drawToolType == line.drawToolType)
  76. {
  77. drawArea.GraphicsList.RemoveAt(i);
  78. break;
  79. }
  80. }
  81. }
  82. }
  83. moved = false;
  84. line.pointChange = false;
  85. line.mouseUpPointChange = false;
  86. }
  87. line = null;
  88. if (!drawArea.ContinuousDrawingMeasure())
  89. drawArea.ActiveTool = DrawToolType.Pointer;
  90. OnMouseUpTwo(drawArea, e);
  91. }
  92. }
  93. public static void OnMouseClick(ISurfaceBox surfacebox, MouseEventArgs e)
  94. {
  95. }
  96. /// <summary>
  97. /// 鼠标左键双击
  98. /// </summary>
  99. /// <param name="drawArea"></param>
  100. /// <param name="e"></param>
  101. public static void OnMouseLeftDoubleClick(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 OnDelKeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  110. {
  111. }
  112. /// <summary>
  113. /// 删除划痕处理&污迹处理选择区域的痕迹
  114. /// </summary>
  115. /// <param name="surfacebox"></param>
  116. /// <param name="e"></param>
  117. public static void OnDel2KeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  118. {
  119. }
  120. /// <summary>
  121. /// 清空全部时调用该方法,将可能未绘制完的对象清空
  122. /// </summary>
  123. public static void beginWithNewObject()
  124. {
  125. }
  126. }
  127. }