From a11b54dbc964ce8fc109090552c8f43a1efb94f0 Mon Sep 17 00:00:00 2001 From: Jaex Date: Sun, 12 Oct 2025 22:42:31 +0300 Subject: [PATCH] Code refactoring --- .../Shapes/Drawing/StickerDrawingShape.cs | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/StickerDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/StickerDrawingShape.cs index ff0f324ba..825578dd9 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/StickerDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/StickerDrawingShape.cs @@ -73,26 +73,33 @@ namespace ShareX.ScreenCaptureLib public override void Resize(int x, int y, bool fromBottomRight) { - // Store the current center - PointF center = new PointF(Rectangle.X + Rectangle.Width / 2, Rectangle.Y + Rectangle.Height / 2); - if (x != 0) + RotateFlipType rotateFlipType = RotateFlipType.RotateNoneFlipNone; + + if (x > 0) { - Image.RotateFlip(RotateFlipType.Rotate90FlipNone); + rotateFlipType = RotateFlipType.Rotate90FlipNone; } - if (y != 0) + else if (x < 0) { - Image.RotateFlip(RotateFlipType.RotateNoneFlipY); + rotateFlipType = RotateFlipType.Rotate270FlipNone; + } + else if (y > 0) + { + rotateFlipType = RotateFlipType.RotateNoneFlipX; + } + else if (y < 0) + { + rotateFlipType = RotateFlipType.RotateNoneFlipY; } - Bitmap flippedBmp = (Bitmap)Image.Clone(); - SetImage(flippedBmp, true); - Rectangle = new RectangleF( - center.X - flippedBmp.Width / 2, - center.Y - flippedBmp.Height / 2, - flippedBmp.Width, - flippedBmp.Height - ); - + if (rotateFlipType != RotateFlipType.RotateNoneFlipNone) + { + PointF center = new PointF(Rectangle.X + Rectangle.Width / 2, Rectangle.Y + Rectangle.Height / 2); + Bitmap flippedBmp = (Bitmap)Image.Clone(); + flippedBmp.RotateFlip(rotateFlipType); + SetImage(flippedBmp, true); + Rectangle = new RectangleF(center.X - flippedBmp.Width / 2, center.Y - flippedBmp.Height / 2, flippedBmp.Width, flippedBmp.Height); + } } private bool OpenStickerForm()