public LevelSelector() { InitializeComponent(); levelSelectModel = new LevelSelectModel(); LoadFromFile(); if (LevelSettingsHotkeys[0] != "Press a Key") { comboBox.SelectedItem = HotkeyedSettingsLevels[0]; label1.Content = "Hotkey: " + LevelSettingsHotkeys[0]; } comboBox.ItemsSource = LevelSelectModel.Levels.Values; comboBox.SelectedIndex = 0; lblFile.Content = lblFile.Content = "Currently Selected File: " + levelSelectModel.fileName; if (levelSelectModel.fileName == "Pick a File in Settings") { btnSave.IsEnabled = false; } _hookID = SetHook(_proc); }
public LevelSelectSettings(LevelSelectModel levelSelectModel) { InitializeComponent(); comboBox1.ItemsSource = LevelSelectModel.Levels.Values; comboBox1.SelectedIndex = 0; comboBox2.ItemsSource = LevelSelectModel.Levels.Values; comboBox2.SelectedIndex = 1; comboBox3.ItemsSource = LevelSelectModel.Levels.Values; comboBox3.SelectedIndex = 2; comboBox4.ItemsSource = LevelSelectModel.Levels.Values; comboBox4.SelectedIndex = 3; comboBox5.ItemsSource = LevelSelectModel.Levels.Values; comboBox5.SelectedIndex = 4; comboBox6.ItemsSource = LevelSelectModel.Levels.Values; comboBox6.SelectedIndex = 5; comboBox7.ItemsSource = LevelSelectModel.Levels.Values; comboBox7.SelectedIndex = 6; comboBox8.ItemsSource = LevelSelectModel.Levels.Values; comboBox8.SelectedIndex = 7; comboBox9.ItemsSource = LevelSelectModel.Levels.Values; comboBox9.SelectedIndex = 8; comboBox10.ItemsSource = LevelSelectModel.Levels.Values; comboBox10.SelectedIndex = 9; comboBox11.ItemsSource = LevelSelectModel.Levels.Values; comboBox11.SelectedIndex = 10; comboBox12.ItemsSource = LevelSelectModel.Levels.Values; comboBox12.SelectedIndex = 11; lblFileSelection.Content = levelSelectModel.fileName; XmlDocument doc = new XmlDocument(); try { doc.Load("Settings.xml"); XmlNodeList hotkeysList = doc.GetElementsByTagName("Hotkey"); textBox1.Text = hotkeysList[0].Attributes["key"].InnerText; comboBox1.SelectedItem = hotkeysList[0].Attributes["level"].InnerText; textBox2.Text = hotkeysList[1].Attributes["key"].InnerText; comboBox2.SelectedItem = hotkeysList[1].Attributes["level"].InnerText; textBox3.Text = hotkeysList[2].Attributes["key"].InnerText; comboBox3.SelectedItem = hotkeysList[2].Attributes["level"].InnerText; textBox4.Text = hotkeysList[3].Attributes["key"].InnerText; comboBox4.SelectedItem = hotkeysList[3].Attributes["level"].InnerText; textBox5.Text = hotkeysList[4].Attributes["key"].InnerText; comboBox5.SelectedItem = hotkeysList[4].Attributes["level"].InnerText; textBox6.Text = hotkeysList[5].Attributes["key"].InnerText; comboBox6.SelectedItem = hotkeysList[5].Attributes["level"].InnerText; textBox7.Text = hotkeysList[6].Attributes["key"].InnerText; comboBox7.SelectedItem = hotkeysList[6].Attributes["level"].InnerText; textBox8.Text = hotkeysList[7].Attributes["key"].InnerText; comboBox8.SelectedItem = hotkeysList[7].Attributes["level"].InnerText; textBox9.Text = hotkeysList[8].Attributes["key"].InnerText; comboBox9.SelectedItem = hotkeysList[8].Attributes["level"].InnerText; textBox10.Text = hotkeysList[9].Attributes["key"].InnerText; comboBox10.SelectedItem = hotkeysList[9].Attributes["level"].InnerText; textBox11.Text = hotkeysList[10].Attributes["key"].InnerText; comboBox11.SelectedItem = hotkeysList[10].Attributes["level"].InnerText; textBox12.Text = hotkeysList[11].Attributes["key"].InnerText; comboBox12.SelectedItem = hotkeysList[11].Attributes["level"].InnerText; if (!levelSelectModel.LevelHotkeys.Any()) { LevelHotkeys = new List <string>(); LevelHotkeys.Add(hotkeysList[0].Attributes["key"].InnerText); LevelHotkeys.Add(hotkeysList[1].Attributes["key"].InnerText); LevelHotkeys.Add(hotkeysList[2].Attributes["key"].InnerText); LevelHotkeys.Add(hotkeysList[3].Attributes["key"].InnerText); LevelHotkeys.Add(hotkeysList[4].Attributes["key"].InnerText); LevelHotkeys.Add(hotkeysList[5].Attributes["key"].InnerText); LevelHotkeys.Add(hotkeysList[6].Attributes["key"].InnerText); LevelHotkeys.Add(hotkeysList[7].Attributes["key"].InnerText); LevelHotkeys.Add(hotkeysList[8].Attributes["key"].InnerText); LevelHotkeys.Add(hotkeysList[9].Attributes["key"].InnerText); LevelHotkeys.Add(hotkeysList[10].Attributes["key"].InnerText); LevelHotkeys.Add(hotkeysList[11].Attributes["key"].InnerText); } else { LevelHotkeys = levelSelectModel.LevelHotkeys; } } // keep blank to prevent crash on empty file or not enough elements found catch { LevelHotkeys = new List <string>(); LevelHotkeys.Add("Press a Key"); LevelHotkeys.Add("Press a Key"); LevelHotkeys.Add("Press a Key"); LevelHotkeys.Add("Press a Key"); LevelHotkeys.Add("Press a Key"); LevelHotkeys.Add("Press a Key"); LevelHotkeys.Add("Press a Key"); LevelHotkeys.Add("Press a Key"); LevelHotkeys.Add("Press a Key"); LevelHotkeys.Add("Press a Key"); LevelHotkeys.Add("Press a Key"); LevelHotkeys.Add("Press a Key"); LevelHotkeys.Add("Press a Key"); } if (levelSelectModel.fileName == "Pick a File in Settings") { textBox1.IsEnabled = false; textBox2.IsEnabled = false; textBox3.IsEnabled = false; textBox4.IsEnabled = false; textBox5.IsEnabled = false; textBox6.IsEnabled = false; textBox7.IsEnabled = false; textBox8.IsEnabled = false; textBox9.IsEnabled = false; textBox10.IsEnabled = false; textBox11.IsEnabled = false; textBox12.IsEnabled = false; lblFileSelection.Content = "Pick a File"; } }