| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 | using PaintDotNet.Annotation.Enum;using PaintDotNet.Annotation.FieldView;using System;using System.Collections.Generic;using System.Drawing;using System.Drawing.Drawing2D;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace PaintDotNet.Annotation.DedicatedAnalysis{    public class DrawRecognitionAreaDrawObject : DedicatedAnalysisDrawObject    {        public CombineMode combineMode;        public DrawRecognitionAreaDrawObject():base(null)        {            Initialize();        }        public DrawRecognitionAreaDrawObject(int x, int y, int width, int height) : base(null)        {            this.objectType = DrawClass.Other;            this.drawToolType = DrawToolType.InclusionDrawRecognitionArea;            this.rectangle.X = x;            this.rectangle.Y = y;            this.rectangle.Width = width;            this.rectangle.Height = height;            Initialize();        }        public DrawRecognitionAreaDrawObject(RectangleF rectangle) : base(null)        {            this.objectType = DrawClass.Other;            this.drawToolType = DrawToolType.InclusionDrawRecognitionArea;            this.rectangle = rectangle;            Initialize();        }        /// <summary>        /// Draw rectangle        /// </summary>        /// <param name="g"></param>        public override void Draw(Graphics g)        {            g.DrawRectangles(new Pen(Color.Black, Selected ? 10 : 1),new RectangleF[] { this.rectangle });        }        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;        }        protected override bool PointInObject(Point point)        {            return rectangle.Contains(point);        }        /// <summary>        /// Move handle to new pointscroll (resizing)        /// </summary>        /// <param name="pointscroll"></param>        /// <param name="handleNumber"></param>        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);            base.MoveHandleTo(point, handleNumber);        }        public override bool IntersectsWith(Rectangle rectangle)        {            return this.rectangle.IntersectsWith(rectangle);        }        public override void Normalize()        {            rectangle = GetNormalizedRectangle(rectangle.X, rectangle.Y, rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height);        }        /// <summary>        /// Move object        /// </summary>        /// <param name="deltaX"></param>        /// <param name="deltaY"></param>        public override void Move(int deltaX, int deltaY)        {            int x = ISurfaceBox.UnscaleScalar(deltaX);            int y = ISurfaceBox.UnscaleScalar(deltaY);            this.rectangle.X += x;            this.rectangle.Y += y;            base.Move(deltaX, deltaY);        }        public override List<PointF> GetPoints()        {            List<PointF> points = new List<PointF>();            points.Add(GetHandle(1));            points.Add(GetHandle(5));            return points;        }    }}
 |