コード例 #1
0
        public static List <string> GetKeyEventArgsAsList(SimpleGlobalHotkeyServiceEventArgs keyEventArgs, string keyStart = "[", string keyEnd = "]")
        {
            List <string> keys = new List <string>();

            // modifier keys
            if (keyEventArgs.IsShiftPressed)
            {
                keys.Add(keyStart + "Shift" + keyEnd);
            }

            if (keyEventArgs.IsCtrlPressed)
            {
                keys.Add(keyStart + "Ctrl" + keyEnd);
            }

            if (keyEventArgs.IsAltPressed)
            {
                keys.Add(keyStart + "Alt" + keyEnd);
            }

            if (keyEventArgs.IsWinPressed)
            {
                keys.Add(keyStart + "Win" + keyEnd);
            }

            // actual hotkey
            if (!Enum.IsDefined(typeof(PressingIssue.Services.Contracts.ModifierKeys), (int)keyEventArgs.Key))
            {
                keys.Add(keyStart + keyEventArgs.Key.ToString() + keyEnd);
            }

            return(keys);
        }
コード例 #2
0
        private void SimpleGlobalHotkeyService_KeyEvent(object sender, SimpleGlobalHotkeyServiceEventArgs e)
        {
            HotkeyDisplay.HotkeySettingString = e.AsSettingString;

            if (e.KeyDown)
            {
                if (!Enum.IsDefined(typeof(PressingIssue.Services.Contracts.ModifierKeys), (int)e.Key))
                {
                    HotkeysAppSetting = e.AsSettingString;
                    DialogResult      = true;
                }
            }
        }
コード例 #3
0
        private void HotkeyServiceKeyEvent(object sender, SimpleGlobalHotkeyServiceEventArgs e)
        {
            string result = $" {(e.KeyDown ? "Down" : "Up")} Alt:{e.IsAltPressed} - Ctrl:{e.IsCtrlPressed} - Shift:{e.IsShiftPressed} - Win:{e.IsWinPressed} - Key:{e.Key}";

            this.ShownKeys.Content = result;
        }