ToolPPhaseOval.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 ToolPPhaseOval : ToolObject
  14. {
  15. private static DrawPPhaseOval drawObject;
  16. public ToolPPhaseOval(ISurfaceBox surface)
  17. {
  18. Cursor = new Cursor(PdnResources.GetResourceStream("Cursors.AnnotationPencil.cur"));
  19. }
  20. public static void OnMouseDown(ISurfaceBox drawArea, MouseEventArgs e)
  21. {
  22. Point pointscroll = GetEventPointInArea(drawArea, e.Location);
  23. drawObject = new DrawPPhaseOval(drawArea, pointscroll.X, pointscroll.Y, 1, 1);
  24. drawObject.ISurfaceBox = drawArea;
  25. AddNewObject(drawArea, drawObject);
  26. }
  27. public static void OnMouseMove(ISurfaceBox drawArea, MouseEventArgs e)
  28. {
  29. Point pointscroll = GetEventPointInArea(drawArea, e.Location);
  30. if (e.Button == MouseButtons.Left)
  31. {
  32. drawArea.GraphicsList[0].MoveHandleTo(pointscroll, 5);
  33. drawArea.Refresh();
  34. drawArea.GraphicsList.Dirty = true;
  35. }
  36. }
  37. public static void OnMouseUp(ISurfaceBox drawArea, MouseEventArgs e)
  38. {
  39. //处理计算椭圆内的像素
  40. drawArea.PPhaseActionOval(drawObject.Rectangle);
  41. //删除对象
  42. RemoveOldObject(drawArea, drawObject);
  43. }
  44. public static void OnMouseClick(ISurfaceBox drawArea, MouseEventArgs e)
  45. {
  46. }
  47. /// <summary>
  48. /// 鼠标左键双击
  49. /// </summary>
  50. /// <param name="drawArea"></param>
  51. /// <param name="e"></param>
  52. public static void OnMouseLeftDoubleClick(ISurfaceBox surfacebox, MouseEventArgs e)
  53. {
  54. }
  55. /// <summary>
  56. /// 删除按键
  57. /// </summary>
  58. /// <param name="surfacebox"></param>
  59. /// <param name="e"></param>
  60. public static void OnDelKeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  61. {
  62. }
  63. /// <summary>
  64. /// 删除划痕处理&污迹处理选择区域的痕迹
  65. /// </summary>
  66. /// <param name="surfacebox"></param>
  67. /// <param name="e"></param>
  68. public static void OnDel2KeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
  69. {
  70. }
  71. /// <summary>
  72. /// 清空全部时调用该方法,将可能未绘制完的对象清空
  73. /// </summary>
  74. public static void beginWithNewObject()
  75. {
  76. drawObject = null;
  77. }
  78. }
  79. }