Shape move logic moved to BaseShape from ResizeManager

This commit is contained in:
Jaex 2016-08-03 12:01:39 +03:00
parent b367bcb747
commit 4414ed888e
3 changed files with 21 additions and 21 deletions

View file

@ -106,6 +106,16 @@ public void AddShapePath(GraphicsPath gp, int sizeOffset = 0)
OnShapePathRequested(gp, rect);
}
public virtual void Move(int x, int y)
{
Rectangle = Rectangle.LocationOffset(x, y);
}
public void Move(Point point)
{
Move(point.X, point.Y);
}
public virtual void OnCreated()
{
}
@ -140,7 +150,7 @@ public virtual void OnUpdate()
}
else if (Manager.IsMoving)
{
Manager.ResizeManager.MoveCurrentArea(InputManager.MouseVelocity.X, InputManager.MouseVelocity.Y);
Move(InputManager.MouseVelocity);
}
}

View file

@ -61,5 +61,11 @@ protected virtual void DrawLine(Graphics g, Pen pen)
{
g.DrawLine(pen, StartPosition, EndPosition);
}
public override void Move(int x, int y)
{
StartPosition = StartPosition.Add(x, y);
EndPosition = EndPosition.Add(x, y);
}
}
}

View file

@ -217,7 +217,9 @@ private void form_KeyDown(object sender, KeyEventArgs e)
int y = isUpPressed && isDownPressed ? 0 : isDownPressed ? speed : isUpPressed ? -speed : 0;
int x = isLeftPressed && isRightPressed ? 0 : isRightPressed ? speed : isLeftPressed ? -speed : 0;
if (shapeManager.CurrentShape == null || shapeManager.IsCreating)
BaseShape shape = shapeManager.CurrentShape;
if (shape == null || shapeManager.IsCreating)
{
Cursor.Position = Cursor.Position.Add(x, y);
}
@ -225,7 +227,7 @@ private void form_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control)
{
MoveCurrentArea(x, y);
shape.Move(x, y);
}
else
{
@ -312,24 +314,6 @@ private void UpdateNodePositions()
}
}
public void MoveCurrentArea(int x, int y)
{
BaseShape shape = shapeManager.CurrentShape;
if (shape != null)
{
if (shape.NodeType == NodeType.Rectangle || shape.NodeType == NodeType.Point)
{
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);
}
}
}
public void ResizeCurrentArea(int x, int y, bool isBottomRightMoving)
{
BaseShape shape = shapeManager.CurrentShape;