Use a checker pattern to denote area to be cut out

This commit is contained in:
Niels Martin Hansen 2022-08-17 16:42:00 +02:00
parent ae25410d83
commit f9d144400e

View file

@ -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();