ToolMeasureMulLineA.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. using PaintDotNet.Annotation.Enum;
  2. using PaintDotNet.Annotation.Measure;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace PaintDotNet.Annotation.PhysicalPhaseAction
  11. {
  12. public class ToolDrawMulLineA : ToolObject
  13. {
  14. private static DrawMulLineA newMulLine;
  15. private static int clickCount = 0; //辅助计算点击次数
  16. /// <summary>
  17. /// Left nouse button is pressed
  18. /// </summary>
  19. /// <param name="drawArea"></param>
  20. /// <param name="e"></param>
  21. public static void OnMouseDown(ISurfaceBox drawArea, MouseEventArgs e)
  22. {
  23. if (e.Button == MouseButtons.Left)
  24. {
  25. clickCount += 1;
  26. Point p = GetEventPointInArea(drawArea, e.Location);
  27. if (newMulLine == null)
  28. {
  29. newMulLine = new DrawMulLineA(drawArea, p.X, p.Y);
  30. newMulLine.ISurfaceBox = drawArea;
  31. AddNewObject(drawArea, newMulLine);
  32. for (int i = 0; i < 6; i++)
  33. {
  34. newMulLine.RectangleFList.Add(new RectangleF());
  35. }
  36. }
  37. drawArea.Refresh();
  38. }
  39. else
  40. {
  41. if (newMulLine != null)
  42. newMulLine.pointChange = false;
  43. clickCount = 0;
  44. newMulLine = null;
  45. if (!drawArea.ContinuousDrawingMeasure())
  46. drawArea.ActiveTool = DrawToolType.Pointer;
  47. }
  48. }
  49. /// <summary>
  50. /// 鼠标移动,需要进行绘制
  51. /// </summary>
  52. /// <param name="drawArea"></param>
  53. /// <param name="e"></param>
  54. public static void OnMouseMove(ISurfaceBox drawArea, MouseEventArgs e)
  55. {
  56. Point pointscroll = GetEventPointInArea(drawArea, e.Location);
  57. if (newMulLine != null)
  58. {
  59. if (drawArea.GraphicsList[0] != null)
  60. {
  61. if (clickCount == 1)
  62. {
  63. if (newMulLine.pointArray.Count == 1)
  64. newMulLine.setNextPoint(pointscroll);
  65. else
  66. newMulLine.pointArray[1] = pointscroll;
  67. }
  68. //if (clickCount > 1)
  69. //{
  70. // //if (newMulLine.pointArray.Count == clickCount)
  71. // // newMulLine.setNextPoint(pointscroll);
  72. // //else
  73. // // newMulLine.pointArray[clickCount] = pointscroll;
  74. // ////newMulLine.MoveHandleTo(pointscroll, clickCount + 1);
  75. //}
  76. drawArea.Refresh();
  77. drawArea.GraphicsList.Dirty = true;
  78. }
  79. }
  80. }
  81. /// <summary>
  82. /// 鼠标抬起事件
  83. /// </summary>
  84. /// <param name="drawArea"></param>
  85. /// <param name="e"></param>
  86. public static void OnMouseUp(ISurfaceBox drawArea, MouseEventArgs e)
  87. {
  88. //for (int i = 0; i < 6; i++)
  89. //{
  90. // newMulLine.RectangleFList.Add(new RectangleF());
  91. //}
  92. beginWithNewObject();
  93. }
  94. public static void OnMouseClick(ISurfaceBox drawArea, MouseEventArgs e)
  95. {
  96. }
  97. /// <summary>
  98. /// 鼠标左键双击
  99. /// </summary>
  100. /// <param name="drawArea"></param>
  101. /// <param name="e"></param>
  102. public static void OnMouseLeftDoubleClick(ISurfaceBox surfacebox, MouseEventArgs e)
  103. {
  104. }
  105. /// <summary>
  106. /// 删除按键
  107. /// </summary>
  108. /// <param name="surfacebox"></param>
  109. /// <param name="e"></param>
  110. public static void OnDelKeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  111. {
  112. }
  113. /// <summary>
  114. /// 删除划痕处理&污迹处理选择区域的痕迹
  115. /// </summary>
  116. /// <param name="surfacebox"></param>
  117. /// <param name="e"></param>
  118. public static void OnDel2KeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  119. {
  120. }
  121. /// <summary>
  122. /// 清空全部时调用该方法,将可能未绘制完的对象清空
  123. /// </summary>
  124. public static void beginWithNewObject()
  125. {
  126. newMulLine = null;
  127. clickCount = 0;
  128. }
  129. }
  130. }