private void DragCollapseSelection(IInputElement previous, IInputElement current)
{
if (current == previous) return;
if (DraggedCards.Count <= 1) return;
bool isFirst = true;
// Collapse if we leave the table
if (previous is TableControl)
{
foreach (CardDragAdorner overlay in OverlayElements)
{
if (overlay.SourceCard == this && isFirst)
{
isFirst = false;
continue;
}
CardControl cardCtrl = overlay.SourceCard;
double dx = Card.X - cardCtrl.Card.X, dy = Card.Y - cardCtrl.Card.Y;
overlay.CollapseTo(dx * ScaleFactor.Width, dy * ScaleFactor.Height);
}
}
// Expand if we enter the table
else if (current is TableControl)
{
foreach (CardDragAdorner overlay in OverlayElements)
{
if (overlay.SourceCard == this && isFirst)
{
isFirst = false;
continue;
}
overlay.Expand();
}
}
}