From e3a419c8b8f720d582f805900f0d180a2e400921 Mon Sep 17 00:00:00 2001 From: Jaex Date: Mon, 22 Jul 2019 03:17:18 +0300 Subject: [PATCH] Store minimum size in options --- ShareX.ScreenCaptureLib/RegionCaptureOptions.cs | 2 ++ ShareX.ScreenCaptureLib/Shapes/BaseShape.cs | 4 +--- .../Shapes/Drawing/LineDrawingShape.cs | 2 +- ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs | 15 +++++++-------- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/ShareX.ScreenCaptureLib/RegionCaptureOptions.cs b/ShareX.ScreenCaptureLib/RegionCaptureOptions.cs index fc00b8b71..f1f7a822e 100644 --- a/ShareX.ScreenCaptureLib/RegionCaptureOptions.cs +++ b/ShareX.ScreenCaptureLib/RegionCaptureOptions.cs @@ -32,6 +32,7 @@ namespace ShareX.ScreenCaptureLib { public class RegionCaptureOptions { + public const int DefaultMinimumSize = 5; public const int MagnifierPixelCountMinimum = 3; public const int MagnifierPixelCountMaximum = 35; public const int MagnifierPixelSizeMinimum = 3; @@ -41,6 +42,7 @@ public class RegionCaptureOptions public const int MoveSpeedMaximum = 10; public bool QuickCrop = true; + public int MinimumSize = DefaultMinimumSize; public RegionCaptureAction RegionCaptureActionRightClick = RegionCaptureAction.RemoveShapeCancelCapture; public RegionCaptureAction RegionCaptureActionMiddleClick = RegionCaptureAction.SwapToolType; public RegionCaptureAction RegionCaptureActionX1Click = RegionCaptureAction.CaptureFullscreen; diff --git a/ShareX.ScreenCaptureLib/Shapes/BaseShape.cs b/ShareX.ScreenCaptureLib/Shapes/BaseShape.cs index 4b99cbf19..918f42e04 100644 --- a/ShareX.ScreenCaptureLib/Shapes/BaseShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/BaseShape.cs @@ -33,8 +33,6 @@ namespace ShareX.ScreenCaptureLib { public abstract class BaseShape : IDisposable { - protected const int MinimumSize = 3; - public abstract ShapeCategory ShapeCategory { get; } public abstract ShapeType ShapeType { get; } @@ -93,7 +91,7 @@ private set public Size InitialSize { get; set; } - public virtual bool IsValidShape => !Rectangle.IsEmpty && Rectangle.Width >= MinimumSize && Rectangle.Height >= MinimumSize; + public virtual bool IsValidShape => !Rectangle.IsEmpty && Rectangle.Width >= Options.MinimumSize && Rectangle.Height >= Options.MinimumSize; public virtual bool IsSelectable => Manager.CurrentTool == ShapeType || Manager.CurrentTool == ShapeType.ToolSelect; diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/LineDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/LineDrawingShape.cs index 2dcd9b48a..9de4bcd94 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/LineDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/LineDrawingShape.cs @@ -40,7 +40,7 @@ public class LineDrawingShape : BaseDrawingShape public bool CenterNodeActive { get; private set; } public int CenterPointCount { get; private set; } - public override bool IsValidShape => Rectangle.Width > 1 || Rectangle.Height > 1; + public override bool IsValidShape => Rectangle.Width >= Options.MinimumSize || Rectangle.Height >= Options.MinimumSize; protected override void UseLightResizeNodes() { diff --git a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs index ccebcee87..f70b1228c 100644 --- a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs +++ b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs @@ -1179,10 +1179,10 @@ private BaseShape CheckHover() { Point location = InputManager.ClientMousePosition; - return new RectangleRegionShape() - { - Rectangle = new Rectangle(new Point(location.X - (Options.FixedSize.Width / 2), location.Y - (Options.FixedSize.Height / 2)), Options.FixedSize) - }; + BaseShape rectangleRegionShape = CreateShape(ShapeType.RegionRectangle); + rectangleRegionShape.Rectangle = new Rectangle(new Point(location.X - (Options.FixedSize.Width / 2), + location.Y - (Options.FixedSize.Height / 2)), Options.FixedSize); + return rectangleRegionShape; } else { @@ -1192,10 +1192,9 @@ private BaseShape CheckHover() { Rectangle hoverArea = CaptureHelpers.ScreenToClient(window.Rectangle); - return new RectangleRegionShape() - { - Rectangle = Rectangle.Intersect(Form.ClientArea, hoverArea) - }; + BaseShape rectangleRegionShape = CreateShape(ShapeType.RegionRectangle); + rectangleRegionShape.Rectangle = Rectangle.Intersect(Form.ClientArea, hoverArea); + return rectangleRegionShape; } } }