예제 #1
0
        private void collectionListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Added data validation to the PopulateCardList method to stop any crashing from empty collections.
            //Need to work on the formatting of the cardListBox.
            CardCollection        lsbCollection  = new CardCollection();
            List <CardCollection> listCollection = new List <CardCollection>();

            lsbCollection.PopulateCardList(listCollection, collectionListBox.SelectedItem.ToString());
            foreach (var item in listCollection)
            {
                cardListBox.Items.Add(item.CardName);
            }
        }
예제 #2
0
        public void EditCard(string eCollectionName, string eCardName)
        {
            //This might be pointless.
            CardCollection        editColl   = new CardCollection();
            List <CardCollection> eLstOfCard = new List <CardCollection>();

            editColl.PopulateCardList(eLstOfCard, eCollectionName);
            for (int i = 0; i < eLstOfCard.Count; i++)
            {
                if (eLstOfCard[i].CardName == eCardName)
                {
                    eLstOfCard.RemoveAt(i);
                }
            }
        }
예제 #3
0
        public void RemoveCard(string rCollectionName, string cardToDelete)
        {
            CardCollection        delColl     = new CardCollection();
            List <CardCollection> rlstOfCards = new List <CardCollection>();

            delColl.PopulateCardList(rlstOfCards, rCollectionName);
            for (int i = 0; i < rlstOfCards.Count; i++)
            {
                if (rlstOfCards[i].CardName == cardToDelete)
                {
                    rlstOfCards.RemoveAt(i);
                }
            }

            delColl.SaveCollection(rCollectionName, rlstOfCards);
        }
예제 #4
0
        public void AddCard(string iCollectionName, string iCardName, double iCardPrice, bool iInDeck)
        {
            //This adds card to a collection.
            CardCollection        newCard  = new CardCollection();
            List <CardCollection> collList = new List <CardCollection>();

            //the PopulateCardList method fills the list with all the card before the one being added.
            newCard.PopulateCardList(collList, iCollectionName);
            newCard.CollectionName = iCollectionName;
            newCard.CardName       = iCardName;
            newCard.CardPrice      = iCardPrice;
            newCard.InDeck         = iInDeck;

            collList.Add(newCard);

            XmlSerializer xs = new XmlSerializer(typeof(List <CardCollection>));

            File.Delete(iCollectionName);
            using (FileStream fs = new FileStream(@"collections\" + iCollectionName, FileMode.Create))
            {
                xs.Serialize(fs, collList);
            }
            MessageBox.Show("card added here: " + @"collections\" + iCollectionName);
        }