mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-15 11:26:36 +12:00
Calculate freehand rectangle on update, close figure on shape path requested
This commit is contained in:
parent
c0ab0507f3
commit
3a7510d2a2
|
@ -521,5 +521,10 @@ public static Rectangle Combine(this IEnumerable<Rectangle> rects)
|
||||||
|
|
||||||
return result;
|
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 @@
|
||||||
|
|
||||||
#endregion License Information (GPL v3)
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
|
using ShareX.HelpersLib;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
|
@ -42,7 +43,9 @@ public override void OnUpdate()
|
||||||
{
|
{
|
||||||
if (points.Count == 0 || points.Last() != InputManager.MousePosition0Based)
|
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)
|
if (len > 1)
|
||||||
{
|
{
|
||||||
|
gp.StartFigure();
|
||||||
|
|
||||||
if (len > 2)
|
if (len > 2)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < len - 1; i++)
|
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]);
|
gp.AddLine(points[len - 1], points[0]);
|
||||||
|
|
||||||
Rectangle = Rectangle.Round(gp.GetBounds());
|
gp.CloseFigure();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue