Rectangle will also set start and end positions

This commit is contained in:
Jaex 2017-11-15 09:54:19 +03:00
parent 59f17da0a8
commit 7766ba374e
2 changed files with 18 additions and 11 deletions

View file

@ -39,9 +39,23 @@ public abstract class BaseShape : IDisposable
public abstract ShapeType ShapeType { get; }
public Rectangle Rectangle { get; set; }
private Rectangle rectangle;
public Rectangle RectangleInsideCanvas => Manager.LimitRectangleToCanvas(Rectangle);
public Rectangle Rectangle
{
get
{
return rectangle;
}
set
{
rectangle = value;
startPosition = rectangle.Location;
endPosition = new Point(rectangle.X + rectangle.Width - 1, rectangle.Y + rectangle.Height - 1);
}
}
public Rectangle RectangleInsideCanvas => Rectangle.Intersect(Rectangle, Manager.Form.CanvasRectangle);
public bool IsInsideCanvas => !RectangleInsideCanvas.IsEmpty;
@ -56,8 +70,7 @@ public Point StartPosition
set
{
startPosition = value;
Rectangle = CaptureHelpers.CreateRectangle(StartPosition, EndPosition);
rectangle = CaptureHelpers.CreateRectangle(startPosition, endPosition);
}
}
@ -72,8 +85,7 @@ public Point EndPosition
set
{
endPosition = value;
Rectangle = CaptureHelpers.CreateRectangle(StartPosition, EndPosition);
rectangle = CaptureHelpers.CreateRectangle(startPosition, endPosition);
}
}

View file

@ -1312,11 +1312,6 @@ public void AddCursor(IntPtr cursorHandle, Point position)
Shapes.Add(shape);
}
public Rectangle LimitRectangleToCanvas(Rectangle rect)
{
return Rectangle.Intersect(rect, Form.CanvasRectangle);
}
public void DrawRegionArea(Graphics g, Rectangle rect, bool isAnimated)
{
Form.DrawRegionArea(g, rect, isAnimated);