If freehand only have one point then draw ellipse to that point using border size

This commit is contained in:
Jaex 2016-08-17 02:41:13 +03:00
parent 51d72b6a4e
commit 952312662e

View file

@ -36,6 +36,14 @@ public class FreehandDrawingShape : BaseDrawingShape
public override bool ShowResizeNodes { get; } = false;
public override bool IsValidShape
{
get
{
return points.Count > 0;
}
}
public Point LastPosition
{
get
@ -104,10 +112,20 @@ public override void OnUpdate()
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;
if (points.Count == 1)
{
using (Brush brush = new SolidBrush(BorderColor))
{
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())
{
@ -118,6 +136,7 @@ public override void OnDraw(Graphics g)
g.DrawPath(pen, gp);
}
}
g.SmoothingMode = SmoothingMode.None;
}