Shape resize logic moved to BaseShape from ResizeManager

This commit is contained in:
Jaex 2016-08-03 12:15:26 +03:00
parent 4dbaa392e6
commit eacac76a75
4 changed files with 29 additions and 32 deletions

View file

@ -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()
{
}

View file

@ -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);
}
}
}
}

View file

@ -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)
{
}
}
}

View file

@ -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);
}
}
}
}
}
}