private void DrawDecks() { controlCanvas.Children.Clear(); if (CurrentPlayer == null || Deck == null || !GameStarted) { return; } List <UNOCardControl> stackedCards = new List <UNOCardControl>(); for (int i = 0; i < Deck.CardsInDeck; i++) { stackedCards.Add(new UNOCardControl(Deck.GetCard(i)) { Margin = new Thickness(150 + (i * 1.25), 25 - (i * 1.25), 0, 0), IsFaceUp = false }); } if (stackedCards.Count > 0) { stackedCards.Last().MouseDoubleClick += Deck_MouseDoubleClick; } if (AvailableCard != null) { var availableCard = new UNOCardControl(AvailableCard) { Margin = new Thickness(0, 25, 0, 0) }; availableCard.MouseDoubleClick += AvailalbleCard_MouseDoubleClick; controlCanvas.Children.Add(availableCard); } stackedCards.ForEach(x => controlCanvas.Children.Add(x)); }
private void DrawCards() { bool isFaceup = (Owner.State != PlayerState.Inactive); if (Owner is ComputerPlayer) { isFaceup = (Owner.State == PlayerState.Loser || Owner.State == PlayerState.Winner); } var cards = Owner.GetCards(); if (cards == null || cards.Count == 0) { return; } for (var i = 0; i < cards.Count; i++) { var cardControl = new UNOCardControl(cards[i]); if (PlayerOrientation == Orientation.Horizontal) { cardControl.Margin = new Thickness(i * 35, 35, 0, 0); } else { cardControl.Margin = new Thickness(5, 35 + i * 30, 0, 0); } cardControl.MouseDoubleClick += cardControl_MouseDoubleClick; cardControl.IsFaceUp = isFaceup; CardSurface.Children.Add(cardControl); } }