ToolSmudgeEllipse.cs 3.1 KB

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