ToolPPhaseRectangle.cs 2.9 KB

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