Beispiel #1
0
        private void ShowOnlyHotKey(object sender, HotKey hotKey)
        {
            TextBox textBox = (TextBox)sender;

            textBox.Text = ((Keys)hotKey.key).ToString();
        }
Beispiel #2
0
        private void ShowHotKey(object sender, KeyEventArgs e, ref HotKey hotKey)
        {
            TextBox textBox = (TextBox)sender;

            Keys modifiers = e.Modifiers;
            int  key       = e.KeyValue;

            //Left = 37,
            //Up = 38
            //Right = 39
            //Down = 40,

            //FuncKey 112 ~ 123

            if ((65 > key || 90 < key) && (37 > key || 40 < key) && (112 > key || 123 < key))
            {
                return;
            }

            if (modifiers == Keys.None)
            {
                return;
            }

            string text = "";

            if ((modifiers & Keys.Control) == Keys.Control)
            {
                text += "Ctrl + ";
            }

            if ((modifiers & Keys.Alt) == Keys.Alt)
            {
                text += "Alt + ";
            }

            if ((modifiers & Keys.Shift) == Keys.Shift)
            {
                text += "Shift + ";
            }

            if ((modifiers & Keys.LWin) == Keys.LWin)
            {
                text += "Windows + ";
            }

            if (65 <= key && 90 >= key)
            {
                text += (char)key;
            }
            else if (37 == key)
            {
                text += "←";
            }
            else if (38 == key)
            {
                text += "↑";
            }
            else if (39 == key)
            {
                text += "→";
            }
            else if (40 == key)
            {
                text += "↓";
            }
            else if (112 <= key && 123 >= key)
            {
                text += "F" + (key - 111).ToString();
            }

            textBox.Text = text;

            hotKey.modifiers = modifiers;
            hotKey.key       = key;
        }