using PaintDotNet.Annotation.Enum; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; namespace PaintDotNet.Annotation.Label { /// /// 编辑->图片裁剪 /// public class ImageCutTool : ToolObject { /// /// Left nouse button is pressed /// /// /// public static void OnMouseDown(ISurfaceBox surfaceBox, MouseEventArgs e) { //如当前已存在其他裁剪框,则先删除 if (surfaceBox.GraphicsList.IsExsitSpecificObject(DrawToolType.ImageCut)) { List objList = surfaceBox.GraphicsList.GetDrawToolTypeList(DrawToolType.ImageCut); for (int i = 0; i< objList.Count; i++) { surfaceBox.GraphicsList.RemoveObj(objList[i]); } } Point pointscroll = GetEventPointInArea(surfaceBox, e.Location); ImageCutDraw rectangle = new ImageCutDraw(pointscroll.X, pointscroll.Y, 1, 1); rectangle.ISurfaceBox = surfaceBox; AddNewObject(surfaceBox, rectangle); } /// /// 鼠标移动,需要进行绘制 /// /// /// public static void OnMouseMove(ISurfaceBox surfaceBox, MouseEventArgs e) { Point pointscroll = GetEventPointInArea(surfaceBox, e.Location); if (e.Button == MouseButtons.Left) { if (surfaceBox.GraphicsList.Count > 0) { surfaceBox.GraphicsList[0].MoveHandleTo(pointscroll, 5); surfaceBox.Refresh(); surfaceBox.GraphicsList.Dirty = true; } } } /// /// 覆盖父类的鼠标抬起事件,什么都不做 /// /// /// public static void OnMouseUp(ISurfaceBox drawArea, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { drawArea.ActiveTool = DrawToolType.Pointer; } } public static void OnMouseClick(ISurfaceBox drawArea, MouseEventArgs e) { } /// /// 鼠标左键双击 /// /// /// public static void OnMouseLeftDoubleClick(ISurfaceBox surfacebox, MouseEventArgs e) { } /// /// 删除按键 /// /// /// public static void OnDelKeyDown(ISurfaceBox surfacebox, MouseEventArgs e) { } /// /// 删除划痕处理&污迹处理选择区域的痕迹 /// /// /// public static void OnDel2KeyDown(ISurfaceBox surfacebox, MouseEventArgs e) { } public static void beginWithNewObject() { } } }