Пример #1
0
        private void DisplayHandCards()
        {
            var element = new HandCardsElement(Player.HandCards,
            showFaces: true,
            rotationAngle: 0,
            displayCardCount: false)
                      {
                        CardWidth = myHandCardsElement.CardWidth,
                        CardHeight = myHandCardsElement.CardHeight,
                      };

              UIElement rootVisual = Application.Current.RootVisual;
              var startRect = myHandCardsElement.GetRect(rootVisual);
              var endRect = new Rect(0, 0, rootVisual.RenderSize.Width, rootVisual.RenderSize.Height);
              const double endXStep = 1.1;
              double endCardWidth = rootVisual.RenderSize.Width / (Player.HandCards.Count * endXStep + 2 * (endXStep - 1));
              double endCardHeight = myHandCardsElement.CardHeight * endCardWidth / myHandCardsElement.CardWidth;
              var projection = new PlaneProjection();
              element.Projection = projection;
              myHandCardsElement.Visibility = Visibility.Collapsed;
              myHandCardsElement.NavigationAction = null;
              Cursor = Cursors.Arrow;
              Action onClosed = delegate
                          {
                            myHandCardsElement.Visibility = Visibility.Visible;
                            Timer timer = null;
                            timer = new Timer(delegate
                                                {
                                                  myHandCardsElement.NavigationAction = DisplayHandCards;
                                                  timer.Dispose();
                                                },
                                                null, 500, int.MaxValue);
                          };
              UIManager.Instance.ShowInPopup(element, startRect, endRect, onClosed,
                                     new AnimationInfo(element, new PropertyPath(HandCardsElement.XStepProperty), myHandCardsElement.XStep, endXStep),
                                     new AnimationInfo(element, new PropertyPath(HandCardsElement.MaxAngleProperty), myHandCardsElement.MaxAngle, 0),
                                     new AnimationInfo(element, new PropertyPath(HandCardsElement.AngleStepProperty), myHandCardsElement.AngleStep, 0),
                                     new AnimationInfo(element, new PropertyPath(HandCardsElement.CardWidthProperty), myHandCardsElement.CardWidth, endCardWidth),
                                     new AnimationInfo(element, new PropertyPath(HandCardsElement.CardHeightProperty), myHandCardsElement.CardHeight, endCardHeight),
                                     new AnimationInfo(projection, new PropertyPath(PlaneProjection.RotationXProperty), -45, 0));
        }
Пример #2
0
        public void Update()
        {
            Children.Clear();
              myCardElements.Clear();
              //myZoomedCard = null; //?
              if (Player == null) return;

              myBorder = new Border
                   {
                     BorderBrush = new SolidColorBrush(Player.Color.ToColor()),
                     BorderThickness = new Thickness(BorderThinkness),
                   };
              Children.Add(myBorder);

              myTitle = new TextBlock
                  {
                    Text = Player.Name,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    Foreground = new SolidColorBrush(Player.Color.ToColor()),
                    FontSize = 16,
                    FontWeight = FontWeights.Bold
                  };
              Children.Add(myTitle);

              AddCardImages(Player.RaceCards.Cast<ICard>());
              AddCardImage(Player.HalfBreededCard);
              AddCardImages(Player.ClassCards.Cast<ICard>());
              AddCardImage(Player.SuperManchkinCard);
              foreach (Tuple<ITreasureCard, ICheatCard> tuple in Player.WornItems)
              {
            AddCardImage(tuple.Item1);
            AddCardImage(tuple.Item2);
              }
              //TODO
              //AddCardImages(myPlayer.InPackItems);

              Action navigationAction = IsActivePlayer ? DisplayHandCards : (Action)null;
              Children.Add(myHandCardsElement = new HandCardsElement(Player.HandCards, IsActivePlayer, RotationAngle) {NavigationAction = navigationAction});

              InvalidateArrange();
        }