diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/BaseDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/BaseDrawingShape.cs index 28fc735b7..3cdf0f9a8 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/BaseDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/BaseDrawingShape.cs @@ -35,6 +35,14 @@ public abstract class BaseDrawingShape : BaseShape public int BorderSize { get; set; } public Color FillColor { get; set; } + public bool Shadow { get; set; } = true; + public Color ShadowColor { get; set; } = Color.FromArgb(125, 0, 0, 0); + public Point ShadowDirection { get; set; } = new Point(0, 1); + + public bool IsShapeVisible => IsBorderVisible || IsFillVisible; + public bool IsBorderVisible => BorderSize > 0 && BorderColor.A > 0; + public bool IsFillVisible => FillColor.A > 0; + public override void OnConfigLoad() { BorderColor = AnnotationOptions.BorderColor; diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/RectangleDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/RectangleDrawingShape.cs index 71dc24645..97bea00b5 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/RectangleDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/RectangleDrawingShape.cs @@ -36,33 +36,43 @@ public class RectangleDrawingShape : BaseDrawingShape public int CornerRadius { get; set; } public override void OnDraw(Graphics g) + { + if (Shadow && IsBorderVisible) + { + DrawRectangle(g, ShadowColor, BorderSize, Color.Transparent, Rectangle.LocationOffset(ShadowDirection), CornerRadius); + } + + DrawRectangle(g, BorderColor, BorderSize, FillColor, Rectangle, CornerRadius); + } + + private void DrawRectangle(Graphics g, Color borderColor, int borderSize, Color fillColor, Rectangle rect, int cornerRadius) { Brush brush = null; Pen pen = null; try { - if (FillColor.A > 0) + if (IsFillVisible) { - brush = new SolidBrush(FillColor); + brush = new SolidBrush(fillColor); } - if (BorderSize > 0 && BorderColor.A > 0) + if (IsBorderVisible) { - pen = new Pen(BorderColor, BorderSize); + pen = new Pen(borderColor, borderSize); } - if (CornerRadius > 0) + if (cornerRadius > 0) { g.SmoothingMode = SmoothingMode.HighQuality; - if (BorderSize.IsEvenNumber()) + if (borderSize.IsEvenNumber()) { g.PixelOffsetMode = PixelOffsetMode.Half; } } - g.DrawRoundedRectangle(brush, pen, Rectangle, CornerRadius); + g.DrawRoundedRectangle(brush, pen, rect, cornerRadius); g.SmoothingMode = SmoothingMode.None; g.PixelOffsetMode = PixelOffsetMode.Default;