mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
Calculate freehand rectangle on update, close figure on shape path requested
This commit is contained in:
parent
c0ab0507f3
commit
3a7510d2a2
2 changed files with 12 additions and 2 deletions
|
@ -521,5 +521,10 @@ public static Rectangle Combine(this IEnumerable<Rectangle> rects)
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Rectangle AddPoint(this Rectangle rect, Point point)
|
||||
{
|
||||
return Rectangle.Union(rect, new Rectangle(point, new Size(1, 1)));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using ShareX.HelpersLib;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
@ -42,7 +43,9 @@ public override void OnUpdate()
|
|||
{
|
||||
if (points.Count == 0 || points.Last() != InputManager.MousePosition0Based)
|
||||
{
|
||||
points.Add(InputManager.MousePosition0Based);
|
||||
Point point = InputManager.MousePosition0Based;
|
||||
points.Add(point);
|
||||
Rectangle = Rectangle.AddPoint(point);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +56,8 @@ public override void OnShapePathRequested(GraphicsPath gp, Rectangle rect)
|
|||
|
||||
if (len > 1)
|
||||
{
|
||||
gp.StartFigure();
|
||||
|
||||
if (len > 2)
|
||||
{
|
||||
for (int i = 0; i < len - 1; i++)
|
||||
|
@ -63,7 +68,7 @@ public override void OnShapePathRequested(GraphicsPath gp, Rectangle rect)
|
|||
|
||||
gp.AddLine(points[len - 1], points[0]);
|
||||
|
||||
Rectangle = Rectangle.Round(gp.GetBounds());
|
||||
gp.CloseFigure();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue