public void Add() { var newBinding = new HotKeyBinding { Name = "New Binding" }; HotKeys.Add(newBinding); SelectedHotKey = newBinding; }
public void RegisterHotKeyToMenuItem(HotKeyBinding hotKey) { // Set the id. hotKey.WindowsHotkeyId = uniqueHotkeyIdCounter++; // Create a hotkey registration. hotKey.HotKeyRegisteredSuccessfully = RegisterHotKey(Handle, hotKey.WindowsHotkeyId, (uint)hotKey.HotKey.Modifiers, (uint)hotKey.HotKey.HotKeyCharacter); hotKeyCodesToHotKeys[hotKey.WindowsHotkeyId] = hotKey; }
void NewHotKeyBindingWindow_Closed(object sender, System.EventArgs e) { if (DialogResult != true) { return; } var vm = newHotKeyBindingView.ViewModel; // Create the hotkey binding. HotKeyBinding = new HotKeyBinding { HotKey = vm.HotKey, DisplayName = vm.DisplayName, Action = vm.SelectedAction }; }
public void ShowSuggestionsWindow(Window parentWindow = null) { // Create a suggestions window. var suggestionsWindow = new Suggestions.SuggestionsWindow { Owner = parentWindow }; // Provide the full set of suggestions... suggestionsWindow.Suggestions = this.Suggestions; // Show the window - if not OKd then return. if (suggestionsWindow.ShowDialog() != true) { return; } // Otherwise, create a binding for each suggestions. foreach (var suggestion in suggestionsWindow.AcceptedSuggestions) { // Add each suggestion. var binding = new HotKeyBinding { DisplayName = suggestion.DisplayName, HotKey = suggestion.HotKey, IsEnabled = true, Action = new ExecuteProgramAction { Program = suggestion.FindValidSuggestionPath() } }; HotKeyBindings.Add(binding); } SaveSettings(); }
/// <summary> /// Adds a binding for the specified hotkey. /// The handler will be called when the hotkey is pressed. /// </summary> /// <param name="binding">The hotkey and the handler to call when the hotkey is pressed.</param> public void AddHotKey(HotKeyBinding binding) { bindings.Add(binding); }
/// <summary> /// Removes the specified binding. /// </summary> /// <param name="binding">The binding to remove.</param> /// <returns>Whether the binding was found and removed.</returns> public bool RemoveHotKey(HotKeyBinding binding) { return(bindings.Remove(binding)); }