1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using PaintDotNet.Annotation.Enum;
- using PaintDotNet.Base.CommTool;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Globalization;
- using System.Runtime.Serialization;
- using System.Windows.Forms;
- namespace PaintDotNet.Annotation.FieldView
- {
- /// <summary>
- /// 多边形视场绘制
- /// </summary>
- public class ViewTriangleEx : ViewBase
- {
- #region Constructor
- private ViewTriangleEx()
- {
- objectType = DrawClass.View;
- drawToolType = DrawToolType.ViewTriangleEx;
- Rotatable = true;
- Initialize();
- }
- public ViewTriangleEx(int x, int y) : this()
- {
- Points = new List<PointF>();
- AddPoint(new PointF(x, y));
- }
- public ViewTriangleEx(List<PointF> points) : this()
- {
- Points = points;
- }
- #endregion
- internal void SetNextPoint(Point p)
- {
- AddPoint(p);
- }
- #region Handle
- public override int HandleCount
- {
- get => Points.Count > 2 ? Points.Count + 1 : Points.Count;
- }
- public override Cursor GetHandleCursor(int handleNumber)
- {
- if (handleNumber > Points.Count)
- return m_rotateCursor;
- else
- return m_resizeCursor;
- }
- public override PointF GetHandle(int handleNumber)
- {
- if (handleNumber < 4) return Points[handleNumber - 1];
- else
- {
- var x = (Points[0].X + Points[1].X) / 2;
- var y = (Points[0].Y + Points[1].Y) / 2;
- return new PointF(x, y);
- }
- }
- public override void MoveHandleTo(Point point, int handleNumber)
- {
- if (handleNumber == 4)
- MoveRotate(point);
- else
- Points[handleNumber - 1] = point;
- OnPropertyChanged();
- }
- #endregion
- #region Clone
- public override DrawObject Clone()
- {
- return Clone(ISurfaceBox);
- }
- public override DrawObject Clone(ISurfaceBox surfaceBox)
- {
- ViewTriangleEx drawRectangle = new ViewTriangleEx(Points);
- drawRectangle.ISurfaceBox = surfaceBox;
- drawRectangle.Color = Color;
- drawRectangle.combineMode = combineMode;
- drawRectangle.ID = ID;
- FillDrawObjectFields(drawRectangle);
- return drawRectangle;
- }
- #endregion
- }
- }
|