public MainWindow()
        {
            this.InitializeComponent();
            var hkm = new HotkeyManager();

            hkm.AddOrReplace("Increment", Key.S, ModifierKeys.Control | ModifierKeys.Alt, this.OnHotkey1);
            hkm.AddOrReplace("Decrement", Key.D, ModifierKeys.Control | ModifierKeys.Alt, this.OnHotkey2);
        }
Exemple #2
0
        public MainForm()
        {
            this.InitializeComponent();
            var hkm = new HotkeyManager();

            hkm.AddOrReplace("Increment", Keys.S | Keys.Control | Keys.Alt, this.OnHotkey1);
            hkm.AddOrReplace("Decrement", Keys.D | Keys.Control | Keys.Alt, this.OnHotkey2);
        }
Exemple #3
0
        /// <summary>
        /// Registers a HotKey with CTRL + {mod} + {key}
        /// </summary>
        /// <param name="hotkey"></param>
        /// <param name="callback"></param>
        public static void RegisterHotkey(Hotkey hotkey, Action callback)
        {
            if (hotkey == null || callback == null)
            {
                Manager.Remove(ShowAppKey);
                Settings.Hotkey        = null;
                Settings.HotkeyEnabled = false;
            }
            else
            {
                Settings.Hotkey        = hotkey.ToString();
                Settings.HotkeyEnabled = true;

                Manager.AddOrReplace(ShowAppKey, hotkey.Key,
                                     ModifierKeys.Control | hotkey.Modifier,
                                     (sender, e) => callback.Invoke());
            }

            Settings.Save();
        }
Exemple #4
0
 public static void AddOrReplace(this HotkeyManager man, string name, Hotkey hotkey, EventHandler <HotkeyEventArgs> handler)
 => man.AddOrReplace(name, hotkey.Key, hotkey.Modifiers, handler);