Esempio n. 1
0
        public bool TransferButton(DealerButtonPosition other)
        {
            if (_isDisplayingButton)
            {
                var transferAnimRequest = new NamedAnimationRequest()
                {
                    Destination             = other._origin,
                    Duration                = 0.3,
                    TargetElementName       = BUTTON_IMAGE_KEY,
                    IsCenteredAtDestination = false
                };

                _canvasProvider.QueueAnimationRequest(transferAnimRequest);
                other._isDisplayingButton = true;
                this._isDisplayingButton  = false;
                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        public void QueueAnimationRequest(NamedAnimationRequest animationRequest)
        {
            FrameworkElement targetElement = FindName(animationRequest.TargetElementName) as FrameworkElement
                                             ?? throw new ArgumentNullException($"{animationRequest.TargetElementName} didn't map to XAML element");
            Point?destination = null;

            if (animationRequest.Destination != null)
            {
                Size?targetSize = animationRequest.IsCenteredAtDestination
                    ? TryGetElementSize(targetElement)
                    : null;
                destination = DenormalizePosition(animationRequest.Destination, targetSize);
                // this does not set the position, it only registers the destination position of the image for dynamic repositioning on size change
                RegisterElementCanvasPosition(targetElement, animationRequest.Destination, true);
            }
            var inflatedReq = AnimationHelper.InflateAnimationRequest(animationRequest, targetElement, destination);
            List <DoubleAnimation> animations = AnimationHelper.ComposeImageAnimations(inflatedReq);

            animationQueue.AddRange(animations);
        }
Esempio n. 3
0
        public void TransferAll(CardGroup destinationGroup, AnimationBehavior animationBehavior)
        {
            var newPositions = destinationGroup.NextOpenPositions(_displayCards.Count);

            var cardsToTransfer = new List <UniqueDisplayCard>(_displayCards);

            this._displayCards.Clear();
            OnPostCardsRemoval();

            // resolve rotations so that the animation terminates at the angle of the destination group
            // rotations are rounded up so that the card is flush with the destination
            double resolvedRotations = ResolveRotations(destinationGroup, animationBehavior);

            for (int i = 0; i < cardsToTransfer.Count; i++)
            {
                var cardToTransfer   = cardsToTransfer[i];
                var destinationPoint = newPositions[i].Item1;
                var newZIndex        = newPositions[i].Item2;

                var transferAnimRequest = new NamedAnimationRequest()
                {
                    Destination       = destinationPoint,
                    Duration          = animationBehavior.Duration,
                    Delay             = animationBehavior.Delay,
                    Rotations         = resolvedRotations,
                    TargetElementName = cardToTransfer.Id
                };
                _canvasFacade.QueueAnimationRequest(transferAnimRequest);

                // finish transfer to destination group by updating the card to have the correct zIndex as determined by its destination group
                _canvasFacade.UpdateCard(cardToTransfer, zIndex: newZIndex);
            }



            destinationGroup.OnPreCardsAddition(cardsToTransfer);
            destinationGroup._displayCards.AddRange(cardsToTransfer);
        }
Esempio n. 4
0
        // transfers the first card in _cards matching the cardName param
        public bool Transfer(Core.Card card, CardGroup destinationGroup, AnimationBehavior animationBehavior)
        {
            UniqueDisplayCard cardToTransfer = GetDisplayCardFromCoreCard(card);

            if (cardToTransfer != null)
            {
                var nextOpenPositionInfo = destinationGroup.NextOpenPositions(1)[0];
                var destinationPoint     = nextOpenPositionInfo.Item1;
                var newZIndex            = nextOpenPositionInfo.Item2;

                this._displayCards.Remove(cardToTransfer);
                this.OnPostCardsRemoval();

                // resolve rotations so that the animation terminates at the angle of the destination group
                // rotations are rounded up so that the card is flush with the destination
                double resolvedRotations = ResolveRotations(destinationGroup, animationBehavior);

                var transferAnimRequest = new NamedAnimationRequest()
                {
                    Destination       = destinationPoint,
                    Duration          = animationBehavior.Duration,
                    Delay             = animationBehavior.Delay,
                    Rotations         = resolvedRotations,
                    TargetElementName = cardToTransfer.Id
                };
                _canvasFacade.QueueAnimationRequest(transferAnimRequest);

                destinationGroup.OnPreCardsAddition(new List <UniqueDisplayCard> {
                    cardToTransfer
                });
                destinationGroup._displayCards.Add(cardToTransfer);

                // finish transfer to destination group by updating the card to have the correct zIndex as determined by its destination group
                _canvasFacade.UpdateCard(cardToTransfer, zIndex: newZIndex);
                return(true);
            }
            return(false);
        }