When drawing freehand region you can hold "Shift" to draw direct lines which will act like polygon region

This commit is contained in:
Jaex 2016-08-04 04:13:57 +03:00
parent efa8704879
commit 1315f47340
2 changed files with 29 additions and 4 deletions

View File

@ -526,5 +526,24 @@ namespace ShareX.HelpersLib
{
return Rectangle.Union(rect, new Rectangle(point, new Size(1, 1)));
}
public static Rectangle CreateRectangle(this IEnumerable<Point> points)
{
Rectangle result = Rectangle.Empty;
foreach (Point point in points)
{
if (result.IsEmpty)
{
result = new Rectangle(point, new Size(1, 1));
}
else
{
result = result.AddPoint(point);
}
}
return result;
}
}
}

View File

@ -42,12 +42,18 @@ namespace ShareX.ScreenCaptureLib
{
if (Manager.IsCreating)
{
if (points.Count == 0 || points.Last() != InputManager.MousePosition0Based)
Point pos = InputManager.MousePosition0Based;
if (points.Count == 0 || (!Manager.IsProportionalResizing && points.Last() != pos))
{
Point point = InputManager.MousePosition0Based;
points.Add(point);
Rectangle = Rectangle.AddPoint(point);
points.Add(pos);
}
else if (Manager.IsProportionalResizing)
{
points[points.Count - 1] = InputManager.MousePosition0Based;
}
Rectangle = points.CreateRectangle();
}
else if (Manager.IsMoving)
{