Exemple #1
0
        public void Parse(List<Set> outList)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(mFilename);

            XmlNodeList nodes = doc.SelectNodes(ROOT_NODE);

            foreach (XmlNode node in nodes)
            {
                Set set = new Set();

                foreach (XmlNode n in node.ChildNodes)
                {
                    switch (n.Name)
                    {
                        case P_NAME:
                            {
                                set.Name = n.InnerText;
                                break;
                            }
                        case P_TYPE:
                            {
                                set.SetSetType(ParseEnum<Set.SetType>(n.InnerText));
                                break;
                            }
                        case P_ID:
                            {

                                break;
                            }
                        case P_CARDS:
                            {
                                foreach(XmlNode card in n.ChildNodes)
                                {
                                    set.AddCard(Convert.ToUInt32(card.InnerText));
                                }
                                break;
                            }
                        default:
                            {
                                Console.WriteLine("Unhandled node type: " + n.Name);
                                break;
                            }
                    }
                }

                outList.Add(set);
            }
        }
Exemple #2
0
        private void Save_btn_Click(object sender, EventArgs e)
        {
            Set set;

            if (-1 == mLastSelectedIndex || mLastSelectedIndex >= SetManager.GetInstance().GetAllSets().Count)
            {
                // Build & add new card
                set = new Set();
                _FillOutDataToSet(set);
                SetManager.GetInstance().AddSet(set);
            }
            else
            {
                // Just fill out card with new data and save
                set = SetManager.GetInstance().GetSetByIndex(mLastSelectedIndex);
                _FillOutDataToSet(set);
            }

            _RefreshListbox();
        }
Exemple #3
0
 public void RemoveSet(Set set)
 {
     mSets.Remove(set);
 }
Exemple #4
0
 public void AddSet(Set newSet)
 {
     mSets.Add(newSet);
 }
Exemple #5
0
        private void _FillOutDataToSet(Set set)
        {
            set.Name = SetName_text.Text;
            set.SetSetType((Set.SetType)SetType_chooser.SelectedIndex);
            //set.Block = (Set.SetBlock)SetBlock_listbox.SelectedItem;

            set.RemoveAllCards();
            foreach(Card c in SetCards_listBox.Items)
            {
                set.AddCard(c.Id);
            }
        }
Exemple #6
0
        private void _AppendSetNode(XmlDocument doc, XmlElement root, Set data)
        {
            // Set up our effect element
            XmlElement set = doc.CreateElement(SET_NODE);

            // Declare element storage
            XmlElement element;

            // Create attribute nodes
            element = doc.CreateElement(P_NAME);
            element.InnerText = data.Name;
            set.AppendChild(element);

            element = doc.CreateElement(P_TYPE);
            element.InnerText = data.GetSetType().ToString();
            set.AppendChild(element);

            List<uint> cardsList = data.GetCardIds();
            if (0 < cardsList.Count)
            {
                XmlElement cards = doc.CreateElement(P_CARDS);

                foreach (uint cId in cardsList)
                {
                    XmlElement card = doc.CreateElement(P_CARDID);
                    card.InnerText = cId.ToString();
                    cards.AppendChild(card);
                }

                set.AppendChild(cards);
            }

            // Finally, add our new set node
            root.AppendChild(set);
        }