public Register ( Key key, ModifierKeys modifiers ) : System.Windows.Input.HotKey | ||
key | Key | The key. |
modifiers | ModifierKeys | The key modifiers. |
return | System.Windows.Input.HotKey |
public static void RegisterGlobalHotkey(HotKeyManager hkManager, LoadedGlobalHotkey hotkey) { if (hotkey.SecondModifierKey != ModifierKeys.None) { hkManager.Register(hotkey.Hotkey, hotkey.FirstModifierKey | hotkey.SecondModifierKey); } else { hkManager.Register(hotkey.Hotkey, hotkey.FirstModifierKey); } }
public MainForm() { InitializeComponent(); try { _hotKeyManager = new HotKeyManager(); _hotKeyManager.KeyPressed += HotKeyManagerPressed; _hotKeyManager.Register(System.Windows.Input.Key.X, System.Windows.Input.ModifierKeys.Alt); } catch { MessageBox.Show("Не удалось зарегистрировать глобальные горячие клавишы! Возможно, приложение уже запущено.", "Ошибка"); Environment.Exit(-1); } _basepath = Application.StartupPath + "\\" + "data.bin"; if (File.Exists(_basepath)) { int _n = int.Parse((Properties.Settings.Default.lastbackup ?? "0").ToString()); _n = _n < 10 ? _n + 1 : 1; File.Copy(_basepath, _basepath + "_" + _n.ToString(), true); Properties.Settings.Default.lastbackup = _n.ToString(); Properties.Settings.Default.Save(); Data.NoteList = new faNotes(_basepath); Data.NoteList.Load(); } else { var result = MessageBox.Show("База данных не найдена, создать новую?", "TizTaboo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { Data.NoteList = new faNotes(_basepath); Data.NoteList.Add(new faNote("Тест", "test", "https://vk.com", "", faType.Ссылка, false, 0)); if (!Data.NoteList.Save()) { MessageBox.Show("Ошибка создания базы!"); Environment.Exit(-1); } } } }