Пример #1
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;
                }
            }
        }
Пример #2
0
        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;
                    }
                }
            }
        }
 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
 /// <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());
     }
 }
Пример #5
0
        public void Enter(KEY key)
        {
            var typedtext = key.kb.KeyboardText.text;

            EnterPressed?.Invoke(typedtext);
            key.kb.KeyboardText.text = "";
        }
Пример #6
0
 private void ImageQuizForm_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         EnterPressed?.Invoke(this, e);
     }
 }
Пример #7
0
        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;
        }
Пример #8
0
 /// <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();
     }
 }
Пример #9
0
 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));
 }
Пример #10
0
 public void Entered(EnterPressed enterPressedString, EnterPressed enterPressedNumber)
 {
     while (stringToIdentify != "1")
     {
         stringToIdentify = Console.ReadLine();
         if (stringToIdentify != "1")
         {
             enterPressedString.Invoke(stringToIdentify);
             enterPressedNumber.Invoke(stringToIdentify);
         }
     }
 }
Пример #11
0
 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();
         }
     }
 }
Пример #12
0
        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);
            }
        }
Пример #13
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());
                }
            }
        }
Пример #14
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();
         }
     }
 }
Пример #15
0
 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;
 }
Пример #16
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();
            }
        }
Пример #17
0
        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);
        }
Пример #18
0
        /// <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();
        }
Пример #19
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);
            }
        }
Пример #20
0
        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);
            }
        }
Пример #21
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;
                }
            }
        }
Пример #22
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));
                }
            });
        }
Пример #23
0
        private void SelectByKey(Keys keys, string keyInput = "", bool keepSelection = false)
        {
            int iRowBefore  = iRowKey;
            int iMenuBefore = iMenuKey;

            Menu         menu             = menus[iMenuKey];
            DataGridView dgv              = null;
            DataGridView dgvBefore        = null;
            Menu         menuFromSelected = null;
            string       textselected     = string.Empty;
            bool         isStillSelected  = IsAnyMenuSelectedByKey(ref dgv, ref menuFromSelected, ref textselected);

            if (isStillSelected)
            {
                if (keepSelection)
                {
                    // If current selection is still valid for this search then skip selecting different item
                    if (textselected.StartsWith(keyInput, true, CultureInfo.InvariantCulture))
                    {
                        return;
                    }
                }

                dgvBefore = dgv;
            }
            else
            {
                ResetSelectedByKey();
                menu = menus[iMenuKey];
                dgv  = menu.GetDataGridView();
            }

            bool toClear = false;

            switch (keys)
            {
            case Keys.Enter:
                if (iRowKey > -1 &&
                    dgv.Rows.Count > iRowKey)
                {
                    RowData trigger = (RowData)dgv.Rows[iRowKey].Cells[2].Value;
                    if (trigger.IsMenuOpen || !trigger.ContainsMenu)
                    {
                        trigger.MouseDown(dgv, null);
                        trigger.DoubleClick(
                            new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0));
                    }
                    else
                    {
                        RowDeselected(iRowBefore, dgvBefore);
                        SelectRow(dgv, iRowKey);
                        EnterPressed.Invoke(dgv, iRowKey);
                    }
                }

                break;

            case Keys.Up:
                if (SelectMatchedReverse(dgv, iRowKey) ||
                    SelectMatchedReverse(dgv, dgv.Rows.Count - 1))
                {
                    RowDeselected(iRowBefore, dgvBefore);
                    SelectRow(dgv, iRowKey);
                    toClear = true;
                }

                break;

            case Keys.Down:
                if (SelectMatched(dgv, iRowKey) ||
                    SelectMatched(dgv, 0))
                {
                    RowDeselected(iRowBefore, dgvBefore);
                    SelectRow(dgv, iRowKey);
                    toClear = true;
                }

                break;

            case Keys.Left:
                int iMenuKeyNext = iMenuKey + 1;
                if (isStillSelected)
                {
                    if (menuFromSelected != null &&
                        menuFromSelected == menus[iMenuKeyNext])
                    {
                        dgv = menuFromSelected.GetDataGridView();
                        if (dgv.Rows.Count > 0)
                        {
                            iMenuKey += 1;
                            iRowKey   = -1;
                            if (SelectMatched(dgv, iRowKey) ||
                                SelectMatched(dgv, 0))
                            {
                                RowDeselected(iRowBefore, dgvBefore);
                                SelectRow(dgv, iRowKey);
                                toClear = true;
                            }
                        }
                    }
                }
                else
                {
                    iRowKey  = -1;
                    iMenuKey = menus.Where(m => m != null).Count() - 1;
                    if (menus[iMenuKey] != null)
                    {
                        dgv = menus[iMenuKey].GetDataGridView();
                        if (SelectMatched(dgv, iRowKey) ||
                            SelectMatched(dgv, 0))
                        {
                            RowDeselected(iRowBefore, dgvBefore);
                            SelectRow(dgv, iRowKey);
                            toClear = true;
                        }
                    }
                }

                break;

            case Keys.Right:
                if (iMenuKey > 0)
                {
                    if (menus[iMenuKey - 1] != null)
                    {
                        iMenuKey -= 1;
                        iRowKey   = -1;
                        menu      = menus[iMenuKey];
                        dgv       = menu.GetDataGridView();
                        if (SelectMatched(dgv, dgv.SelectedRows[0].Index) ||
                            SelectMatched(dgv, 0))
                        {
                            RowDeselected(iRowBefore, dgvBefore);
                            SelectRow(dgv, iRowKey);
                            toClear = true;
                        }
                    }
                }
                else
                {
                    RowDeselected(iRowBefore, dgvBefore);
                    iMenuKey = 0;
                    iRowKey  = -1;
                    toClear  = true;
                    Cleared?.Invoke();
                }

                break;

            case Keys.Escape:
                RowDeselected(iRowBefore, dgvBefore);
                iMenuKey = 0;
                iRowKey  = -1;
                toClear  = true;
                ClosePressed?.Invoke();
                break;

            default:
                if (!string.IsNullOrEmpty(keyInput))
                {
                    if (SelectMatched(dgv, iRowKey, keyInput) ||
                        SelectMatched(dgv, 0, keyInput))
                    {
                        RowDeselected(iRowBefore, null);
                        SelectRow(dgv, iRowKey);
                        toClear = true;
                    }
                    else if (isStillSelected)
                    {
                        iRowKey = iRowBefore - 1;
                        if (SelectMatched(dgv, iRowKey, keyInput) ||
                            SelectMatched(dgv, 0, keyInput))
                        {
                            RowDeselected(iRowBefore, null);
                            SelectRow(dgv, iRowKey);
                        }
                        else
                        {
                            iRowKey = iRowBefore;
                        }
                    }
                }

                break;
            }

            if (isStillSelected && toClear)
            {
                ClearIsSelectedByKey(iMenuBefore, iRowBefore);
            }
        }
Пример #24
0
 private void internalTextEditWidget_EnterPressed(object sender, KeyEventArgs keyEvent)
 {
     EnterPressed?.Invoke(this, keyEvent);
 }
Пример #25
0
        protected virtual void OnEnterPressed(EventArgs e)
        {
            this.Focused = false;

            EnterPressed?.Invoke(this, e);
        }
Пример #26
0
 protected virtual void OnEnterPressed(TomShane.Neoforce.Controls.EventArgs e)
 {
     EnterPressed.Invoke(this, e);
 }
Пример #27
0
 public void PressEnter()
 {
     EnterPressed?.Invoke(this, new EventArgs());
 }
Пример #28
0
 protected virtual void OnEnterPressed(TomShane.Neoforce.Controls.EventArgs e)
 {
     EnterPressed.Invoke(this, e);
     LoginForm.username = Username;
 }
Пример #29
0
 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();