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();
}
///
/// Draw rectangle
///
///
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);
}
///
/// 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);
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);
}
///
/// Move object
///
///
///
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 GetPoints()
{
List points = new List();
points.Add(GetHandle(1));
points.Add(GetHandle(5));
return points;
}
}
}