Example #1
0
 internal void HandleCardDraw(CardWrapper card)
 {
     if (PlayerDrawnCard != null)
     {
         PlayerDrawnCard(this, new CardDrawEventArgs(card));
     }
 }
Example #2
0
 public void SelectCard(CardWrapper card)
 {
     foreach (CardWrapper cardWrapper in Cards)
     {
         if (card.Card == cardWrapper.Card)
         {
             cardWrapper.IsSelected = true;
         }
     }
 }
Example #3
0
        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);
            }
        }
Example #4
0
        /// <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);
            }
        }
Example #5
0
        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);
                }
            }
        }
Example #6
0
 public CardDrawEventArgs(CardWrapper wrapper)
 {
     Card = wrapper;
 }