mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-06 23:21:16 +12:00
Improvements to support resizing and moving two point (line, arrow) shapes
This commit is contained in:
parent
0e7ba6cbe9
commit
d1ec0b8ae6
|
@ -318,7 +318,15 @@ public void MoveCurrentArea(int x, int y)
|
||||||
|
|
||||||
if (shape != null)
|
if (shape != null)
|
||||||
{
|
{
|
||||||
shape.Rectangle = shape.Rectangle.LocationOffset(x, y);
|
if (shape.NodeType == NodeType.Rectangle)
|
||||||
|
{
|
||||||
|
shape.Rectangle = shape.Rectangle.LocationOffset(x, y);
|
||||||
|
}
|
||||||
|
else if (shape.NodeType == NodeType.Line)
|
||||||
|
{
|
||||||
|
shape.StartPosition = shape.StartPosition.Add(x, y);
|
||||||
|
shape.EndPosition = shape.EndPosition.Add(x, y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,13 +336,27 @@ public void ResizeCurrentArea(int x, int y, bool isBottomRightMoving)
|
||||||
|
|
||||||
if (shape != null)
|
if (shape != null)
|
||||||
{
|
{
|
||||||
if (isBottomRightMoving)
|
if (shape.NodeType == NodeType.Rectangle)
|
||||||
{
|
{
|
||||||
shape.Rectangle = shape.Rectangle.SizeOffset(x, y);
|
if (isBottomRightMoving)
|
||||||
|
{
|
||||||
|
shape.Rectangle = shape.Rectangle.SizeOffset(x, y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shape.Rectangle = shape.Rectangle.LocationOffset(x, y).SizeOffset(-x, -y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (shape.NodeType == NodeType.Line)
|
||||||
{
|
{
|
||||||
shape.Rectangle = shape.Rectangle.LocationOffset(x, y).SizeOffset(-x, -y);
|
if (isBottomRightMoving)
|
||||||
|
{
|
||||||
|
shape.StartPosition = shape.StartPosition.Add(x, y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shape.EndPosition = shape.EndPosition.Add(x, y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -589,17 +589,15 @@ private void surface_KeyUp(object sender, KeyEventArgs e)
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if (CurrentShape != null)
|
BaseShape shape = CurrentShape;
|
||||||
|
|
||||||
|
if (shape != null)
|
||||||
{
|
{
|
||||||
if (IsMoving)
|
if (IsMoving)
|
||||||
{
|
{
|
||||||
Rectangle rect = CurrentRectangle;
|
ResizeManager.MoveCurrentArea(InputManager.MouseVelocity.X, InputManager.MouseVelocity.Y);
|
||||||
rect.X += InputManager.MouseVelocity.X;
|
|
||||||
rect.Y += InputManager.MouseVelocity.Y;
|
|
||||||
CurrentShape.Rectangle = rect;
|
|
||||||
}
|
}
|
||||||
|
else if (IsCreating && !CurrentRectangle.IsEmpty)
|
||||||
if (IsCreating && !CurrentRectangle.IsEmpty)
|
|
||||||
{
|
{
|
||||||
CurrentPosition = InputManager.MousePosition0Based;
|
CurrentPosition = InputManager.MousePosition0Based;
|
||||||
|
|
||||||
|
@ -615,7 +613,7 @@ public void Update()
|
||||||
newPosition = SnapPosition(PositionOnClick, newPosition);
|
newPosition = SnapPosition(PositionOnClick, newPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentShape.EndPosition = newPosition;
|
shape.EndPosition = newPosition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue