Limit cut out selection highlight to canvas area

This commit is contained in:
Niels Martin Hansen 2022-08-17 17:14:33 +02:00
parent ce02e9ab07
commit 21bb827d03

View file

@ -24,6 +24,7 @@ You should have received a copy of the GNU General Public License
#endregion License Information (GPL v3) #endregion License Information (GPL v3)
using ShareX.HelpersLib; using ShareX.HelpersLib;
using System;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
@ -122,11 +123,11 @@ public override void OnDraw(Graphics g)
{ {
if (IsHorizontalTrim) if (IsHorizontalTrim)
{ {
g.FillRectangle(selectionHighlightBrush, new RectangleF(Rectangle.X, g.ClipBounds.Y, Rectangle.Width, g.ClipBounds.Height)); g.FillRectangle(selectionHighlightBrush, new RectangleF(Rectangle.X, Math.Max(g.ClipBounds.Y, Manager.Form.CanvasRectangle.Y), Rectangle.Width, Math.Min(g.ClipBounds.Height, Manager.Form.CanvasRectangle.Height)));
} }
else if (IsVerticalTrim) else if (IsVerticalTrim)
{ {
g.FillRectangle(selectionHighlightBrush, new RectangleF(g.ClipBounds.X, Rectangle.Y, g.ClipBounds.Width, Rectangle.Height)); g.FillRectangle(selectionHighlightBrush, new RectangleF(Math.Max(g.ClipBounds.X, Manager.Form.CanvasRectangle.X), Rectangle.Y, Math.Min(g.ClipBounds.Width, Manager.Form.CanvasRectangle.Width), Rectangle.Height));
} }
} }
} }