diff --git a/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs b/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs index 1150737fd..7783447b7 100644 --- a/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs +++ b/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs @@ -208,13 +208,13 @@ protected override void Draw(Graphics g) // Draw effect shapes foreach (BaseEffectShape effectShape in ShapeManager.EffectShapes) { - effectShape.Draw(g); + effectShape.OnDraw(g); } // Draw drawing shapes foreach (BaseDrawingShape drawingShape in ShapeManager.DrawingShapes) { - drawingShape.Draw(g); + drawingShape.OnDraw(g); } // Draw animated rectangle on hover area diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/ArrowDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/ArrowDrawingShape.cs index a2d389e2e..b5de4c71a 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/ArrowDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/ArrowDrawingShape.cs @@ -32,15 +32,27 @@ namespace ShareX.ScreenCaptureLib { - public class ArrowDrawingShape : LineDrawingShape + public class ArrowDrawingShape : BaseDrawingShape { public override ShapeType ShapeType { get; } = ShapeType.DrawingArrow; + public override NodeType NodeType { get; } = NodeType.Line; - public override Pen CreatePen() + public override void OnDraw(Graphics g) { - Pen pen = base.CreatePen(); - pen.CustomEndCap = new AdjustableArrowCap(4, 6); - return pen; + if (BorderSize > 0 && BorderColor.A > 0) + { + g.SmoothingMode = SmoothingMode.HighQuality; + + using (Pen pen = new Pen(BorderColor, BorderSize)) + using (AdjustableArrowCap arrowCap = new AdjustableArrowCap(4, 6)) + { + pen.CustomEndCap = arrowCap; + + g.DrawLine(pen, StartPosition, EndPosition); + } + + g.SmoothingMode = SmoothingMode.None; + } } } } \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/BaseDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/BaseDrawingShape.cs index 6ff17d41b..2cbf45890 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/BaseDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/BaseDrawingShape.cs @@ -53,21 +53,6 @@ public override void ApplyShapeConfig() AnnotationOptions.FillColor = FillColor; } - public virtual void Draw(Graphics g) - { - using (Pen borderPen = new Pen(Color.Black)) - using (Pen borderDotPen = new Pen(Color.White)) - { - borderDotPen.DashPattern = new float[] { 2, 2 }; - - g.DrawRectangleProper(borderPen, Rectangle); - g.DrawRectangleProper(borderDotPen, Rectangle); - } - } - - public virtual void DrawFinal(Graphics g, Bitmap bmp) - { - Draw(g); - } + public abstract void OnDraw(Graphics g); } } \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/EllipseDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/EllipseDrawingShape.cs index 1b00e56a8..53a630a73 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/EllipseDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/EllipseDrawingShape.cs @@ -38,7 +38,7 @@ public class EllipseDrawingShape : BaseDrawingShape { public override ShapeType ShapeType { get; } = ShapeType.DrawingEllipse; - public override void Draw(Graphics g) + public override void OnDraw(Graphics g) { g.SmoothingMode = SmoothingMode.HighQuality; diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/LineDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/LineDrawingShape.cs index 26cc56c1e..bfc748921 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/LineDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/LineDrawingShape.cs @@ -37,13 +37,13 @@ public class LineDrawingShape : BaseDrawingShape public override ShapeType ShapeType { get; } = ShapeType.DrawingLine; public override NodeType NodeType { get; } = NodeType.Line; - public override void Draw(Graphics g) + public override void OnDraw(Graphics g) { if (BorderSize > 0 && BorderColor.A > 0) { g.SmoothingMode = SmoothingMode.HighQuality; - using (Pen pen = CreatePen()) + using (Pen pen = new Pen(BorderColor, BorderSize)) { g.DrawLine(pen, StartPosition, EndPosition); } @@ -51,10 +51,5 @@ public override void Draw(Graphics g) g.SmoothingMode = SmoothingMode.None; } } - - public virtual Pen CreatePen() - { - return new Pen(BorderColor, BorderSize); - } } } \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/RectangleDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/RectangleDrawingShape.cs index 45e367aff..de787a8bb 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/RectangleDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/RectangleDrawingShape.cs @@ -38,7 +38,7 @@ public class RectangleDrawingShape : BaseDrawingShape { public override ShapeType ShapeType { get; } = ShapeType.DrawingRectangle; - public override void Draw(Graphics g) + public override void OnDraw(Graphics g) { if (FillColor.A > 0) { diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/RoundedRectangleDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/RoundedRectangleDrawingShape.cs index f1f469efb..528a3876c 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/RoundedRectangleDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/RoundedRectangleDrawingShape.cs @@ -51,7 +51,7 @@ public override void ApplyShapeConfig() AnnotationOptions.RoundedRectangleRadius = (int)Radius; } - public override void Draw(Graphics g) + public override void OnDraw(Graphics g) { Brush brush = null; Pen pen = null; diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/TextDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/TextDrawingShape.cs index 5f6e60063..54d8d65be 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/TextDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/TextDrawingShape.cs @@ -58,14 +58,7 @@ public override void ApplyShapeConfig() AnnotationOptions.TextFillColor = FillColor; } - public override void Draw(Graphics g) - { - base.Draw(g); - - DrawFinal(g, null); - } - - public override void DrawFinal(Graphics g, Bitmap bmp) + public override void OnDraw(Graphics g) { if (FillColor.A > 0) { @@ -96,6 +89,16 @@ public override void DrawFinal(Graphics g, Bitmap bmp) } } + public override void OnShapeCreated() + { + UpdateText(); + } + + public override void OnShapeDoubleClicked() + { + UpdateText(); + } + private void UpdateText() { Manager.PauseForm(); @@ -109,15 +112,5 @@ private void UpdateText() Manager.ResumeForm(); } - - public override void OnShapeCreated() - { - UpdateText(); - } - - public override void OnShapeDoubleClicked() - { - UpdateText(); - } } } \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Shapes/Effect/BaseEffectShape.cs b/ShareX.ScreenCaptureLib/Shapes/Effect/BaseEffectShape.cs index 7fa8a45c6..52a81a0c7 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Effect/BaseEffectShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Effect/BaseEffectShape.cs @@ -33,11 +33,11 @@ namespace ShareX.ScreenCaptureLib { public abstract class BaseEffectShape : BaseShape { - public abstract void Draw(Graphics g); + public abstract void OnDraw(Graphics g); - public virtual void DrawFinal(Graphics g, Bitmap bmp) + public virtual void OnDrawFinal(Graphics g, Bitmap bmp) { - Draw(g); + OnDraw(g); } } } \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Shapes/Effect/BlurEffectShape.cs b/ShareX.ScreenCaptureLib/Shapes/Effect/BlurEffectShape.cs index cf3d1c836..87cbc4d9b 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Effect/BlurEffectShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Effect/BlurEffectShape.cs @@ -50,7 +50,7 @@ public override void ApplyShapeConfig() AnnotationOptions.BlurRadius = BlurRadius; } - public override void Draw(Graphics g) + public override void OnDraw(Graphics g) { if (BlurRadius > 1) { @@ -77,7 +77,7 @@ public override void Draw(Graphics g) } } - public override void DrawFinal(Graphics g, Bitmap bmp) + public override void OnDrawFinal(Graphics g, Bitmap bmp) { if (BlurRadius > 1) { diff --git a/ShareX.ScreenCaptureLib/Shapes/Effect/HighlightEffectShape.cs b/ShareX.ScreenCaptureLib/Shapes/Effect/HighlightEffectShape.cs index 44a2e3b10..5584e24d2 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Effect/HighlightEffectShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Effect/HighlightEffectShape.cs @@ -50,7 +50,7 @@ public override void ApplyShapeConfig() AnnotationOptions.HighlightColor = HighlightColor; } - public override void Draw(Graphics g) + public override void OnDraw(Graphics g) { using (Brush brush = new SolidBrush(Color.FromArgb(100, HighlightColor))) { @@ -74,7 +74,7 @@ public override void Draw(Graphics g) } } - public override void DrawFinal(Graphics g, Bitmap bmp) + public override void OnDrawFinal(Graphics g, Bitmap bmp) { using (Bitmap croppedImage = ImageHelpers.CropBitmap(bmp, Rectangle)) { diff --git a/ShareX.ScreenCaptureLib/Shapes/Effect/PixelateEffectShape.cs b/ShareX.ScreenCaptureLib/Shapes/Effect/PixelateEffectShape.cs index 14ce35ea5..84dc20ed2 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Effect/PixelateEffectShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Effect/PixelateEffectShape.cs @@ -50,7 +50,7 @@ public override void ApplyShapeConfig() AnnotationOptions.PixelateSize = PixelSize; } - public override void Draw(Graphics g) + public override void OnDraw(Graphics g) { if (PixelSize > 1) { @@ -77,7 +77,7 @@ public override void Draw(Graphics g) } } - public override void DrawFinal(Graphics g, Bitmap bmp) + public override void OnDrawFinal(Graphics g, Bitmap bmp) { if (PixelSize > 1) { diff --git a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs index e8bf34f8d..c3b4f8b17 100644 --- a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs +++ b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs @@ -1159,7 +1159,7 @@ public Image RenderOutputImage(Image img) { if (shape != null) { - shape.DrawFinal(g, bmp); + shape.OnDrawFinal(g, bmp); } } @@ -1167,7 +1167,7 @@ public Image RenderOutputImage(Image img) { if (shape != null) { - shape.DrawFinal(g, bmp); + shape.OnDraw(g); } } }