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); } }
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(); }
public void RemoveSet(Set set) { mSets.Remove(set); }
public void AddSet(Set newSet) { mSets.Add(newSet); }
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); } }
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); }