From a60139d91dd3076dee87a989f4c7325d38f10413 Mon Sep 17 00:00:00 2001 From: Don McComb Date: Sun, 17 Jun 2018 14:50:54 +1000 Subject: [PATCH] Simplified code by better utilising DrawEllipse The only downside of this simplification is that it no longer produces the 'glow' around the step label. --- Greenshot.sln | 8 ++++--- Greenshot/Drawing/StepLabelContainer.cs | 31 +------------------------ 2 files changed, 6 insertions(+), 33 deletions(-) diff --git a/Greenshot.sln b/Greenshot.sln index b76fba9a6..8f3572d70 100644 --- a/Greenshot.sln +++ b/Greenshot.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.27130.2010 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Greenshot", "Greenshot\Greenshot.csproj", "{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}" EndProject @@ -181,7 +181,6 @@ Global {9C0ECC4C-7807-4111-916A-4F57BB29788A}.Release|x86.Build.0 = Release|x86 {9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|x86.ActiveCfg = Debug|Any CPU {9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|x86.Build.0 = Debug|Any CPU {9801F62C-540F-4BFE-9211-6405DEDE563B}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -193,4 +192,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1D6A3118-38AE-46C7-BEDA-FF399F001344} + EndGlobalSection EndGlobal diff --git a/Greenshot/Drawing/StepLabelContainer.cs b/Greenshot/Drawing/StepLabelContainer.cs index fddf5e867..317c23d0e 100644 --- a/Greenshot/Drawing/StepLabelContainer.cs +++ b/Greenshot/Drawing/StepLabelContainer.cs @@ -213,37 +213,8 @@ namespace Greenshot.Drawing { int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS); bool shadow = GetFieldValueAsBool(FieldType.SHADOW); - if (shadow) - { - const int basealpha = 100; - Rectangle dropShadowRect = rect; + EllipseContainer.DrawEllipse(rect, graphics, rm, lineThickness, lineColor, fillColor, shadow); - // Draw glow around step label - dropShadowRect.Inflate(1, 1); - EllipseContainer.DrawEllipse(dropShadowRect, graphics, rm, 0, Color.Transparent, Color.FromArgb(basealpha, 100, 100, 100), false); - - // Draw drop shadow - dropShadowRect = rect; - int steps = 4; - int alpha = basealpha; - for (int currentStep = 0; currentStep <= steps; currentStep++) - { - dropShadowRect.Offset(1, 1); - EllipseContainer.DrawEllipse(dropShadowRect, graphics, rm, 0, Color.Transparent, Color.FromArgb(alpha, 100, 100, 100), false); - alpha = alpha - basealpha / steps; - } - } - - if (_drawAsRectangle) { - RectangleContainer.DrawRectangle(rect, graphics, rm, 0, Color.Transparent, fillColor, false); - } else { - if (lineThickness > 0) - { - EllipseContainer.DrawEllipse(rect, graphics, rm, 0, Color.Transparent, lineColor, false); - rect.Inflate(lineThickness * -2, lineThickness * -2); - } - EllipseContainer.DrawEllipse(rect, graphics, rm, 0, Color.Transparent, fillColor, false); - } using (FontFamily fam = new FontFamily(FontFamily.GenericSansSerif.Name)) { using (Font font = new Font(fam, fontSize, FontStyle.Bold, GraphicsUnit.Pixel)) { TextContainer.DrawText(graphics, rect, 0, textColor, false, _stringFormat, text, font);