public WindowHerderOptions() { // default save hotkey: Alt+F1 SaveStateHotKey = new HotKeyDefinition { IncludeAltKey = true, IncludeCtrlKey = false, IncludeShiftKey = false, IncludeWindowsKey = false, KeyCode = Keys.F1 }; // default restore hotkey: Alt+F2 RestoreStateHotKey = new HotKeyDefinition { IncludeAltKey = true, IncludeCtrlKey = false, IncludeShiftKey = false, IncludeWindowsKey = false, KeyCode = Keys.F2 }; ShowStartupMessage = true; ShowSavedMessage = true; ShowRestoredMessage = false; BalloonTipLifespan = 500; }
private void saveHotKey(RegistryKey parentRegistryKey, string subRegistryKeyName, HotKeyDefinition hotKey) { using (RegistryKey subKey = parentRegistryKey.CreateSubKey(subRegistryKeyName)) { subKey.SetValue("IncludeAltKey", hotKey.IncludeAltKey); subKey.SetValue("IncludeCtrlKey", hotKey.IncludeCtrlKey); subKey.SetValue("IncludeShiftKey", hotKey.IncludeShiftKey); subKey.SetValue("IncludeWindowsKey", hotKey.IncludeWindowsKey); subKey.SetValue("KeyCode", (int)hotKey.KeyCode); } }
private HotKeyDefinition loadHotKey(RegistryKey parentRegistryKey, string subRegistryKeyName) { var hotKey = new HotKeyDefinition(); using (RegistryKey subKey = parentRegistryKey.CreateSubKey(subRegistryKeyName)) { hotKey.IncludeAltKey = Convert.ToBoolean(subKey.GetValue("IncludeAltKey", hotKey.IncludeAltKey)); hotKey.IncludeCtrlKey = Convert.ToBoolean(subKey.GetValue("IncludeCtrlKey", hotKey.IncludeCtrlKey)); hotKey.IncludeShiftKey = Convert.ToBoolean(subKey.GetValue("IncludeShiftKey", hotKey.IncludeShiftKey)); hotKey.IncludeWindowsKey = Convert.ToBoolean(subKey.GetValue("IncludeWindowsKey", hotKey.IncludeWindowsKey)); hotKey.KeyCode = (Keys)Convert.ToInt32(subKey.GetValue("KeyCode", hotKey.KeyCode)); } return hotKey; }
private HotKeyDefinition loadHotKey(RegistryKey parentRegistryKey, string subRegistryKeyName) { var hotKey = new HotKeyDefinition(); using (RegistryKey subKey = parentRegistryKey.CreateSubKey(subRegistryKeyName)) { hotKey.IncludeAltKey = Convert.ToBoolean(subKey.GetValue("IncludeAltKey", hotKey.IncludeAltKey)); hotKey.IncludeCtrlKey = Convert.ToBoolean(subKey.GetValue("IncludeCtrlKey", hotKey.IncludeCtrlKey)); hotKey.IncludeShiftKey = Convert.ToBoolean(subKey.GetValue("IncludeShiftKey", hotKey.IncludeShiftKey)); hotKey.IncludeWindowsKey = Convert.ToBoolean(subKey.GetValue("IncludeWindowsKey", hotKey.IncludeWindowsKey)); hotKey.KeyCode = (Keys)Convert.ToInt32(subKey.GetValue("KeyCode", hotKey.KeyCode)); } return(hotKey); }
public void RegisterHotKey(HotKeyDefinition definition, HotKeyPressedCallback callback) { try { var hotkey = new Hotkey { Alt = definition.IncludeAltKey, Ctrl = definition.IncludeCtrlKey, Shift = definition.IncludeShiftKey, WindowsKey = definition.IncludeWindowsKey, KeyCode = definition.KeyCode }; hotkey.HotkeyPressed += ((sender, e) => callback.Invoke()); hotkey.Enabled = true; _hotkeys.Add(hotkey); } catch (Exception) { } }