コード例 #1
0
 private void ImageQuizForm_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         EnterPressed?.Invoke(this, e);
     }
 }
コード例 #2
0
        private void Window_TextInput(object sender, TextInputEventArgs e)
        {
            if (state == State.FOCUSED)
            {
                switch ((int)e.Character)
                {
                case 8:
                    // BACKSPACE

                    if (builder.Length != 0)
                    {
                        builder.Remove(builder.Length - 1, 1);
                    }

                    break;

                case 13:
                    // ENTER

                    EnterPressed?.Invoke();
                    break;

                default:
                    if (Font.Characters.Contains(e.Character))
                    {
                        AppendText(e.Character);
                    }

                    break;
                }
            }
        }
コード例 #3
0
 private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         if ((e.Modifiers & InputModifiers.Shift) != InputModifiers.Shift && (e.Modifiers & InputModifiers.Control) != InputModifiers.Control)
         {
             EnterPressed?.Invoke(this, new EventArgs());
             e.Handled = true;
         }
         else
         {
             this.FindControl <InputTextBox>("commandBox").Height += 18;
         }
     }
     else if (e.Key == Key.Up && (this.FindControl <InputTextBox>("commandBox").Text == null || !this.FindControl <InputTextBox>("commandBox").Text.Contains("\n") || this.FindControl <InputTextBox>("commandBox").CaretIndex < this.FindControl <InputTextBox>("commandBox").Text.IndexOf("\n")))
     {
         historyIndex--;
         HistoryRequested?.Invoke(this, new HistoryRequestEventArgs(historyIndex, -1));
         e.Handled = true;
     }
     else if (e.Key == Key.Down && (this.FindControl <InputTextBox>("commandBox").Text == null || this.FindControl <InputTextBox>("commandBox").CaretIndex >= this.FindControl <InputTextBox>("commandBox").Text.LastIndexOf("\n")))
     {
         historyIndex = Math.Min(0, historyIndex + 1);
         HistoryRequested?.Invoke(this, new HistoryRequestEventArgs(historyIndex, +1));
         e.Handled = true;
     }
 }
コード例 #4
0
ファイル: InputManager.cs プロジェクト: RunawaySystems/Pong
        static Task ListenForInput()
        {
            while (true)
            {
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo keyInfo = Console.ReadKey(intercept: true);
                    switch (keyInfo.Key)
                    {
                    case ConsoleKey.W:
                    case ConsoleKey.UpArrow:
                        MovementInput?.Invoke(1f);
                        break;

                    case ConsoleKey.S:
                    case ConsoleKey.DownArrow:
                        MovementInput?.Invoke(-1f);
                        break;

                    case ConsoleKey.Enter:
                        EnterPressed?.Invoke();
                        break;
                    }
                }
            }
        }
コード例 #5
0
ファイル: ScreenKeyboard.cs プロジェクト: waldo2590/Rock
 /// <summary>
 /// When implemented by a class, enables a server control to process an event raised when a form is posted to the server.
 /// </summary>
 /// <param name="eventArgument">A <see cref="T:System.String" /> that represents an optional event argument to be passed to the event handler.</param>
 public void RaisePostBackEvent(string eventArgument)
 {
     if (eventArgument == "enter")
     {
         EnterPressed?.Invoke(this, new EventArgs());
     }
 }
コード例 #6
0
        public void Enter(KEY key)
        {
            var typedtext = key.kb.KeyboardText.text;

            EnterPressed?.Invoke(typedtext);
            key.kb.KeyboardText.text = "";
        }
コード例 #7
0
ファイル: MainWindow.xaml.cs プロジェクト: 0Dexter0/EM3
        private void TBInput_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                EnterPressed++;

                SpIndex.Children.Add(new TextBlock()
                {
                    Text                = EnterPressed.ToString(),
                    Foreground          = Brushes.White,
                    FontSize            = 15,
                    HorizontalAlignment = HorizontalAlignment.Center
                });

                AddLines();
                TbCommands.Focus();
                TbCommands.CaretIndex = TbCommands.Text.Length;
            }
            else if (e.Key == Key.Back)
            {
                int numLines = GetNumLines(TbCommands.Text);

                if (numLines < EnterPressed && EnterPressed > 1)
                {
                    SpIndex.Children.RemoveAt(--EnterPressed);
                }
            }
        }
コード例 #8
0
 private void ExpressionTextBox_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         EnterPressed?.Execute(null);
     }
 }
コード例 #9
0
ファイル: TextBox.cs プロジェクト: wdstest/SharpJS
        public TextBox()
        {
            var internalTextBox = new ExaPhaser.WebForms.Controls.TextBox();

            internalTextBox.EnterPressed += (s, e) => EnterPressed?.Invoke(this, EventArgs.Empty);
            internalTextBox.TextChanged  += (s, e) => TextChanged?.Invoke(this, EventArgs.Empty);
            WebFormsControl = internalTextBox;
        }
コード例 #10
0
ファイル: BoggleGame.cs プロジェクト: sorennelson/Boggle
 /// <summary>
 /// Play word button clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Enter_Click(object sender, EventArgs e)
 {
     if (ValidWord())
     {
         EnterPressed?.Invoke(wordTextBox.Text, EnterButton);
         wordTextBox.Text = "";
         this.Update();
     }
 }
コード例 #11
0
 public void Entered(EnterPressed enterPressedString, EnterPressed enterPressedNumber)
 {
     while (stringToIdentify != "1")
     {
         stringToIdentify = Console.ReadLine();
         if (stringToIdentify != "1")
         {
             enterPressedString.Invoke(stringToIdentify);
             enterPressedNumber.Invoke(stringToIdentify);
         }
     }
 }
コード例 #12
0
ファイル: EditorForm.cs プロジェクト: stefl0n/turrican2tools
 protected override bool ProcessCmdKey(ref Message m, Keys keyData)
 {
     if (keyData == Keys.Enter)
     {
         if (EnterPressed != null)
         {
             EnterPressed.Invoke(this, EventArgs.Empty);
             return(true);
         }
     }
     return(base.ProcessCmdKey(ref m, keyData));
 }
コード例 #13
0
ファイル: BoggleGame.cs プロジェクト: sorennelson/Boggle
 private void wordTextBox_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode.Equals(Keys.Enter))
     {
         if (ValidWord())
         {
             EnterPressed?.Invoke(wordTextBox.Text, EnterButton);
             wordTextBox.Text   = "";
             e.SuppressKeyPress = true;
             this.Update();
         }
     }
 }
コード例 #14
0
ファイル: GameKeyboard.cs プロジェクト: DerNooM/HostileSpace
        private void RenderWindow_TextEntered(object sender, TextEventArgs e)
        {
            //Console.WriteLine((int)e.Unicode[0]);

            if (e.Unicode[0] >= 48 && e.Unicode[0] <= 57)
            {
                KeyPressed?.Invoke(this, new KeyPressedArgs()
                {
                    Char = e.Unicode[0]
                });
            }
            else if (e.Unicode[0] >= 65 && e.Unicode[0] <= 90)
            {
                KeyPressed?.Invoke(this, new KeyPressedArgs()
                {
                    Char = e.Unicode[0]
                });
            }
            else if (e.Unicode[0] >= 97 && e.Unicode[0] <= 122)
            {
                KeyPressed?.Invoke(this, new KeyPressedArgs()
                {
                    Char = e.Unicode[0]
                });
            }

            if (e.Unicode[0] == 8)
            {
                BackspacePressed?.Invoke(this, null);
            }

            if (e.Unicode[0] == 9)
            {
                TabulatorPressed?.Invoke(this, null);
            }

            if (e.Unicode[0] == 13)
            {
                EnterPressed?.Invoke(this, null);
            }

            if (e.Unicode[0] == 27)
            {
                EscapePressed?.Invoke(this, null);
            }

            if (e.Unicode[0] == 32)
            {
                SpacePressed?.Invoke(this, null);
            }
        }
コード例 #15
0
        private void InnerTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (m_text.Length == 0)
            {
                InnerTextBox.Clear();
                InnerTextBox.ForeColor = ForeColor;
            }

            if (e.KeyCode == Keys.Enter)
            {
                if (EnterPressed != null)
                {
                    EnterPressed.Invoke(this, new EventArgs());
                }
            }
        }
コード例 #16
0
ファイル: TextField.cs プロジェクト: wert007/StealthyGame
 public TextField(Control parent) : base(parent)
 {
     textInput = new TextInput();
     textInput.EnterPressed += (txt) =>
     {
         EnterPressed?.Invoke(this, txt);
     };
     textInput.TextChanged += (txt) =>
     {
         TextChanged?.Invoke(this, txt);
     };
     textInput.TextTyped += (txt) =>
     {
         TextTyped?.Invoke(this, txt);
     };
     TextColor = Color.Black;
     Font      = Font.Arial11;
 }
コード例 #17
0
 private void HandleEnterButton()
 {
     if (UseEnterEvents && (EnterPressed != null))
     {
         EnterPressed.Invoke(this, new EventArgs());
     }
     else if (!UseEnterEvents)
     {
         if (CompactMode && (KeyboardContextMenu != null))
         {
             KeyboardContextMenu.IsOpen = false;
         }
         else if (!CompactMode)
         {
             Window.GetWindow(this).Close();
         }
     }
 }
コード例 #18
0
        protected internal virtual void HandleCommandPressed(KeyboardCommand command)
        {
            switch (command)
            {
            case KeyboardCommand.Backspace:
                if (Text.Length > 0 && CursorPosition > 0)
                {
                    CursorPosition--;
                    Text = Text.Remove(CursorPosition, 1);
                }
                break;

            case KeyboardCommand.Enter:
                EnterPressed?.Invoke(this, EventArgs.Empty);
                break;

            case KeyboardCommand.CursorLeft:
                if (CursorPosition > 0)
                {
                    CursorPosition--;
                }
                break;

            case KeyboardCommand.CursorRight:
                if (CursorPosition < Text.Length)
                {
                    CursorPosition++;
                }
                break;

            case KeyboardCommand.CursorUp:
                //TODO cursor up handling
                break;

            case KeyboardCommand.CursorDown:
                //TODO cursor down handling
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #19
0
ファイル: TextInput.cs プロジェクト: wert007/StealthyGame
        public void Add(TextInputEventArgs e)
        {
            textInputEventArgs.Add(e);
            if (e.Character != 13 &&
                e.Character != 8 &&
                e.Character >= 1 &&
                e.Character <= 31)
            {
                return;
            }
            switch (e.Character)
            {
            case '\b':                     //DEL
                if (TypedText.Length > 0)
                {
                    TypedText = TypedText.Remove(TypedText.Length - 1);
                }
                break;

            case '\t':                     //TAB
                int c = TypedText.Length % 4;
                TypedText += new string(' ', 4 - c);
                break;

            case '\r':                     //ENTER
                EnterPressed?.Invoke(TypedText);
                break;

            case '\u007f':                     //CTRL+DEL
                if (TypedText.Length > 0)
                {
                    TypedText = TypedText.Remove(Math.Max(TypedText.LastIndexOf(' '), 0));
                }
                break;

            default:
                TypedText += e.Character;
                break;
            }
            TextChanged?.Invoke(TypedText);
            TextTyped?.Invoke(TypedText);
        }
コード例 #20
0
ファイル: VirtualKeyboard.cs プロジェクト: Anttifer/Jypeli
        /// <summary>
        /// Käsittelee näppäimen painalluksen.
        /// </summary>
        /// <param name="key">Näppäin.</param>
        private void HandleKeyPress(VirtualKey key)
        {
            switch (key.Type)
            {
            case VirtualKeyType.Enter:
                EnterPressed?.Invoke(this, EventArgs.Empty);
                break;

            case VirtualKeyType.Backspace:
                BackspacePressed?.Invoke(this, EventArgs.Empty);
                break;

            case VirtualKeyType.Normal:
            default:
                InputEntered?.Invoke(this, new VirtualKeyboardInputEventArgs(key.Value));
                break;
            }

            key.Pressed();
        }
コード例 #21
0
        internal void ChangeText(string newText)
        {
            bool hadEnter = false;

            if (CurrentText.Length < 0 && CurrentText.Length < newText.Length)
            {
                if (newText.Substring(CurrentText.Length - 1).Contains("\r"))
                {
                    hadEnter = true;
                }
            }
            else
            {
                hadEnter = newText.Contains("\r");
            }

            bool wasEmpty = CurrentText == string.Empty;

            CurrentText = newText;

            if (TextLabel != null)
            {
                TextLabel.Text = GetCurrentText();
                TextLabel.ForceRefresh();
                SetCursorPostion();
            }

            if (wasEmpty)
            {
                SetupCursor();
            }

            TextChanged?.Invoke(this, this);
            if (hadEnter)
            {
                EnterPressed?.Invoke(this, this);
            }
        }
コード例 #22
0
ファイル: FTLRichTextBox.cs プロジェクト: mattire/FTLSnipTool
        protected override void OnKeyDown(KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Tab)
            {
                if (!e.Shift)
                {
                    TabForward?.Invoke(this, e);
                }
                else
                {
                    TabBackward?.Invoke(this, e);
                }

                //const string tabtospaces = "    ";
                //var hassel = this.SelectionLength > 0;
                //this.SelectedText = tabtospaces;
                //if (!hassel) this.SelectionStart += tabtospaces.Length;
                e.SuppressKeyPress = true;
                e.Handled          = true;
            }
            else if (e.KeyCode == Keys.Enter)
            {
                if (SuggestUIMngr.Current?.mListBox.Visible == true)
                {
                    SuggestUIMngr.Current.HandleSuggestBoxKeys(null, e);
                }
                else
                {
                    EnterPressed?.Invoke(this, e);
                }
                e.SuppressKeyPress = true;
            }
            else
            {
                base.OnKeyDown(e);
                RtbKeyDown?.Invoke(this, e);
            }
        }
コード例 #23
0
ファイル: MainWindow.xaml.cs プロジェクト: 0Dexter0/EM3
        private void TBInput_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.S)
            {
                TbCommands.IsEnabled = false;
                TbOut.IsEnabled      = false;
                TbRegA.IsEnabled     = false;
                TbRegB.IsEnabled     = false;
                TbOther.IsEnabled    = false;

                SaveFile();

                ShowSave();

                TbCommands.IsEnabled = true;
                TbOut.IsEnabled      = true;
                TbRegA.IsEnabled     = true;
                TbRegB.IsEnabled     = true;
                TbOther.IsEnabled    = true;
            }

            if (e.Key == Key.Return)
            {
                EnterPressed++;
                TbInfo.Text = EnterPressed.ToString();
            }

            if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.O)
            {
                MIOpen_OnClick(null, null);
            }

            if (e.Key == Key.F5)
            {
                MiStart.Command.Execute(null);
            }
        }
コード例 #24
0
        private void OnEnterButtonPressed()
        {
            ContextMenu contextMenu = NumberEntryContextMenu;

            if (contextMenu != null)
            {
                contextMenu.IsOpen = false;
            }
            if (FireEventOnEnter)
            {
                if (EnterPressed != null)
                {
                    EnterPressed.Invoke(this, new EventArgs());
                }
                else if (!CompactMode)
                {
                    Window.GetWindow(this).Close();
                }
                else
                {
                    contextMenu.IsOpen = false;
                }
            }
        }
コード例 #25
0
        public void Start()
        {
            Task.Run(async() =>
            {
                ISenseHat senseHat = await SenseHatFactory.GetSenseHat();

                while (true)
                {
                    if (senseHat.Joystick.Update())
                    {
                        if (senseHat.Joystick.LeftKey == KeyState.Pressed)
                        {
                            LeftPressed?.Invoke(this, EventArgs.Empty);
                        }
                        else if (senseHat.Joystick.RightKey == KeyState.Pressed)
                        {
                            RightPressed?.Invoke(this, EventArgs.Empty);
                        }
                        else if (senseHat.Joystick.UpKey == KeyState.Pressed)
                        {
                            UpPressed?.Invoke(this, EventArgs.Empty);
                        }
                        else if (senseHat.Joystick.DownKey == KeyState.Pressed)
                        {
                            DownPressed?.Invoke(this, EventArgs.Empty);
                        }
                        else if (senseHat.Joystick.EnterKey == KeyState.Pressed)
                        {
                            EnterPressed?.Invoke(this, EventArgs.Empty);
                        }
                    }

                    await Task.Delay(TimeSpan.FromMilliseconds(2));
                }
            });
        }
コード例 #26
0
 private void internalTextEditWidget_EnterPressed(object sender, KeyEventArgs keyEvent)
 {
     EnterPressed?.Invoke(this, keyEvent);
 }
コード例 #27
0
 public void PressEnter()
 {
     EnterPressed?.Invoke(this, new EventArgs());
 }
コード例 #28
0
ファイル: LoginForm.cs プロジェクト: bburhans/vtank
 protected virtual void OnEnterPressed(TomShane.Neoforce.Controls.EventArgs e)
 {
     EnterPressed.Invoke(this, e);
     LoginForm.username = Username;
 }
コード例 #29
0
ファイル: UIInputBox.cs プロジェクト: BlackCoyote/Voxalia
 protected override void Tick(double delta)
 {
     if (MDown)
     {
         AdjustMax();
     }
     if (Selected)
     {
         if (MinCursor > MaxCursor)
         {
             int min = MinCursor;
             MinCursor = MaxCursor;
             MaxCursor = min;
         }
         bool            modified = false;
         KeyHandlerState khs      = KeyHandler.GetKBState();
         if (khs.Escaped)
         {
             TriedToEscape = true;
         }
         if (khs.InitBS > 0)
         {
             int end;
             if (MaxCursor > MinCursor)
             {
                 khs.InitBS--;
             }
             if (khs.InitBS > 0)
             {
                 end = MinCursor - Math.Min(khs.InitBS, MinCursor);
             }
             else
             {
                 end = MinCursor;
             }
             Text      = Text.Substring(0, end) + Text.Substring(MaxCursor);
             MinCursor = end;
             MaxCursor = end;
             modified  = true;
         }
         if (khs.KeyboardString.Length > 0)
         {
             Text      = Text.Substring(0, MinCursor) + khs.KeyboardString + Text.Substring(MaxCursor);
             MinCursor = MinCursor + khs.KeyboardString.Length;
             MaxCursor = MinCursor;
             modified  = true;
         }
         if (!MultiLine && Text.Contains('\n'))
         {
             Text = Text.Substring(0, Text.IndexOf('\n'));
             if (MaxCursor > Text.Length)
             {
                 MaxCursor = Text.Length;
                 if (MinCursor > MaxCursor)
                 {
                     MinCursor = MaxCursor;
                 }
             }
             modified = true;
             EnterPressed?.Invoke();
         }
         if (modified && TextModified != null)
         {
             TextModified.Invoke(this, null);
         }
     }
 }
コード例 #30
0
 /// <summary>
 /// Invokes the EnterPressed event.
 /// </summary>
 protected virtual void OnEnterPressed()
 => EnterPressed?.Invoke();