protected override void OnMouseMove(MouseEventArgs e)
{
if (Card == null) return;
if (Card.Controller != Player.LocalPlayer) return;
base.OnMouseMove(e);
e.Handled = true;
Point windowPt = e.GetPosition(Window.GetWindow(this));
Point pt = e.GetPosition(this);
if (!_isDragging)
{
// Check if the button was pressed over the card, and was not release on another control in the meantime
// (possible if the cursor is near the border of the card)
if (Mouse.LeftButton == MouseButtonState.Pressed &&
// Check if has moved enough to start a drag and drop
(Math.Abs(windowPt.X - _mouseWindowPt.X) > SystemParameters.MinimumHorizontalDragDistance ||
Math.Abs(windowPt.Y - _mouseWindowPt.Y) > SystemParameters.MinimumVerticalDragDistance))
{
if (_dragSource == DragSource.Card)
{
DragCardStarted();
}
// Fix: Card could be null if a keyboard shortut was used when the mouse button was pressed.
else if (_dragSource == DragSource.Target && Card != null && Card.Group is Table)
{
_isDragging = true;
RaiseEvent(new CardEventArgs(CardHoveredEvent, this));
AdornerLayer layer = AdornerLayer.GetAdornerLayer(this);
_draggedArrow = new ArrowAdorner(Player.LocalPlayer, this);
layer.Add(_draggedArrow);
}
}
}
else
{
switch (_dragSource)
{
case DragSource.Card:
DragMouseDelta(windowPt.X - _mouseWindowPt.X, windowPt.Y - _mouseWindowPt.Y);
break;
case DragSource.Target:
DragTargetDelta(pt);
break;
}
}
}