internal void HandleCardDraw(CardWrapper card) { if (PlayerDrawnCard != null) { PlayerDrawnCard(this, new CardDrawEventArgs(card)); } }
public void SelectCard(CardWrapper card) { foreach (CardWrapper cardWrapper in Cards) { if (card.Card == cardWrapper.Card) { cardWrapper.IsSelected = true; } } }
public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container) { if (item == null) { return(null); } CardWrapper currentCard = (CardWrapper)item; FrameworkElement element = (FrameworkElement)container; if (currentCard.Card == Card.Empty) { return(element.TryFindResource("CardBackTemplate") as DataTemplate); } else { return(element.TryFindResource("CardFrontTemplate") as DataTemplate); } }
/// <summary> /// A callback for a player card click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CardButtonClicked(object sender, RoutedEventArgs e) { // must have a valid player as the data context to handle the current draw action GuiMainPlayer thePlayer = DataContext as GuiMainPlayer; if (thePlayer == null) { return; } // the card is also the button data context Button clickedCard = (Button)e.OriginalSource; CardWrapper wrapper = clickedCard.DataContext as CardWrapper; // send the player the button which was clicked. if (wrapper != null) { thePlayer.HandleCardDraw(wrapper); } }
private void RemoveCards(IEnumerable cards) { CardWrapper foundCard = null; foreach (Card card in cards) { foreach (CardWrapper cardWrapper in this.cards) { if (cardWrapper.Card == card) { foundCard = cardWrapper; break; } } if (foundCard != null) { this.cards.Remove(foundCard); } } }
public CardDrawEventArgs(CardWrapper wrapper) { Card = wrapper; }