private void ApplyButton_Click(object sender, RoutedEventArgs e) { for (int i = 0; i < itemsControl.Items.Count; i++) { Hotkey hotkey = (Hotkey)itemsControl.Items[i]; if (ModifiedHotkeys.TryGetValue(hotkey.Name, out bool output)) { if (output) { SetBinding(hotkey); } } } //Refreshes list of hotkeys UpdateHotkeys(); }
// Updates hotkeys as they have been modified public void UpdateHotkeys() { List <string> hotkeysToUpdate = new List <string>(); foreach (KeyValuePair <string, bool> pair in ModifiedHotkeys.ToList()) { if (pair.Value == true) { hotkeysToUpdate.Add(pair.Key); ModifiedHotkeys[pair.Key] = false; } } foreach (string name in hotkeysToUpdate) { Hotkey hotkey = Hotkeys.Find(item => item.Name == name); if (Groups.TryGetValue(hotkey.Group, out XMLHotkeyGroup group)) { hotkey.Binding = group.GetBinding(name); } } }