123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using PaintDotNet.Annotation.Enum;
- using PaintDotNet.Annotation.Label;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Windows.Forms;
- namespace PaintDotNet.Annotation.Other
- {
- /// <summary>
- /// 二值提取 - 交互操作 - 分割 - 折线
- /// </summary>
- public class DrawBinaryConnectionPolygonLine : DrawObject
- {
- public List<Point> pointArray = new List<Point>();
- public DrawBinaryConnectionPolygonLine(ISurfaceBox surfaceBox, int x1, int y1) : base()
- {
- this.objectType = DrawClass.Interaction;
- this.drawToolType = DrawToolType.BinaryConnectionPolygonLine;
- this.ISurfaceBox = surfaceBox;
- startPoint.X = x1;
- startPoint.Y = y1;
- endPoint.X = x1;
- endPoint.Y = y1;
- pointArray.Add(new Point(x1, y1));
- Initialize();
- }
- public override DrawObject Clone()
- {
- return null;
- }
- public override void Draw(Graphics g)
- {
- if (HandleCount >= 2)
- {
- g.SmoothingMode = SmoothingMode.AntiAlias;
- Pen pen = new Pen(Color.Red, this.ISurfaceBox.GetConnectionWidth());
- pen.DashStyle = DashStyle.Dash;
- g.DrawLines(pen, pointArray.ToArray());
- pen.Dispose();
- }
- }
- public void AddPoint(Point point)
- {
- pointArray.Add(point);
- }
- internal void setNextPoint(Point p)
- {
- AddPoint(p);
- startPoint = endPoint;
- endPoint = p;
- }
- public override RectangleF GetBoundingBox()
- {
- return rectangle;
- }
- public override void MoveHandleTo(Point point, int handleNumber)
- {
- if (handleNumber < 1)
- handleNumber = 1;
- if (handleNumber > pointArray.Count)
- handleNumber = pointArray.Count;
- pointArray[handleNumber - 1] = point;
- }
- public override int HandleCount
- {
- get
- {
- return pointArray.Count;
- }
- }
- }
- }
|