示例#1
0
        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;
        }
示例#3
0
        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
            };
        }
示例#4
0
        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();
        }
示例#5
0
 /// <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);
 }
示例#6
0
 /// <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));
 }