From 68b62f7bde82c575d00cc68367afc4b070c5f9b2 Mon Sep 17 00:00:00 2001 From: Jaex Date: Sat, 18 Nov 2017 19:09:10 +0300 Subject: [PATCH] When canvas modified update effect cache --- .../Shapes/ShapeManager.cs | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs index 2e6cc1766..084da49d9 100644 --- a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs +++ b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs @@ -1344,6 +1344,18 @@ public void DrawRegionArea(Graphics g, Rectangle rect, bool isAnimated) Form.DrawRegionArea(g, rect, isAnimated); } + private void UpdateCanvas(Image img) + { + Form.InitBackground(img); + + foreach (BaseEffectShape effect in EffectShapes) + { + effect.OnMoved(); + } + + isAnnotated = true; + } + public void CropArea(Rectangle rect) { Image img = CropImage(rect, true); @@ -1351,8 +1363,7 @@ public void CropArea(Rectangle rect) if (img != null) { MoveAll(Form.CanvasRectangle.X - rect.X, Form.CanvasRectangle.Y - rect.Y); - Form.InitBackground(img); - isAnnotated = true; + UpdateCanvas(img); } } @@ -1391,8 +1402,7 @@ private void ChangeImageSize() if (img != null) { - Form.InitBackground(img); - isAnnotated = true; + UpdateCanvas(img); } } } @@ -1411,8 +1421,7 @@ private void ChangeCanvasSize() if (img != null) { MoveAll(canvas.Left, canvas.Top); - Form.InitBackground(img); - isAnnotated = true; + UpdateCanvas(img); } } } @@ -1420,10 +1429,9 @@ private void ChangeCanvasSize() private void RotateImage(RotateFlipType type) { - Image clone = (Image)Form.Canvas.Clone(); - clone.RotateFlip(type); - Form.InitBackground(clone); - isAnnotated = true; + Image img = (Image)Form.Canvas.Clone(); + img.RotateFlip(type); + UpdateCanvas(img); } private void OnCurrentShapeChanged(BaseShape shape)