private void btn_Update_Click(object sender, EventArgs e) { if (cbx_Stats.SelectedItem != null) { if (cbx_Stats.SelectedItem.ToString() == txb_Name.Text && txb_Name.Text != "") { Character.Stat.StatType temp = Character.Stat.StatType.Regular; if (rdb_Calculated.Checked) { temp = Character.Stat.StatType.Calculated; } stats[cbx_Stats.SelectedItem.ToString()].Update(temp, txb_Abbreviation.Text, txb_Description.Text); } } }
public void LoadStats() { stats.Clear(); if (!File.Exists(path + @"\Stats.xml")) { return; } XmlDocument xml = new XmlDocument(); xml.Load(path + @"\Stats.xml"); XmlElement root = xml.DocumentElement; XmlNodeList xn = root.SelectNodes("/Stats/Stat"); foreach (XmlNode node in xn) { string name = "", abb = "", desc = ""; Character.Stat.StatType type = Character.Stat.StatType.Calculated; for (int i = 0; i < node.ChildNodes.Count; i++) { switch (node.ChildNodes[i].Name) { case "Name": name = node.ChildNodes[i].InnerText; break; case "Abbreviation": abb = node.ChildNodes[i].InnerText; break; case "Description": desc = node.ChildNodes[i].InnerText; break; case "Type": if (node.ChildNodes[i].InnerText == Character.Stat.StatType.Regular.ToString()) { type = Character.Stat.StatType.Regular; } break; } } stats.Add(name, new Character.Stat(name, type, abb, desc)); } }
private void btn_Add_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txb_Name.Text) || string.IsNullOrWhiteSpace(txb_Abbreviation.Text) || string.IsNullOrWhiteSpace(txb_Description.Text)) { return; } if (stats.ContainsKey(txb_Name.Text)) { MessageBox.Show("This Stat already exists.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Character.Stat.StatType temp = Character.Stat.StatType.Regular; if (rdb_Calculated.Checked) { temp = Character.Stat.StatType.Calculated; } stats.Add(txb_Name.Text, new Character.Stat(txb_Name.Text, temp, txb_Abbreviation.Text, txb_Description.Text)); UpdateComboBox(); }