using PaintDotNet.Annotation.Enum; using PaintDotNet.Annotation.Label; using System.Drawing; using System.Windows.Forms; namespace PaintDotNet.Annotation.Other { /// /// 二值提取-交互操作-删除-椭圆 /// public class DrawBinaryDeleteOval : DrawObject { public DrawBinaryDeleteOval(ISurfaceBox surfaceBox, int x, int y, int width, int height) : base() { this.objectType = DrawClass.Interaction; this.drawToolType = DrawToolType.BinaryDeleteOval; this.rectangle.X = x; this.rectangle.Y = y; this.rectangle.Width = width; this.rectangle.Height = height; Initialize(); } public override DrawObject Clone() { return null; } public override void Draw(Graphics g) { Pen pen = new Pen(Color.Red, 3); pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; SolidBrush fillBrush = new SolidBrush(Color.Transparent); g.FillRectangle(fillBrush, DrawRectangle.GetNormalizedRectangle(Rectangle)); g.DrawEllipse(pen, DrawRectangle.GetNormalizedRectangle(Rectangle)); fillBrush.Dispose(); pen.Dispose(); } public override RectangleF GetBoundingBox() { return rectangle; } /// /// Move handle to new pointscroll (resizing) /// /// /// public override void MoveHandleTo(Point point, int handleNumber) { float left = Rectangle.Left; float top = Rectangle.Top; float right = Rectangle.Right; float bottom = Rectangle.Bottom; switch (handleNumber) { case 1: left = point.X; top = point.Y; break; case 2: top = point.Y; break; case 3: right = point.X; top = point.Y; break; case 4: right = point.X; break; case 5: right = point.X; bottom = point.Y; break; case 6: bottom = point.Y; break; case 7: left = point.X; bottom = point.Y; break; case 8: left = point.X; break; } SetRectangle(left, top, right - left, bottom - top); } protected void SetRectangle(float x, float y, float width, float height) { this.rectangle.X = x; this.rectangle.Y = y; this.rectangle.Width = width; this.rectangle.Height = height; } } }