using PaintDotNet.Annotation.Enum; using PaintDotNet.Annotation.Label; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; namespace PaintDotNet.Annotation.Other { /// /// 二值提取 - 交互操作 - 分割 - 直线 /// public class DrawBinaryConnectionLine : DrawObject { public DrawBinaryConnectionLine(ISurfaceBox surfaceBox, int x, int y, int x1, int y1) : base() { this.objectType = DrawClass.Interaction; this.drawToolType = DrawToolType.BinaryConnectionLine; this.ISurfaceBox = surfaceBox; startPoint.X = x; startPoint.Y = y; endPoint.X = x1; endPoint.Y = y1; Initialize(); } public override DrawObject Clone() { return null; } public override void Draw(Graphics g) { g.SmoothingMode = SmoothingMode.AntiAlias; Pen pen = new Pen(Color.Red, this.ISurfaceBox.GetConnectionWidth()); pen.DashStyle = DashStyle.Dash; g.DrawLine(pen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); pen.Dispose(); } public override RectangleF GetBoundingBox() { return rectangle; } public override void MoveHandleTo(Point point, int handleNumber) { if (handleNumber == 1) startPoint = point; else endPoint = point; } } }