/// <summary> /// Обработчик события после отмены копирования/вставки /// </summary> void InputHandler_CopyIsActive() { string headerNotifyMessage = "Bind any key for buffer"; string bodyNotifyMessage = "You can bind any key, expect \"Esc\" and \"Left Ctrl\" After binded you might to use binded key for paste."; CopyIsActive?.Invoke(headerNotifyMessage, bodyNotifyMessage); _trayIconManager.ShowNotify(60000); }
/// <summary> /// Перехватывает нажатие всех клавиш в системе /// </summary> /// <param name="sender"></param> /// <param name="e">Нажатая клавиша</param> void InputController_KeyDown(object sender, KeyEventArgs e) { if (!_globalKeyDown) { return; } //ESC else if (e.KeyCode == Keys.Escape) { _keysCopyList.Clear(); _keysPasteList.Clear(); _keysShowWindowList.Clear(); CopyPasteCancelled?.Invoke(); } //LeftCtrl else if ((_keysCopyList.Count == 0 || _keysPasteList.Count == 0) && e.KeyCode == Keys.LControlKey) { _keysCopyList.Add(e.KeyCode); _keysPasteList.Add(e.KeyCode); _keysShowWindowList.Add(e.KeyCode); } //LeftCtrl + C else if (_keysCopyList.Count == 1 && _keysCopyList[0] == Keys.LControlKey && e.KeyCode == Keys.C) { _keysPasteList.Clear(); _keysShowWindowList.Clear(); _keysCopyList.Add(e.KeyCode); CopyIsActive?.Invoke(); } //LeftCtrl + V else if (_keysPasteList.Count == 1 && _keysPasteList[0] == Keys.LControlKey && e.KeyCode == Keys.V) { e.SuppressKeyPress = true; e.Handled = true; _keysCopyList.Clear(); _keysShowWindowList.Clear(); _keysPasteList.Add(e.KeyCode); PasteIsActive?.Invoke(); } //LeftCtrl + ~ else if (_keysShowWindowList.Count == 1 && _keysShowWindowList[0] == Keys.LControlKey && e.KeyCode == Keys.Oemtilde) { e.SuppressKeyPress = true; e.Handled = true; _keysShowWindowList.Clear(); _keysCopyList.Clear(); _keysPasteList.Clear(); ShowWindowKeyPress?.Invoke(this, EventArgs.Empty); } //LeftCtrl + C + AnyKey else if (_keysCopyList.Count == 2 && _keysCopyList[0] == Keys.LControlKey && _keysCopyList[1] == Keys.C) { e.SuppressKeyPress = true; e.Handled = true; _keysCopyList.Add(e.KeyCode); } //LeftCtrl + V + AnyKey else if (_keysPasteList.Count == 2 && _keysPasteList[0] == Keys.LControlKey && _keysPasteList[1] == Keys.V) { e.SuppressKeyPress = true; e.Handled = true; _keysPasteList.Add(e.KeyCode); PasteKeyPress?.Invoke(this, new InputHandlerEventArgs(_keysPasteList[2], string.Empty)); } else { _keysShowWindowList.Clear(); _keysCopyList.Clear(); _keysPasteList.Clear(); } }