예제 #1
0
        // whenever you select a deck

        private void populateDeckContents(int id)
        {
            Models.CollectionDeck deck;

            stackDeckContents.Children.Clear();
            listDeckContentGUI.Clear();
            deck = ctrl.getDeckByID(id);

            this.deck = deck.Clone();

            if (deck != null)
            {
                foreach (Models.CollectionDeckItem cdi in deck.CardList)
                {
                    Models.DeckItemGUIModel cguim = new Models.DeckItemGUIModel(cdi, this);
                    listDeckContentGUI.Add(cguim);
                    stackDeckContents.Children.Add(cguim.Border);
                }
            }
        }
예제 #2
0
        // add a new card to deck while in Edit mode

        private void addCardToDeck(Models.Card card)
        {
            bool found;

            if (deck.Count == 40)
            {
                MessageBox.Show("This deck contains 40 cards. You cannot add any more.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (deck.addCard(card))
            {
                found = false;
                foreach (Models.DeckItemGUIModel dguim in listDeckContentGUI)
                {
                    if (dguim.Card.ID == card.ID)
                    {
                        dguim.increaseCount();
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    Models.CollectionDeckItem collectionDeckItem = deck.getCollectionDeckItemByID(card.ID);
                    Models.DeckItemGUIModel   cguim = new Models.DeckItemGUIModel(collectionDeckItem, this);
                    listDeckContentGUI.Add(cguim);
                    stackDeckContents.Children.Add(cguim.Border);
                }
            }
            else
            {
                MessageBox.Show("You can only add a maximum of 4 copies of any card.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }