ToolSmudgeRectangle.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 ToolSmudgeRectangle : ToolObject
  10. {
  11. public ToolSmudgeRectangle()
  12. {
  13. Cursor = new Cursor(PdnResources.GetResourceStream("Cursors.AnnotationRectangle.cur"));
  14. }
  15. public static void OnMouseDown(ISurfaceBox drawArea, MouseEventArgs e)
  16. {
  17. if (e.Button == MouseButtons.Left)
  18. {
  19. Point pointscroll = GetEventPointInArea(drawArea, e.Location);
  20. DrawSmudgeRectangle rectangle = new DrawSmudgeRectangle(drawArea, pointscroll.X, pointscroll.Y, 1, 1);
  21. rectangle.ISurfaceBox = drawArea;
  22. AddNewObject(drawArea, rectangle);
  23. }
  24. }
  25. public static void OnMouseMove(ISurfaceBox drawArea, MouseEventArgs e)
  26. {
  27. Point pointscroll = GetEventPointInArea(drawArea, e.Location);
  28. //drawArea.Cursor = Cursor;
  29. if (e.Button == MouseButtons.Left)
  30. {
  31. drawArea.GraphicsList[0].MoveHandleTo(pointscroll, 5);
  32. drawArea.Refresh();
  33. drawArea.GraphicsList.Dirty = true;
  34. }
  35. }
  36. public static void OnMouseUp(ISurfaceBox drawArea, MouseEventArgs e)
  37. {
  38. if (e.Button == MouseButtons.Left)
  39. {
  40. if (!drawArea.ContinuousDrawingLabel())
  41. {
  42. drawArea.ActiveTool = DrawToolType.Pointer;
  43. }
  44. }
  45. }
  46. /// <summary>
  47. /// Remove selected object
  48. /// </summary>
  49. /// <param name="drawArea"></param>
  50. /// <param name="e"></param>
  51. public static void OnDel2KeyDown(ISurfaceBox drawArea, MouseEventArgs e)
  52. {
  53. if (drawArea != null && drawArea.GraphicsList != null && drawArea.GraphicsList.Count > 0)
  54. {
  55. for (int i = drawArea.GraphicsList.Count - 1; i >= 0; i--)
  56. {
  57. if (drawArea.GraphicsList[i].drawToolType == DrawToolType.DrawSmudgeRectangle/*DrawScratchTreatmentLine*//*drawArea.GraphicsList[i].Selected == true*/)
  58. {
  59. drawArea.GraphicsList.RemoveObj(drawArea.GraphicsList[i]);
  60. }
  61. }
  62. drawArea.Refresh();
  63. }
  64. }
  65. public static void OnMouseClick(ISurfaceBox drawArea, MouseEventArgs e)
  66. {
  67. }
  68. /// <summary>
  69. /// 鼠标左键双击
  70. /// </summary>
  71. /// <param name="drawArea"></param>
  72. /// <param name="e"></param>
  73. public static void OnMouseLeftDoubleClick(ISurfaceBox surfacebox, MouseEventArgs e)
  74. {
  75. }
  76. /// <summary>
  77. /// 删除按键
  78. /// </summary>
  79. /// <param name="surfacebox"></param>
  80. /// <param name="e"></param>
  81. public static void OnDelKeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  82. {
  83. }
  84. /// <summary>
  85. /// 清空全部时调用该方法,将可能未绘制完的对象清空
  86. /// </summary>
  87. public static void beginWithNewObject()
  88. {
  89. }
  90. }
  91. }