From efe88bde5756e16610cf288a088a15d5954aae5c Mon Sep 17 00:00:00 2001 From: Jaex Date: Tue, 29 Nov 2016 19:52:07 +0300 Subject: [PATCH] Added ellipse shadow --- .../Shapes/Drawing/EllipseDrawingShape.cs | 23 ++++++++++++++----- .../Shapes/Drawing/RectangleDrawingShape.cs | 4 ++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/EllipseDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/EllipseDrawingShape.cs index c1bb9d78f..c33145d68 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/EllipseDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/EllipseDrawingShape.cs @@ -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); } } diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/RectangleDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/RectangleDrawingShape.cs index 97bea00b5..9c20f8eb1 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/RectangleDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/RectangleDrawingShape.cs @@ -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); }