private void edit_Click(object sender, EventArgs e) { Keybind toEdit = (Keybind)picker.SelectedItem; using (SingleKeybindEditor edit = new SingleKeybindEditor(toEdit)) { edit.ShowDialog(); ApplyKeybindAfterEditing(edit, true, toEdit); edit.Enabled = false; delete.Enabled = false; } }
private void delete_Click(object sender, EventArgs e) { Keybind toDelete = (Keybind)picker.SelectedItem; Data.keybinds.DeleteKeybind(toDelete); if (Data.keybinds.keybinds.Count == 0) { edit.Enabled = false; delete.Enabled = false; } UpdateBox(); }
public void ReplaceKeybind(Keybind a, Keybind b) { Keybind[] arr = keybinds.ToArray(); for (int i = 0; i < arr.Length; i++) { Keybind current = arr[i]; if (current.Equals(a)) { arr[i] = b; } } keybinds = arr.ToList(); }
private void deleteButton_Click(object sender, EventArgs e) { Keybind toDelete = (Keybind)picker.SelectedItem; if (toDelete == null) { return; } Data.keybinds.DeleteKeybind(toDelete); if (Data.keybinds.keybinds.Count == 0) { editButton.Enabled = false; deleteButton.Enabled = false; } UpdateBox(); }
private void ApplyKeybindAfterEditing(SingleKeybindEditor editor, bool edited, Keybind toReplace) { if (!editor.confirmed) { return; } Keybind kb = editor.keybind; if (edited) { Data.keybinds.ReplaceKeybind(toReplace, kb); } else { Data.keybinds.AddKeybind(kb); } UpdateBox(); }
public void DeleteKeybind(Keybind k) { keybinds.Remove(k); }
public void AddKeybind(Keybind kb) { keybinds.Add(kb); }