mirror of
https://github.com/ShareX/ShareX.git
synced 2024-08-05 21:38:40 +12:00
If freehand only have one point then draw ellipse to that point using border size
This commit is contained in:
parent
51d72b6a4e
commit
952312662e
1 changed files with 25 additions and 6 deletions
|
@ -36,6 +36,14 @@ public class FreehandDrawingShape : BaseDrawingShape
|
||||||
|
|
||||||
public override bool ShowResizeNodes { get; } = false;
|
public override bool ShowResizeNodes { get; } = false;
|
||||||
|
|
||||||
|
public override bool IsValidShape
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return points.Count > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Point LastPosition
|
public Point LastPosition
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -104,19 +112,30 @@ public override void OnUpdate()
|
||||||
|
|
||||||
public override void OnDraw(Graphics g)
|
public override void OnDraw(Graphics g)
|
||||||
{
|
{
|
||||||
if (points.Count > 1 && BorderSize > 0 && BorderColor.A > 0)
|
if (points.Count > 0 && BorderSize > 0 && BorderColor.A > 0)
|
||||||
{
|
{
|
||||||
g.SmoothingMode = SmoothingMode.HighQuality;
|
g.SmoothingMode = SmoothingMode.HighQuality;
|
||||||
|
|
||||||
using (Pen pen = new Pen(BorderColor, BorderSize) { StartCap = LineCap.Round, EndCap = LineCap.Round })
|
if (points.Count == 1)
|
||||||
using (GraphicsPath gp = new GraphicsPath())
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < points.Count - 1; i++)
|
using (Brush brush = new SolidBrush(BorderColor))
|
||||||
{
|
{
|
||||||
gp.AddLine(points[i], points[i + 1]);
|
Rectangle rect = new Rectangle((int)(points[0].X - BorderSize / 2f), (int)(points[0].Y - BorderSize / 2f), BorderSize, BorderSize);
|
||||||
|
g.FillEllipse(brush, rect);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
using (Pen pen = new Pen(BorderColor, BorderSize) { StartCap = LineCap.Round, EndCap = LineCap.Round })
|
||||||
|
using (GraphicsPath gp = new GraphicsPath())
|
||||||
|
{
|
||||||
|
for (int i = 0; i < points.Count - 1; i++)
|
||||||
|
{
|
||||||
|
gp.AddLine(points[i], points[i + 1]);
|
||||||
|
}
|
||||||
|
|
||||||
g.DrawPath(pen, gp);
|
g.DrawPath(pen, gp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g.SmoothingMode = SmoothingMode.None;
|
g.SmoothingMode = SmoothingMode.None;
|
||||||
|
|
Loading…
Reference in a new issue