public void Renew(GlobalHotkey ghk, IWin32Window window) { Modifier = ghk.Modifier; Key = (int)ghk.Key; hWnd = window.Handle; Id = GetHashCode(); Register(); }
/* Sets the hotkeys using global hotkey objects *Depreciated* */ public void setVolumeHotkeys(GlobalHotkey volumeUp, GlobalHotkey volumeDown) { if (hotkeyVolUp != null) { hotkeyVolUp.Unregister(); } else if(hotkeyVolDown != null){ hotkeyVolDown.Unregister(); } hotkeyVolUp = volumeUp; hotkeyVolDown = volumeDown; hasHotkey = true; }
/* Registers the hotkeys assigned to this group with the operating system and associates them with the programs main window */ public void registerHotkey(IWin32Window window) { if (!hasHotkey && !hotkeyPendingRegistration) { return; } Keys volUpKey = Keys.None; Keys volDownKey = Keys.None; //convert the Keys and Modifiers into a useable form if (volumeUp != "None" && volumeUp != null) { volUpKey = (Keys)Enum.Parse(typeof(Keys), volumeUp); } if (volumeDown != "None" && volumeDown != null) { volDownKey = (Keys)Enum.Parse(typeof(Keys), volumeDown); } Modifiers modifiers = Modifiers.NoMod; foreach(string keyModifier in mods){ modifiers |= (Modifiers)Enum.Parse(typeof(Modifiers), keyModifier); } //create the hotkeys from hotkey data and register them with the system try { if (volumeUp != "None") { hotkeyVolUp = new GlobalHotkey(modifiers, volUpKey, window, true); } if (volumeDown != "None") { hotkeyVolDown = new GlobalHotkey(modifiers, volDownKey, window, true); } hasHotkey = true; hotkeyPendingRegistration = false; } catch (GlobalHotkeyException exc) { MessageBox.Show(exc.Message); } Console.WriteLine(groupName+" HotkeysRegistered"); }