ToolBinaryConnectionLine.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 ToolBinaryConnectionLine : ToolObject
  10. {
  11. private static DrawBinaryConnectionLine drawObject;
  12. public static void OnMouseDown(ISurfaceBox drawArea, MouseEventArgs e)
  13. {
  14. Point pointscroll = GetEventPointInArea(drawArea, e.Location);
  15. drawObject = new DrawBinaryConnectionLine(drawArea, pointscroll.X, pointscroll.Y, pointscroll.X + 1, pointscroll.Y + 1);
  16. drawObject.ISurfaceBox = drawArea;
  17. AddNewObject(drawArea, drawObject);
  18. }
  19. public static void OnMouseMove(ISurfaceBox drawArea, MouseEventArgs e)
  20. {
  21. Point pointscroll = GetEventPointInArea(drawArea, e.Location);
  22. //drawArea.Cursor = Cursor;
  23. if (e.Button == MouseButtons.Left)
  24. {
  25. drawArea.GraphicsList[0].MoveHandleTo(pointscroll, 2);
  26. drawArea.Refresh();
  27. drawArea.GraphicsList.Dirty = true;
  28. }
  29. }
  30. public static void OnMouseUp(ISurfaceBox drawArea, MouseEventArgs e)
  31. {
  32. //直线连接
  33. drawArea.BinaryActionConnectionLine(drawObject.startPoint, drawObject.endPoint);
  34. //删除对象
  35. RemoveOldObject(drawArea, drawObject);
  36. //处理连续绘制
  37. if (!drawArea.ContinuousBinaryAction())
  38. {
  39. drawArea.ActiveTool = DrawToolType.Pointer;
  40. }
  41. OnMouseUpTwo(drawArea, e);
  42. }
  43. public static void OnMouseClick(ISurfaceBox drawArea, MouseEventArgs e)
  44. {
  45. }
  46. /// <summary>
  47. /// 鼠标左键双击
  48. /// </summary>
  49. /// <param name="drawArea"></param>
  50. /// <param name="e"></param>
  51. public static void OnMouseLeftDoubleClick(ISurfaceBox surfacebox, MouseEventArgs e)
  52. {
  53. }
  54. /// <summary>
  55. /// 删除按键
  56. /// </summary>
  57. /// <param name="surfacebox"></param>
  58. /// <param name="e"></param>
  59. public static void OnDelKeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  60. {
  61. }
  62. /// <summary>
  63. /// 删除划痕处理&污迹处理选择区域的痕迹
  64. /// </summary>
  65. /// <param name="surfacebox"></param>
  66. /// <param name="e"></param>
  67. public static void OnDel2KeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  68. {
  69. }
  70. /// <summary>
  71. /// 清空全部时调用该方法,将可能未绘制完的对象清空
  72. /// </summary>
  73. public static void beginWithNewObject()
  74. {
  75. drawObject = null;
  76. }
  77. }
  78. }