diff --git a/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs b/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs
index fa9261156..1150737fd 100644
--- a/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs
+++ b/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs
@@ -222,7 +222,7 @@ protected override void Draw(Graphics g)
{
using (GraphicsPath hoverDrawPath = new GraphicsPath { FillMode = FillMode.Winding })
{
- ShapeManager.CreateRegionShape(ShapeManager.CurrentHoverRectangle).AddShapePath(hoverDrawPath, -1);
+ ShapeManager.CreateShape(ShapeManager.CurrentHoverRectangle).AddShapePath(hoverDrawPath, -1);
g.DrawPath(borderPen, hoverDrawPath);
g.DrawPath(borderDotPen, hoverDrawPath);
@@ -253,7 +253,7 @@ protected override void Draw(Graphics g)
// Add hover area to list so rectangle info can be shown
if (ShapeManager.IsCurrentShapeTypeRegion && ShapeManager.IsCurrentHoverAreaValid && areas.All(area => area.Rectangle != ShapeManager.CurrentHoverRectangle))
{
- BaseShape shape = ShapeManager.CreateRegionShape(ShapeManager.CurrentHoverRectangle);
+ BaseShape shape = ShapeManager.CreateShape(ShapeManager.CurrentHoverRectangle);
areas.Add(shape);
}
diff --git a/ShareX.ScreenCaptureLib/RegionHelpers/ShapeManager.cs b/ShareX.ScreenCaptureLib/RegionHelpers/ShapeManager.cs
index 243da7f9e..c016144fc 100644
--- a/ShareX.ScreenCaptureLib/RegionHelpers/ShapeManager.cs
+++ b/ShareX.ScreenCaptureLib/RegionHelpers/ShapeManager.cs
@@ -875,7 +875,7 @@ private void RegionSelection(Point location)
rect = new Rectangle(location, new Size(1, 1));
}
- AddRegionShape(rect);
+ AddShape(rect);
CurrentShape.StartPosition = PositionOnClick;
}
@@ -917,7 +917,7 @@ private void EndRegionSelection()
if (!CurrentHoverRectangle.IsEmpty)
{
- AddRegionShape(CurrentHoverRectangle);
+ AddShape(CurrentHoverRectangle);
if (Config.QuickCrop && IsCurrentShapeTypeRegion)
{
@@ -936,14 +936,14 @@ private void EndRegionSelection()
}
}
- private void AddRegionShape(Rectangle rect)
+ private void AddShape(Rectangle rect)
{
- BaseShape shape = CreateRegionShape(rect);
+ BaseShape shape = CreateShape(rect);
Shapes.Add(shape);
CurrentShape = shape;
}
- public BaseShape CreateRegionShape(Rectangle rect)
+ public BaseShape CreateShape(Rectangle rect)
{
BaseShape shape;
@@ -991,54 +991,14 @@ public BaseShape CreateRegionShape(Rectangle rect)
shape.Manager = this;
shape.Rectangle = rect;
- UpdateShape(shape);
+ shape.UpdateShapeConfig();
return shape;
}
private void UpdateCurrentShape()
{
- UpdateShape(CurrentShape);
- }
-
- private void UpdateShape(BaseShape shape)
- {
- if (shape != null)
- {
- if (shape is BaseDrawingShape)
- {
- BaseDrawingShape baseDrawingShape = (BaseDrawingShape)shape;
- baseDrawingShape.BorderColor = Config.ShapeBorderColor;
- baseDrawingShape.BorderSize = Config.ShapeBorderSize;
- baseDrawingShape.FillColor = Config.ShapeFillColor;
- }
-
- if (shape is IRoundedRectangleShape)
- {
- IRoundedRectangleShape roundedRectangleShape = (IRoundedRectangleShape)shape;
- roundedRectangleShape.Radius = Config.ShapeRoundedRectangleRadius;
- }
- else if (shape is TextDrawingShape)
- {
- TextDrawingShape textDrawingShape = (TextDrawingShape)shape;
- textDrawingShape.Options = Config.ShapeTextOptions.Copy();
- }
- else if (shape is BlurEffectShape)
- {
- BlurEffectShape blurEffectShape = (BlurEffectShape)shape;
- blurEffectShape.BlurRadius = Config.ShapeBlurRadius;
- }
- else if (shape is PixelateEffectShape)
- {
- PixelateEffectShape pixelateEffectShape = (PixelateEffectShape)shape;
- pixelateEffectShape.PixelSize = Config.ShapePixelateSize;
- }
- else if (shape is HighlightEffectShape)
- {
- HighlightEffectShape highlightEffectShape = (HighlightEffectShape)shape;
- highlightEffectShape.HighlightColor = Config.ShapeHighlightColor;
- }
- }
+ CurrentShape.UpdateShapeConfig();
}
public Image RenderOutputImage(Image img)
diff --git a/ShareX.ScreenCaptureLib/Shapes/BaseShape.cs b/ShareX.ScreenCaptureLib/Shapes/BaseShape.cs
index 81a1b24cf..b46f4ebd8 100644
--- a/ShareX.ScreenCaptureLib/Shapes/BaseShape.cs
+++ b/ShareX.ScreenCaptureLib/Shapes/BaseShape.cs
@@ -39,6 +39,14 @@ public abstract class BaseShape
public ShapeManager Manager { get; set; }
+ protected SurfaceOptions Config
+ {
+ get
+ {
+ return Manager.Config;
+ }
+ }
+
private Point startPosition;
public Point StartPosition
@@ -87,6 +95,10 @@ public void AddShapePath(GraphicsPath gp, int sizeOffset)
AddShapePath(gp, rect);
}
+ public virtual void UpdateShapeConfig()
+ {
+ }
+
public virtual void OnShapeCreated()
{
}
diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/BaseDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/BaseDrawingShape.cs
index 08524d339..9f4d53aee 100644
--- a/ShareX.ScreenCaptureLib/Shapes/Drawing/BaseDrawingShape.cs
+++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/BaseDrawingShape.cs
@@ -39,6 +39,13 @@ public abstract class BaseDrawingShape : BaseShape
public Color FillColor { get; set; }
public int BorderSize { get; set; }
+ public override void UpdateShapeConfig()
+ {
+ BorderColor = Config.ShapeBorderColor;
+ BorderSize = Config.ShapeBorderSize;
+ FillColor = Config.ShapeFillColor;
+ }
+
public virtual void Draw(Graphics g)
{
using (Pen borderPen = new Pen(Color.Black))
diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/RoundedRectangleDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/RoundedRectangleDrawingShape.cs
index e43d98af5..0d2cd1056 100644
--- a/ShareX.ScreenCaptureLib/Shapes/Drawing/RoundedRectangleDrawingShape.cs
+++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/RoundedRectangleDrawingShape.cs
@@ -33,12 +33,17 @@
namespace ShareX.ScreenCaptureLib
{
- public class RoundedRectangleDrawingShape : BaseDrawingShape, IRoundedRectangleShape
+ public class RoundedRectangleDrawingShape : BaseDrawingShape
{
public override ShapeType ShapeType { get; } = ShapeType.DrawingRoundedRectangle;
public float Radius { get; set; }
+ public override void UpdateShapeConfig()
+ {
+ Radius = Config.ShapeRoundedRectangleRadius;
+ }
+
public override void Draw(Graphics g)
{
Brush brush = null;
diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/TextDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/TextDrawingShape.cs
index c52e6224a..2e86ba92f 100644
--- a/ShareX.ScreenCaptureLib/Shapes/Drawing/TextDrawingShape.cs
+++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/TextDrawingShape.cs
@@ -42,14 +42,16 @@ public class TextDrawingShape : BaseDrawingShape
public string Text { get; set; }
public TextDrawingOptions Options { get; set; } = new TextDrawingOptions();
+ public override void UpdateShapeConfig()
+ {
+ Options = Config.ShapeTextOptions.Copy();
+ }
+
public override void Draw(Graphics g)
{
base.Draw(g);
- if (!string.IsNullOrEmpty(Text))
- {
- DrawText(g);
- }
+ DrawFinal(g, null);
}
public override void DrawFinal(Graphics g, Bitmap bmp)
@@ -80,7 +82,7 @@ private void UpdateText()
{
inputBox.ShowDialog();
Text = inputBox.InputText;
- Manager.Config.ShapeTextOptions = Options;
+ Config.ShapeTextOptions = Options;
}
Manager.ResumeForm();
diff --git a/ShareX.ScreenCaptureLib/Shapes/Effect/BlurEffectShape.cs b/ShareX.ScreenCaptureLib/Shapes/Effect/BlurEffectShape.cs
index 3847c1873..ed5a7bb12 100644
--- a/ShareX.ScreenCaptureLib/Shapes/Effect/BlurEffectShape.cs
+++ b/ShareX.ScreenCaptureLib/Shapes/Effect/BlurEffectShape.cs
@@ -40,6 +40,11 @@ public class BlurEffectShape : BaseEffectShape
public int BlurRadius { get; set; }
+ public override void UpdateShapeConfig()
+ {
+ BlurRadius = Config.ShapeBlurRadius;
+ }
+
public override void Draw(Graphics g)
{
if (BlurRadius > 1)
diff --git a/ShareX.ScreenCaptureLib/Shapes/Effect/HighlightEffectShape.cs b/ShareX.ScreenCaptureLib/Shapes/Effect/HighlightEffectShape.cs
index c4b2ee191..bbda4d95d 100644
--- a/ShareX.ScreenCaptureLib/Shapes/Effect/HighlightEffectShape.cs
+++ b/ShareX.ScreenCaptureLib/Shapes/Effect/HighlightEffectShape.cs
@@ -40,6 +40,11 @@ public class HighlightEffectShape : BaseEffectShape
public Color HighlightColor { get; set; }
+ public override void UpdateShapeConfig()
+ {
+ HighlightColor = Config.ShapeHighlightColor;
+ }
+
public override void Draw(Graphics g)
{
using (Brush brush = new SolidBrush(Color.FromArgb(100, HighlightColor)))
diff --git a/ShareX.ScreenCaptureLib/Shapes/Effect/PixelateEffectShape.cs b/ShareX.ScreenCaptureLib/Shapes/Effect/PixelateEffectShape.cs
index 684075c80..f7952ed63 100644
--- a/ShareX.ScreenCaptureLib/Shapes/Effect/PixelateEffectShape.cs
+++ b/ShareX.ScreenCaptureLib/Shapes/Effect/PixelateEffectShape.cs
@@ -40,6 +40,11 @@ public class PixelateEffectShape : BaseEffectShape
public int PixelSize { get; set; }
+ public override void UpdateShapeConfig()
+ {
+ PixelSize = Config.ShapePixelateSize;
+ }
+
public override void Draw(Graphics g)
{
if (PixelSize > 1)
diff --git a/ShareX.ScreenCaptureLib/Shapes/IRoundedRectangleShape.cs b/ShareX.ScreenCaptureLib/Shapes/IRoundedRectangleShape.cs
deleted file mode 100644
index ee3b485bf..000000000
--- a/ShareX.ScreenCaptureLib/Shapes/IRoundedRectangleShape.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-#region License Information (GPL v3)
-
-/*
- ShareX - A program that allows you to take screenshots and share any file type
- Copyright (c) 2007-2016 ShareX Team
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- Optionally you can also view the license at .
-*/
-
-#endregion License Information (GPL v3)
-
-namespace ShareX.ScreenCaptureLib
-{
- public interface IRoundedRectangleShape
- {
- float Radius { get; set; }
- }
-}
\ No newline at end of file
diff --git a/ShareX.ScreenCaptureLib/Shapes/Region/RoundedRectangleRegionShape.cs b/ShareX.ScreenCaptureLib/Shapes/Region/RoundedRectangleRegionShape.cs
index fe6d144be..064ca606a 100644
--- a/ShareX.ScreenCaptureLib/Shapes/Region/RoundedRectangleRegionShape.cs
+++ b/ShareX.ScreenCaptureLib/Shapes/Region/RoundedRectangleRegionShape.cs
@@ -33,12 +33,17 @@
namespace ShareX.ScreenCaptureLib
{
- public class RoundedRectangleRegionShape : BaseRegionShape, IRoundedRectangleShape
+ public class RoundedRectangleRegionShape : BaseRegionShape
{
public override ShapeType ShapeType { get; } = ShapeType.RegionRoundedRectangle;
public float Radius { get; set; }
+ public override void UpdateShapeConfig()
+ {
+ Radius = Config.ShapeRoundedRectangleRadius;
+ }
+
public override void AddShapePath(GraphicsPath gp, Rectangle rect)
{
gp.AddRoundedRectangle(rect, Radius);
diff --git a/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj b/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj
index 3d7d1311c..f8a6f9e1a 100644
--- a/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj
+++ b/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj
@@ -101,7 +101,6 @@
-