Пример #1
0
        private void FanCanvas_CardDrop(object sender, CardDropEventArgs e)
        {
            var hitTestResult = VisualTreeHelper.HitTest(this, e.MouseEventArgs.GetPosition(this));

            FanCanvas fan = null;

            if (hitTestResult != null)
            {
                fan = FindFanCanvasAncestor(hitTestResult.VisualHit);
            }

            if (fan == null)
            {
                ((FanCanvas)sender).CancelDrag();
            }
            else
            {
                var sourceController = FanCanvasControllers[(FanCanvas)sender];
                var card             = sourceController.CardFromShape(e.CardShape);
                //Debug.Assert(card != null);//***
                if (card == null)
                {
                    ((FanCanvas)sender).CancelDrag();
                }
                else
                {
                    var targetController = FanCanvasControllers[fan];

                    if (targetController.AcceptDrop(card))
                    {
                        sourceController.DropAcceptedNotification(card);
                        if (sourceController == HumanCardsController && humanCards.HasVisibleCards() == false)
                        {
                            foreach (var mshape in MeldShapes[HumanPlayer])
                            {
                                ((MeldController)FanCanvasControllers[mshape]).SubmitToGameState();
                            }
                        }
                    }
                    else
                    {
                        ((FanCanvas)sender).CancelDrag();
                    }
                }
            }
        }
Пример #2
0
        void FanCanvas_PreviewMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (_cardBeingDragged != null)
            {
                _dragsInLimbo.Add(_cardBeingDragged);
                _cardBeingDragged = null;
                if (_isDrag)
                {
                    _isDrag = false;
                    AdornerLayerForDrag().Remove(_dragAdorner);
                    _dragAdorner = null;

                    this.ReleaseMouseCapture();

                    var dropEventArgs = new CardDropEventArgs(_dragsInLimbo.Last(), e, CardDropEvent, this);
                    RaiseEvent(dropEventArgs);
                }
            }
        }