Esempio n. 1
0
        private void inputContext_KeyPressed(object sender, KeyboardInputEventArgs e)
        {
            if (currentlyFocusedElement == null)
            {
                return;
            }

            if (currentlyFocusedElement.IsFocused)
            {
                if (currentlyFocusedElement is TextBox)
                {
                    (currentlyFocusedElement as TextBox).UpdateText(e);
                }
                else if (currentlyFocusedElement is ChatBox)
                {
                    (currentlyFocusedElement as ChatBox).UpdateText(e);
                }
            }
        }
Esempio n. 2
0
        private void keyboardBuffer_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (KeyPressed != null)
            {
                var args = new KeyboardInputEventArgs
                {
                    Value = e.KeyChar,
                    IsShiftDown = keyboardBuffer.IsShiftDown,
                    IsControlDown = keyboardBuffer.IsControlDown
                };

                KeyPressed(this, args);
            }
        }
Esempio n. 3
0
        public void UpdateText(KeyboardInputEventArgs args)
        {
            if (args.Value == (int)Keys.Enter)
            {
                for (int i = numberOfLines - 1; i > 0; i--)
                {
                    textBlocks[i].Text = textBlocks[i - 1].Text;
                }

                string time = DateTime.Now.Hour.ToString() + ":" +
                              DateTime.Now.Minute.ToString() + " - ";

                // Add text to the queue
                textHistory.Enqueue(time + textBox.Text);

                // Set the latest textBlock to inputed text
                textBlocks[0].Text = time + textBox.Text;

                // Clear input-field and reset caret index
                textBox.Text = "";
                textBox.SetCaretIndex(0);
            }
            else
            {
                textBox.UpdateText(args);
            }
        }
Esempio n. 4
0
        private void keyboardBuffer_KeyDown(object sender, KeyEventArgs e)
        {
            if (KeyPressed != null)
            {
                var args = new KeyboardInputEventArgs
                {
                    IsShiftDown = keyboardBuffer.IsShiftDown,
                    IsControlDown = keyboardBuffer.IsControlDown
                };

                switch ((Keys)e.KeyValue)
                {
                    case Keys.Home:
                    case Keys.End:
                    case Keys.Up:
                    case Keys.Down:
                    case Keys.Left:
                    case Keys.Right:
                    case Keys.Delete:
                    case Keys.LeftShift:
                    case Keys.RightShift:
                    case Keys.LeftControl:
                    case Keys.RightControl:
                        args.Key = (Keys)e.KeyValue;
                        break;

                    default:
                        return;
                }

                KeyPressed(this, args);
            }
        }