ToolPPhasePolygon.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows.Forms;
  8. namespace PaintDotNet.Annotation.PhysicalPhaseAction
  9. {
  10. /// <summary>
  11. /// 物相提取->定义物体->轮廓->多边形
  12. /// </summary>
  13. public class ToolPPhasePolygon : ToolObject
  14. {
  15. private static DrawPPhasePolygon drawObject;
  16. public ToolPPhasePolygon(ISurfaceBox surface)
  17. {
  18. Cursor = new Cursor(PdnResources.GetResourceStream("Cursors.AnnotationPencil.cur"));
  19. }
  20. public static void OnMouseDown(ISurfaceBox drawArea, MouseEventArgs e)
  21. {
  22. if (e.Button == MouseButtons.Left)
  23. {
  24. Point p = GetEventPointInArea(drawArea, e.Location);
  25. if (drawObject == null)
  26. {
  27. drawObject = new DrawPPhasePolygon(drawArea, p.X, p.Y);
  28. drawObject.ISurfaceBox = drawArea;
  29. AddNewObject(drawArea, drawObject);
  30. }
  31. else
  32. {
  33. drawObject.setNextPoint(p);
  34. }
  35. drawArea.Refresh();
  36. }
  37. else //右键或其它
  38. {
  39. //处理计算多边形内的像素
  40. drawArea.PPhaseActionPolygon(drawObject.pointArray);
  41. //删除对象
  42. RemoveOldObject(drawArea, drawObject);
  43. //销毁对象
  44. drawObject = null;
  45. }
  46. }
  47. public static void OnMouseMove(ISurfaceBox drawArea, MouseEventArgs e)
  48. {
  49. }
  50. public static void OnMouseUp(ISurfaceBox drawArea, MouseEventArgs e)
  51. {
  52. }
  53. public static void OnMouseClick(ISurfaceBox drawArea, MouseEventArgs e)
  54. {
  55. }
  56. /// <summary>
  57. /// 鼠标左键双击
  58. /// </summary>
  59. /// <param name="drawArea"></param>
  60. /// <param name="e"></param>
  61. public static void OnMouseLeftDoubleClick(ISurfaceBox surfacebox, MouseEventArgs e)
  62. {
  63. }
  64. /// <summary>
  65. /// 删除按键
  66. /// </summary>
  67. /// <param name="surfacebox"></param>
  68. /// <param name="e"></param>
  69. public static void OnDelKeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  70. {
  71. }
  72. /// <summary>
  73. /// 删除划痕处理&污迹处理选择区域的痕迹
  74. /// </summary>
  75. /// <param name="surfacebox"></param>
  76. /// <param name="e"></param>
  77. public static void OnDel2KeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  78. {
  79. }
  80. /// <summary>
  81. /// 清空全部时调用该方法,将可能未绘制完的对象清空
  82. /// </summary>
  83. public static void beginWithNewObject()
  84. {
  85. drawObject = null;
  86. }
  87. }
  88. }