diff --git a/ShareX.HelpersLib/Helpers/CaptureHelpers.cs b/ShareX.HelpersLib/Helpers/CaptureHelpers.cs index 71cb6e7f1..e0cc365b3 100644 --- a/ShareX.HelpersLib/Helpers/CaptureHelpers.cs +++ b/ShareX.HelpersLib/Helpers/CaptureHelpers.cs @@ -221,28 +221,6 @@ public static Rectangle CreateRectangle(Point pos, Point pos2) return CreateRectangle(pos.X, pos.Y, pos2.X, pos2.Y); } - public static Rectangle FixRectangle(int x, int y, int width, int height) - { - if (width < 0) - { - x += width; - width = -width; - } - - if (height < 0) - { - y += height; - height = -height; - } - - return new Rectangle(x, y, width, height); - } - - public static Rectangle FixRectangle(Rectangle rect) - { - return FixRectangle(rect.X, rect.Y, rect.Width, rect.Height); - } - public static Point ProportionalPosition(Point pos, Point pos2) { Point newPosition = Point.Empty; diff --git a/ShareX.ScreenCaptureLib/Shapes/BaseShape.cs b/ShareX.ScreenCaptureLib/Shapes/BaseShape.cs index c7e33b483..25afc4c4e 100644 --- a/ShareX.ScreenCaptureLib/Shapes/BaseShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/BaseShape.cs @@ -80,7 +80,7 @@ public Point EndPosition internal ShapeManager Manager { get; set; } - private Rectangle tempNodeRect; + private Point tempNodePos, tempStartPos, tempEndPos; public virtual bool Intersects(Point position) { @@ -195,52 +195,58 @@ public virtual void OnNodeUpdate() { for (int i = 0; i < 8; i++) { - if (Manager.Nodes[i].IsDragging) + NodeObject node = Manager.Nodes[i]; + + if (node.IsDragging) { Manager.IsResizing = true; if (!InputManager.IsBeforeMouseDown(MouseButtons.Left)) { - tempNodeRect = Rectangle; + tempNodePos = node.Position; + tempStartPos = Rectangle.Location; + tempEndPos = new Point(Rectangle.X + Rectangle.Width - 1, Rectangle.Y + Rectangle.Height - 1); } + Point pos = InputManager.MousePosition0Based; + Point startPos = tempStartPos; + Point endPos = tempEndPos; + NodePosition nodePosition = (NodePosition)i; - int x = InputManager.MouseVelocity.X; + int x = pos.X - tempNodePos.X; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Left: case NodePosition.BottomLeft: - tempNodeRect.X += x; - tempNodeRect.Width -= x; + startPos.X += x; break; case NodePosition.TopRight: case NodePosition.Right: case NodePosition.BottomRight: - tempNodeRect.Width += x; + endPos.X += x; break; } - int y = InputManager.MouseVelocity.Y; + int y = pos.Y - tempNodePos.Y; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Top: case NodePosition.TopRight: - tempNodeRect.Y += y; - tempNodeRect.Height -= y; + startPos.Y += y; break; case NodePosition.BottomLeft: case NodePosition.Bottom: case NodePosition.BottomRight: - tempNodeRect.Height += y; + endPos.Y += y; break; } - Rectangle = CaptureHelpers.FixRectangle(tempNodeRect); + Rectangle = CaptureHelpers.CreateRectangle(startPos, endPos); } } }