Added ellipse shadow

This commit is contained in:
Jaex 2016-11-29 19:52:07 +03:00
parent f28e913a11
commit efe88bde57
2 changed files with 19 additions and 8 deletions

View file

@ -23,6 +23,7 @@
#endregion License Information (GPL v3)
using ShareX.HelpersLib;
using System.Drawing;
using System.Drawing.Drawing2D;
@ -33,22 +34,32 @@ public class EllipseDrawingShape : BaseDrawingShape
public override ShapeType ShapeType { get; } = ShapeType.DrawingEllipse;
public override void OnDraw(Graphics g)
{
if (Shadow && IsBorderVisible)
{
DrawEllipse(g, ShadowColor, BorderSize, Color.Transparent, Rectangle.LocationOffset(ShadowDirection));
}
DrawEllipse(g, BorderColor, BorderSize, FillColor, Rectangle);
}
private void DrawEllipse(Graphics g, Color borderColor, int borderSize, Color fillColor, Rectangle rect)
{
g.SmoothingMode = SmoothingMode.HighQuality;
if (FillColor.A > 0)
if (fillColor.A > 0)
{
using (Brush brush = new SolidBrush(FillColor))
using (Brush brush = new SolidBrush(fillColor))
{
g.FillEllipse(brush, Rectangle);
g.FillEllipse(brush, rect);
}
}
if (BorderSize > 0 && BorderColor.A > 0)
if (borderSize > 0 && borderColor.A > 0)
{
using (Pen pen = new Pen(BorderColor, BorderSize))
using (Pen pen = new Pen(borderColor, borderSize))
{
g.DrawEllipse(pen, Rectangle);
g.DrawEllipse(pen, rect);
}
}

View file

@ -52,12 +52,12 @@ private void DrawRectangle(Graphics g, Color borderColor, int borderSize, Color
try
{
if (IsFillVisible)
if (fillColor.A > 0)
{
brush = new SolidBrush(fillColor);
}
if (IsBorderVisible)
if (borderSize > 0 && borderColor.A > 0)
{
pen = new Pen(borderColor, borderSize);
}