private void HandleShapeDrag(DragState state)
{
_doc.UndoStack.UndoTentativeAction();
var movingShapes = Control.SelectedShapes;
var panels = Control.SelectedShapes.Where(s => s.IsPanel);
if (panels.Any() && (Control.SelectedShapes.Count > 1 ||
state.ClickedShape.MouseCursor == Cursors.SizeAll))
{
// Also move shapes that are inside the panel
movingShapes = Control.SelectedShapes.Clone();
foreach (var panel in panels)
movingShapes.AddRange(ShapesInsidePanel(panel));
}
if (movingShapes.Count <= 1)
{
var shape = state.ClickedShape.Shape;
if (shape is Shape)
{
DoOrUndo action = ((Shape)shape).DragMoveAction(state.ClickedShape, state.TotalDelta);
if (action != null)
{
_doc.UndoStack.DoTentatively(action);
AutoHandleAnchorsChanged();
}
}
}
else
{
foreach (Shape shape in movingShapes)
{
DoOrUndo action = shape.DragMoveAction(state.ClickedShape, state.TotalDelta);
if (action != null)
_doc.UndoStack.DoTentatively(action);
}
AutoHandleAnchorsChanged();
}
}