Fix shape moving twice when moving and panning at the same time

Fix resizing while panning.
This commit is contained in:
L1Q 2017-11-07 08:24:04 +02:00
parent 13a3dc14fb
commit ec030b1fc2
6 changed files with 26 additions and 9 deletions

View file

@ -112,7 +112,8 @@ public void AddShapePath(GraphicsPath gp, int sizeOffset = 0)
public virtual void Move(int x, int y)
{
Rectangle = Rectangle.LocationOffset(x, y);
StartPosition = StartPosition.Add(x, y);
EndPosition = EndPosition.Add(x, y);
}
public void Move(Point offset)
@ -158,7 +159,7 @@ public virtual void OnUpdate()
{
Point pos = InputManager.ClientMousePosition;
if (Manager.IsCornerMoving)
if (Manager.IsCornerMoving && !Manager.IsPanning)
{
StartPosition = StartPosition.Add(InputManager.MouseVelocity);
}
@ -186,7 +187,7 @@ public virtual void OnUpdate()
EndPosition = pos;
}
else if (Manager.IsMoving)
else if (Manager.IsMoving && !Manager.IsPanning)
{
Move(InputManager.MouseVelocity);
}
@ -235,6 +236,13 @@ public virtual void OnNodeUpdate()
tempEndPos = new Point(Rectangle.X + Rectangle.Width - 1, Rectangle.Y + Rectangle.Height - 1);
}
if (Manager.IsCornerMoving || Manager.IsPanning)
{
tempStartPos.Offset(InputManager.MouseVelocity);
tempEndPos.Offset(InputManager.MouseVelocity);
tempNodePos.Offset(InputManager.MouseVelocity);
}
Point pos = InputManager.ClientMousePosition;
Point startPos = tempStartPos;
Point endPos = tempEndPos;
@ -273,7 +281,8 @@ public virtual void OnNodeUpdate()
break;
}
Rectangle = CaptureHelpers.CreateRectangle(startPos, endPos);
StartPosition = startPos;
EndPosition = endPos;
}
}
}

View file

@ -50,7 +50,8 @@ public void UpdateCursor(IntPtr cursorHandle, Point position)
Icon icon = Icon.FromHandle(cursorHandle);
cursorBitmap = icon.ToBitmap();
Rectangle = new Rectangle(position, cursorBitmap.Size);
StartPosition = position;
EndPosition = new Point(position.X + cursorBitmap.Size.Width, position.Y + cursorBitmap.Size.Height);
}
public override void ShowNodes()

View file

@ -73,7 +73,7 @@ public override void OnUpdate()
{
if (Manager.IsCreating)
{
if (Manager.IsCornerMoving)
if (Manager.IsCornerMoving && !Manager.IsPanning)
{
Move(InputManager.MouseVelocity);
}

View file

@ -185,6 +185,10 @@ public override void OnNodeVisible()
public override void OnNodeUpdate()
{
if (Manager.IsCornerMoving && !Manager.IsMoving && !Manager.IsPanning)
{
Move(InputManager.MouseVelocity);
}
if (Manager.ResizeNodes[0].IsDragging)
{
Manager.IsResizing = true;

View file

@ -40,7 +40,8 @@ public class StepDrawingShape : EllipseDrawingShape
public StepDrawingShape()
{
Rectangle = new Rectangle(0, 0, DefaultSize, DefaultSize);
StartPosition = new Point(0, 0);
EndPosition = new Point(DefaultSize, DefaultSize);
}
public override void ShowNodes()
@ -51,7 +52,8 @@ public override void OnCreating()
{
Manager.IsMoving = true;
Point pos = InputManager.ClientMousePosition;
Rectangle = new Rectangle(new Point(pos.X - Rectangle.Width / 2, pos.Y - Rectangle.Height / 2), Rectangle.Size);
StartPosition = new Point(pos.X - DefaultSize / 2, pos.Y - DefaultSize / 2);
EndPosition = new Point(pos.X + DefaultSize / 2, pos.Y + DefaultSize / 2);
}
public override void OnConfigLoad()

View file

@ -163,7 +163,8 @@ public void AutoSize(bool center)
location = Rectangle.Location;
}
Rectangle = new Rectangle(location, size);
StartPosition = location;
EndPosition = new Point(location.X + size.Width, location.Y + size.Height);
}
}
}