private void ShowHiddenCards()
 {
     for (int i = 0; i < 5; i++)
     {
         UserControls.Card card = userDeckViewCards[i, 0];
         card.cardImage.Source = new BitmapImage(new Uri( card.CardInView.SourceImage.Substring(20),UriKind.Relative));
     }
 }
        private void RecieveCardAnimation(int seatNumber, int cardSlotNumber, Card card)
        {
            Console.WriteLine("---recieveCard: " + card.ToString());

            NameScope.SetNameScope(this, new NameScope());

            // 创建card
            UserControls.Card viewCard = new UserControls.Card();
            userDeckViewCards[seatNumber, cardSlotNumber] = viewCard;            
            viewCard.CardInView = card;

            // 创建card的旋转效果
            RotateTransform cardTransform = new RotateTransform();            
            viewCard.RenderTransform = cardTransform;
            
            canvas.Children.Add(viewCard);

            string cardTransformName = "CardTransform" + card.ID;
            string cardName = "Card" + card.ID;
            Console.WriteLine("cardName: " + cardName);
            // 注册name
            this.RegisterName(cardTransformName, cardTransform);
            this.RegisterName(cardName, viewCard);
            
            // 初始化card至主牌堆
            Canvas.SetLeft(viewCard, Canvas.GetLeft(decks));
            Canvas.SetTop(viewCard, Canvas.GetTop(decks));

            this.Content = canvas;

            // 获取用户牌堆位置<top, left, rotate> (相对于canvas)
            UserControls.UserCardDeck userDeck;
            if (seatNumber == bankerSeatNumber) userDeck = ViewHelper.FindChild<UserControls.UserCardDeck>(canvas, "bankerDeck");
            else userDeck = ViewHelper.FindChild<UserControls.UserCardDeck>(canvas, "playerDeck" + seatNumber);
            var startPosition = new Tuple<double, double, double>(Canvas.GetTop(decks), Canvas.GetLeft(decks), 0);
            var keyFramePosition1 = new Tuple<double, double, double>(Canvas.GetTop(userDeck), Canvas.GetLeft(userDeck), userDeck.RotateAngle);

            // 定义贝塞尔曲线
            KeySpline keySpline = new KeySpline(0.25, 0.5, 0.75, 1);
            // 定义动画时间
            TimeSpan timeSpan = TimeSpan.FromMilliseconds(100);            
            // 定义动画时间戳
            KeyTime keyTime1 = KeyTime.FromTimeSpan(timeSpan);

            // Top
            var animationX = new DoubleAnimationUsingKeyFrames() { Duration = timeSpan };
            animationX.FillBehavior = FillBehavior.Stop;
            animationX.KeyFrames.Add(new SplineDoubleKeyFrame(keyFramePosition1.Item1, keyTime1, keySpline));
            
            // Left
            var animationY = new DoubleAnimationUsingKeyFrames() { Duration = timeSpan };
            animationY.FillBehavior = FillBehavior.Stop;
            animationY.KeyFrames.Add(new SplineDoubleKeyFrame(keyFramePosition1.Item2, keyTime1, keySpline));

            // Rotate
            var animationR = new DoubleAnimationUsingKeyFrames() { Duration = timeSpan };
            animationR.FillBehavior = FillBehavior.Stop;
            animationR.KeyFrames.Add(new SplineDoubleKeyFrame(keyFramePosition1.Item3, keyTime1, keySpline));

            // 绑定动画
            Storyboard.SetTargetName(animationX, cardName);
            Storyboard.SetTargetName(animationY, cardName);
            Storyboard.SetTargetName(animationR, cardTransformName);
            Storyboard.SetTargetProperty(animationX, new PropertyPath(Canvas.TopProperty));
            Storyboard.SetTargetProperty(animationY, new PropertyPath(Canvas.LeftProperty));
            Storyboard.SetTargetProperty(animationR, new PropertyPath(RotateTransform.AngleProperty));

            Storyboard storyboard1 = new Storyboard();
            storyboard1.Children.Add(animationX);
            storyboard1.Children.Add(animationY);
            storyboard1.Children.Add(animationR);

            // 获取用户牌位置
            var viewCardSlot = ViewHelper.FindChild<Border>(userDeck.canvas, "cardSlot" + cardSlotNumber);
            var viewCardSlotRender = (RotateTransform)userDeck.FindName("cardSlotRotateAngle" + cardSlotNumber);
            var keyFramePosition2 =
                new Tuple<double, double, double>(Canvas.GetTop(viewCardSlot), Canvas.GetLeft(viewCardSlot), viewCardSlotRender.Angle);

            Console.WriteLine(keyFramePosition2);

            var animationXs = new DoubleAnimationUsingKeyFrames() { Duration = timeSpan };
            animationXs.FillBehavior = FillBehavior.Stop;
            animationXs.KeyFrames.Add(new SplineDoubleKeyFrame(keyFramePosition2.Item1, keyTime1, keySpline));
            var animationYs = new DoubleAnimationUsingKeyFrames() { Duration = timeSpan };
            animationYs.FillBehavior = FillBehavior.Stop;
            animationYs.KeyFrames.Add(new SplineDoubleKeyFrame(keyFramePosition2.Item2, keyTime1, keySpline));
            var animationRs = new DoubleAnimationUsingKeyFrames() { Duration = timeSpan };
            animationRs.FillBehavior = FillBehavior.Stop;
            animationRs.KeyFrames.Add(new SplineDoubleKeyFrame(keyFramePosition2.Item3, keyTime1, keySpline));

            Storyboard.SetTargetName(animationXs, cardName);
            Storyboard.SetTargetName(animationYs, cardName);
            Storyboard.SetTargetName(animationRs, cardTransformName);
            Storyboard.SetTargetProperty(animationXs, new PropertyPath(Canvas.TopProperty));
            Storyboard.SetTargetProperty(animationYs, new PropertyPath(Canvas.LeftProperty));
            Storyboard.SetTargetProperty(animationRs, new PropertyPath(RotateTransform.AngleProperty));

            Storyboard storyboard2 = new Storyboard();
            storyboard2.Children.Add(animationXs);
            storyboard2.Children.Add(animationYs);
            storyboard2.Children.Add(animationRs);

            int cardLoadCount = 0;
            viewCard.Loaded += delegate (object sender, RoutedEventArgs e)
            {
                switch (cardLoadCount)
                {
                    case 0:
                        Console.WriteLine("animation " + animationCount + "start");
                        storyboard1.Begin(this);
                        animationLock.Status = Card.StatusEnum.Invisible;

                        Console.WriteLine(animationCount + " lock release");
                        break;
                    case 1:
                        storyboard2.Begin(this);
                        break;
                    default:
                        break;
                }
                cardLoadCount++;            
            };
            storyboard1.Completed += delegate (object sender, EventArgs e)
            {
                Canvas.SetLeft(viewCard, 0);
                Canvas.SetTop(viewCard, 0);
                cardTransform.Angle = 0;
                viewCard.RenderTransform = cardTransform;
                if (cardSlotNumber < 6) viewCard.RenderTransformOrigin = new Point(0, 1.5);
                else viewCard.RenderTransformOrigin = new Point(0, 1);

                // 将牌送入用户牌堆
                canvas.Children.Remove(viewCard);
                userDeck.canvas.Children.Add(viewCard);                          
            };
            storyboard2.Completed += delegate (object senders, EventArgs es)
            {
                Canvas.SetLeft(viewCard, 0);
                Canvas.SetTop(viewCard, 0);                
                cardTransform.Angle = 0;
                viewCard.RenderTransform = cardTransform;
                userDeck.canvas.Children.Remove(viewCard);

                viewCardSlot.Child = viewCard;
                viewCardSlot.Visibility = Visibility.Visible;

                Console.WriteLine("animation " + animationCount + "finish");

                animationCount--;
                if(animationQueue.Count > 0)
                    HandleDealCardEvent(animationQueue.Dequeue());
                if (animationCount == 0)
                {
                    HandleAnimations(room.Next());
                    if (room.CurrentPlayerIsYou)
                    {
                        chooseWantCardPanel.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        chooseWantCardPanel.Visibility = Visibility.Hidden;
                    }
                }
            };            
        }