ToolScratchTreatmentLine.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using PaintDotNet.Annotation.Enum;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. namespace PaintDotNet.Annotation.Other
  5. {
  6. /// <summary>
  7. /// 工具->划痕处理
  8. /// </summary>
  9. public class ToolScratchTreatmentLine : ToolObject
  10. {
  11. public static void OnMouseDown(ISurfaceBox drawArea, MouseEventArgs e)
  12. {
  13. if (e.Button == MouseButtons.Left)
  14. {
  15. Point pointscroll = GetEventPointInArea(drawArea, e.Location);
  16. DrawScratchTreatmentLine line = new DrawScratchTreatmentLine(drawArea, pointscroll.X, pointscroll.Y, pointscroll.X + 1, pointscroll.Y + 1);
  17. line.ISurfaceBox = drawArea;
  18. AddNewObject(drawArea, line);
  19. }
  20. }
  21. public static void OnMouseMove(ISurfaceBox drawArea, MouseEventArgs e)
  22. {
  23. Point pointscroll = GetEventPointInArea(drawArea, e.Location);
  24. if (e.Button == MouseButtons.Left)
  25. {
  26. if (drawArea.GraphicsList[0] != null)
  27. {
  28. drawArea.GraphicsList[0].MoveHandleTo(pointscroll, 2);
  29. drawArea.Refresh();
  30. drawArea.GraphicsList.Dirty = true;
  31. }
  32. }
  33. }
  34. public static void OnMouseUp(ISurfaceBox drawArea, MouseEventArgs e)
  35. {
  36. if (e.Button == MouseButtons.Left)
  37. {
  38. if (!drawArea.ContinuousDrawingLabel())
  39. {
  40. drawArea.ActiveTool = DrawToolType.Pointer;
  41. }
  42. }
  43. }
  44. /// <summary>
  45. /// Remove selected object
  46. /// </summary>
  47. /// <param name="drawArea"></param>
  48. /// <param name="e"></param>
  49. public static void OnDel2KeyDown(ISurfaceBox drawArea, MouseEventArgs e)
  50. {
  51. if (drawArea != null && drawArea.GraphicsList != null && drawArea.GraphicsList.Count > 0)
  52. {
  53. for (int i = drawArea.GraphicsList.Count - 1; i >= 0; i--)
  54. {
  55. if (drawArea.GraphicsList[i].drawToolType == DrawToolType.DrawScratchTreatmentLine/*drawArea.GraphicsList[i].Selected == true*/)
  56. {
  57. drawArea.GraphicsList.RemoveObj(drawArea.GraphicsList[i]);
  58. }
  59. }
  60. drawArea.Refresh();
  61. }
  62. }
  63. public static void OnMouseClick(ISurfaceBox drawArea, MouseEventArgs e)
  64. {
  65. }
  66. /// <summary>
  67. /// 鼠标左键双击
  68. /// </summary>
  69. /// <param name="drawArea"></param>
  70. /// <param name="e"></param>
  71. public static void OnMouseLeftDoubleClick(ISurfaceBox surfacebox, MouseEventArgs e)
  72. {
  73. }
  74. /// <summary>
  75. /// 删除按键
  76. /// </summary>
  77. /// <param name="surfacebox"></param>
  78. /// <param name="e"></param>
  79. public static void OnDelKeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  80. {
  81. }
  82. /// <summary>
  83. /// 清空全部时调用该方法,将可能未绘制完的对象清空
  84. /// </summary>
  85. public static void beginWithNewObject()
  86. {
  87. }
  88. ///// <summary>
  89. ///// Remove selected object
  90. ///// </summary>
  91. ///// <param name="drawArea"></param>
  92. ///// <param name="e"></param>
  93. //public override void OnDelKeyDown(ISurfaceBox drawArea, MouseEventArgs e)
  94. //{
  95. // if (drawArea != null && drawArea.GraphicsList != null && drawArea.GraphicsList.Count > 0)
  96. // {
  97. // for (int i = drawArea.GraphicsList.Count - 1; i >= 0; i--)
  98. // {
  99. // if (drawArea.GraphicsList[i].Selected == true)
  100. // {
  101. // //对数字标记做单独处理
  102. // if (drawArea.GraphicsList[i].drawToolType == DrawToolType.DrawNumberMark)
  103. // {
  104. // DrawNumberMark drawNumberMark = (DrawNumberMark)drawArea.GraphicsList[i];
  105. // List<DrawObject> objList = drawArea.GraphicsList.GetDrawToolTypeList(DrawToolType.DrawNumberMark);
  106. // if (objList != null && objList.Count > 0)
  107. // {
  108. // for (int j = 0; j < objList.Count; j++)
  109. // {
  110. // DrawNumberMark modifyNum = (DrawNumberMark)objList[j];
  111. // if (modifyNum.nowNum > drawNumberMark.nowNum)
  112. // {
  113. // modifyNum.nowNum -= 1;
  114. // }
  115. // }
  116. // }
  117. // }
  118. // drawArea.GraphicsList.RemoveObj(drawArea.GraphicsList[i]);
  119. // }
  120. // }
  121. // drawArea.Refresh();
  122. // }
  123. //}
  124. }
  125. }