public MainWindow() { InitializeComponent(); this.heroList = new List<string>(); this.heroList.Add("Druid"); this.heroList.Add("Hunter"); this.heroList.Add("Mage"); this.heroList.Add("Paladin"); this.heroList.Add("Priest"); this.heroList.Add("Rogue"); this.heroList.Add("Shaman"); this.heroList.Add("Warlock"); this.heroList.Add("Warrior"); cmbHero.ItemsSource = this.heroList; cmbOpponentHero.ItemsSource = this.heroList; List<string> result = new List<string>(); result.Add("Win"); result.Add("Loss"); cmbResult.ItemsSource = result; //Load history and cards this.xmlReader = new XmlReader(); //set statistics tab setStatisticsTab(); //Try to load saved arena this.currentArena = this.xmlReader.LoadArena("currentArena.xml"); if (this.currentArena == null) { setNewArenaTab(); } else { setCurrentArenaTab(); } }
public void SaveArena(Arena arena, string fileName) { XmlSerializer xs = new XmlSerializer(typeof(Arena)); TextWriter tw = new StreamWriter(fileName); try { xs.Serialize(tw, arena); } catch (Exception e) { MessageBox.Show(e.Message); } finally { tw.Close(); } }
private void setNewArenaTab() { tbStatus.Text = "Can't load saved arena. Creating new arena run."; this.currentArena = new Arena(); tabCurrentArena.IsEnabled = false; tabNewArena.IsEnabled = true; tabControl.SelectedIndex = 1; txtCard.IsEnabled = false; btnAddCard.IsEnabled = false; btnSaveToCurrentArena.IsEnabled = false; btnRemoveLast.IsEnabled = false; lbCards.ItemsSource = null; }