コード例 #1
0
 private void TextBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
 {
     if (e.Key == System.Windows.Input.Key.Enter)
     {
         EnterKeyPressed?.Invoke(this, EventArgs.Empty);
     }
 }
コード例 #2
0
 private void TextBox1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         EnterKeyPressed?.Invoke(this, EventArgs.Empty);
     }
 }
コード例 #3
0
 // event raised when a key is pressed while the player name textbox has focus
 // (only watching for Enter being hit to raise custom EnterKeyPressed event)
 private void PlayerNameTextBox_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)Keys.Return)                 // if Enter key is hit
     {
         EnterKeyPressed?.Invoke(this, new EventArgs()); // call event handler if defined
         e.Handled = true;                               // suppress the "ding" error sound when hitting enter in a non-multiline textbox
     }
 }
コード例 #4
0
 protected override bool ProcessDialogKey(Keys keyData)
 {
     if (keyData == Keys.Enter)
     {
         EnterKeyPressed?.Invoke(this, EventArgs.Empty);
         return(true);
     }
     return(base.ProcessDialogKey(keyData));
 }
コード例 #5
0
 private void TextBox_OnKeyUp(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Escape)
     {
         TextBox.Clear();
     }
     if (e.Key == Key.Enter)
     {
         EnterKeyPressed?.Invoke(null, null);
     }
 }
コード例 #6
0
        private void CwOnCharacterReceived(CoreWindow sender, CharacterReceivedEventArgs args)
        {
            //if (!focused) return;

            var c = Convert.ToChar(args.KeyCode);

            if (MapToDvorak)
            {
                c = DvorakConverter.Convert(c);
            }

            if (char.IsLetter(c))
            {
                var bc = new BufferCharacter
                {
                    Character = c.ToString()
                };

                if (Buffer.Count < WordToMatch.Length)
                {
                    bc.CharacterToMatch = WordToMatch[Buffer.Count].ToString();
                }

                Buffer.Add(bc);
                Text += c;
                TextChanged?.Invoke(this, new EventArgs());
            }
            else if (c == '\b')
            {
                if (Buffer.Any())
                {
                    Buffer.Remove(Buffer.Last());
                }
                if (!string.IsNullOrEmpty(Text))
                {
                    if (Text.Length > 0)
                    {
                        Text = Text.Substring(0, Text.Length - 1);
                        TextChanged?.Invoke(this, new EventArgs());
                    }
                }
            }
            else if (c == '\r')
            {
                EnterKeyPressed?.Invoke(this, new EventArgs());
            }
            else if (c == ' ')
            {
                SpaceKeyPressed?.Invoke(this, new EventArgs());
            }
        }
コード例 #7
0
 protected override void OnKeyDown(KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter && e.Control)
     {
         EnterAndControlKeyPressed?.Invoke();
         e.SuppressKeyPress = true;
         e.Handled          = true;
     }
     else if (e.KeyCode == Keys.Enter)
     {
         EnterKeyPressed?.Invoke();
         e.SuppressKeyPress = true;
         e.Handled          = true;
     }
     else
     {
         base.OnKeyDown(e);
     }
 }
コード例 #8
0
 public void Selecter(int height)
 {
     while (true)
     {
         Console.SetCursorPosition(2, height + 1);
         ConsoleKeyInfo keyInfo = Console.ReadKey(true);
         if (keyInfo.Key == ConsoleKey.DownArrow)
         {
             ArrowDownKeyPressed?.Invoke();
         }
         else if (keyInfo.Key == ConsoleKey.UpArrow)
         {
             ArrowUpKeyPressed?.Invoke();
         }
         else if (keyInfo.Key == ConsoleKey.Enter)
         {
             EnterKeyPressed?.Invoke();
         }
         else if (keyInfo.Key == ConsoleKey.Escape)
         {
             EscapeKeyPressed?.Invoke();
         }
         else if (keyInfo.Key == ConsoleKey.F2)
         {
             F2KeyPressed?.Invoke();
         }
         else if (keyInfo.Key == ConsoleKey.F3)
         {
             F3KeyPressed?.Invoke();
         }
         else if (keyInfo.Key == ConsoleKey.F4)
         {
             F4KeyPressed?.Invoke();
         }
         else if (keyInfo.Key == ConsoleKey.F5)
         {
             F5KeyPressed?.Invoke();
         }
         else if (keyInfo.Key == ConsoleKey.F6)
         {
             F6KeyPressed?.Invoke();
         }
         else if (keyInfo.Key == ConsoleKey.F7)
         {
             F7KeyPressed?.Invoke();
         }
         else if (keyInfo.Key == ConsoleKey.F8)
         {
             F8KeyPressed?.Invoke();
         }
         else if (keyInfo.Key == ConsoleKey.F9)
         {
             F9KeyPressed?.Invoke();
         }
         else if (keyInfo.Key == ConsoleKey.F10)
         {
             F10KeyPressed?.Invoke();
         }
         else if (keyInfo.Key == ConsoleKey.Tab)
         {
             TabKeyPressed?.Invoke();
         }
     }
 }
コード例 #9
0
 protected virtual void OnEnterKeyPressed(EventArgs e)
 {
     EnterKeyPressed?.Invoke(this, e);
 }
コード例 #10
0
        private void OnKeyPressed(object sender, KeyboardEventArgs e)
        {
            KeyPressed?.Invoke(this, e);

            switch (e.Key)
            {
            case Keys.Enter:
                EnterKeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.Left:
                LeftKeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.Right:
                RightKeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.Up:
                UpKeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.Down:
                DownKeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.D0:
                D0KeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.D1:
                D1KeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.D2:
                D2KeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.D3:
                D3KeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.D4:
                D4KeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.D5:
                D5KeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.D6:
                D6KeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.D7:
                D7KeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.D8:
                D8KeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.D9:
                D9KeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.D:
                DKeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.E:
                EKeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.C:
                CKeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.U:
                UKeyPressed?.Invoke(this, new EventArgs());
                break;

            case Keys.I:
                IKeyPressed?.Invoke(this, new EventArgs());
                break;

            default: return;
            }
        }