mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
Shape resize logic moved to BaseShape from ResizeManager
This commit is contained in:
parent
4dbaa392e6
commit
eacac76a75
4 changed files with 29 additions and 32 deletions
|
@ -116,6 +116,18 @@ public void Move(Point point)
|
|||
Move(point.X, point.Y);
|
||||
}
|
||||
|
||||
public virtual void Resize(int x, int y, bool fromBottomRight)
|
||||
{
|
||||
if (fromBottomRight)
|
||||
{
|
||||
Rectangle = Rectangle.SizeOffset(x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
Rectangle = Rectangle.LocationOffset(x, y).SizeOffset(-x, -y);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnCreated()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -67,5 +67,17 @@ public override void Move(int x, int y)
|
|||
StartPosition = StartPosition.Add(x, y);
|
||||
EndPosition = EndPosition.Add(x, y);
|
||||
}
|
||||
|
||||
public override void Resize(int x, int y, bool fromBottomRight)
|
||||
{
|
||||
if (fromBottomRight)
|
||||
{
|
||||
StartPosition = StartPosition.Add(x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
EndPosition = EndPosition.Add(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -117,5 +117,9 @@ public override void OnShapePathRequested(GraphicsPath gp, Rectangle rect)
|
|||
{
|
||||
gp.AddEllipse(rect);
|
||||
}
|
||||
|
||||
public override void Resize(int x, int y, bool fromBottomRight)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -231,7 +231,7 @@ private void form_KeyDown(object sender, KeyEventArgs e)
|
|||
}
|
||||
else
|
||||
{
|
||||
ResizeCurrentArea(x, y, IsBottomRightResizing);
|
||||
shape.Resize(x, y, IsBottomRightResizing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -313,36 +313,5 @@ private void UpdateNodePositions()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ResizeCurrentArea(int x, int y, bool isBottomRightMoving)
|
||||
{
|
||||
BaseShape shape = shapeManager.CurrentShape;
|
||||
|
||||
if (shape != null)
|
||||
{
|
||||
if (shape.NodeType == NodeType.Rectangle)
|
||||
{
|
||||
if (isBottomRightMoving)
|
||||
{
|
||||
shape.Rectangle = shape.Rectangle.SizeOffset(x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
shape.Rectangle = shape.Rectangle.LocationOffset(x, y).SizeOffset(-x, -y);
|
||||
}
|
||||
}
|
||||
else if (shape.NodeType == NodeType.Line)
|
||||
{
|
||||
if (isBottomRightMoving)
|
||||
{
|
||||
shape.StartPosition = shape.StartPosition.Add(x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
shape.EndPosition = shape.EndPosition.Add(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue