ToolSmudgePolygon.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using PaintDotNet.Annotation.Enum;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. namespace PaintDotNet.Annotation.Label
  5. {
  6. /// <summary>
  7. /// 污迹处理->多边形
  8. /// </summary>
  9. public class ToolSmudgePolygon : ToolObject
  10. {
  11. public ToolSmudgePolygon()
  12. {
  13. Cursor = new Cursor(PdnResources.GetResourceStream("Cursors.AnnotationPencil.cur"));
  14. }
  15. private static DrawSmudgePolygon newPolygon;
  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. Point p = GetEventPointInArea(drawArea, e.Location);
  26. if (newPolygon == null)
  27. {
  28. newPolygon = new DrawSmudgePolygon(drawArea, p.X, p.Y);
  29. newPolygon.ISurfaceBox = drawArea;
  30. AddNewObject(drawArea, newPolygon);
  31. }
  32. else
  33. {
  34. newPolygon.setNextPoint(p);
  35. }
  36. drawArea.Refresh();
  37. }
  38. else
  39. {
  40. newPolygon = null;
  41. if (!drawArea.ContinuousDrawingLabel())
  42. {
  43. OnMouseUpTwo(drawArea, e);
  44. }
  45. }
  46. }
  47. /// <summary>
  48. /// 鼠标移动,需要进行绘制
  49. /// </summary>
  50. /// <param name="drawArea"></param>
  51. /// <param name="e"></param>
  52. public static void OnMouseMove(ISurfaceBox drawArea, MouseEventArgs e)
  53. {
  54. }
  55. /// <summary>
  56. /// 覆盖父类的鼠标抬起事件,什么都不做
  57. /// </summary>
  58. /// <param name="drawArea"></param>
  59. /// <param name="e"></param>
  60. public static void OnMouseUp(ISurfaceBox drawArea, MouseEventArgs e)
  61. {
  62. }
  63. /// <summary>
  64. /// 清空全部时调用该方法,将可能未绘制完的对象清空
  65. /// </summary>
  66. public static void beginWithNewObject()
  67. {
  68. newPolygon = null;
  69. }
  70. /// <summary>
  71. /// Remove selected object
  72. /// </summary>
  73. /// <param name="drawArea"></param>
  74. /// <param name="e"></param>
  75. public static void OnDel2KeyDown(ISurfaceBox drawArea, MouseEventArgs e)
  76. {
  77. if (drawArea != null && drawArea.GraphicsList != null && drawArea.GraphicsList.Count > 0)
  78. {
  79. for (int i = drawArea.GraphicsList.Count - 1; i >= 0; i--)
  80. {
  81. if (drawArea.GraphicsList[i].drawToolType == DrawToolType.DrawSmudgePolygon/*DrawScratchTreatmentLine*//*drawArea.GraphicsList[i].Selected == true*/)
  82. {
  83. drawArea.GraphicsList.RemoveObj(drawArea.GraphicsList[i]);
  84. }
  85. }
  86. drawArea.Refresh();
  87. }
  88. }
  89. public static void OnMouseClick(ISurfaceBox drawArea, MouseEventArgs e)
  90. {
  91. }
  92. /// <summary>
  93. /// 鼠标左键双击
  94. /// </summary>
  95. /// <param name="drawArea"></param>
  96. /// <param name="e"></param>
  97. public static void OnMouseLeftDoubleClick(ISurfaceBox surfacebox, MouseEventArgs e)
  98. {
  99. }
  100. /// <summary>
  101. /// 删除按键
  102. /// </summary>
  103. /// <param name="surfacebox"></param>
  104. /// <param name="e"></param>
  105. public static void OnDelKeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  106. {
  107. }
  108. }
  109. }