From f9d144400eb4be222e32b5def6bd28ea8213d1fe Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Wed, 17 Aug 2022 16:42:00 +0200 Subject: [PATCH] Use a checker pattern to denote area to be cut out --- .../Shapes/Tool/CutOutTool.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ShareX.ScreenCaptureLib/Shapes/Tool/CutOutTool.cs b/ShareX.ScreenCaptureLib/Shapes/Tool/CutOutTool.cs index 7ff65feb1..f2f8927ea 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Tool/CutOutTool.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Tool/CutOutTool.cs @@ -44,8 +44,6 @@ public class CutOutTool : BaseTool private Size buttonSize = new Size(80, 40); private int buttonOffset = 15; - private Brush selectionHighlightBrush = new SolidBrush(Color.FromArgb(128, Color.Gray)); - public override void OnUpdate() { base.OnUpdate(); @@ -107,13 +105,17 @@ public override void OnUpdate() public override void OnDraw(Graphics g) { - if (IsHorizontalTrim) + using (Image selectionHighlightPattern = ImageHelpers.CreateCheckerPattern(8, 8, Color.FromArgb(128, Color.White), Color.FromArgb(128, Color.Gray))) + using (Brush selectionHighlightBrush = new TextureBrush(selectionHighlightPattern, System.Drawing.Drawing2D.WrapMode.Tile)) { - g.FillRectangle(selectionHighlightBrush, new RectangleF(Rectangle.X, g.ClipBounds.Y, Rectangle.Width, g.ClipBounds.Height)); - } - else if (IsVerticalTrim) - { - g.FillRectangle(selectionHighlightBrush, new RectangleF(g.ClipBounds.X, Rectangle.Y, g.ClipBounds.Width, Rectangle.Height)); + if (IsHorizontalTrim) + { + g.FillRectangle(selectionHighlightBrush, new RectangleF(Rectangle.X, g.ClipBounds.Y, Rectangle.Width, g.ClipBounds.Height)); + } + else if (IsVerticalTrim) + { + g.FillRectangle(selectionHighlightBrush, new RectangleF(g.ClipBounds.X, Rectangle.Y, g.ClipBounds.Width, Rectangle.Height)); + } } } @@ -169,8 +171,6 @@ public override void Dispose() { base.Dispose(); - selectionHighlightBrush.Dispose(); - if ((confirmButton != null && confirmButton.IsCursorHover) || (cancelButton != null && cancelButton.IsCursorHover)) { Manager.Form.SetDefaultCursor();