public LogEntryTextBoxController(LogEntryInputParser inputParser, IAutoFillListBoxController autoFillListBoxController, IHotKeyState initialHotKeyState)
 {
     _inputParser = inputParser;
     _autoFillListBoxController = autoFillListBoxController;
     _initialHotKeyState        = initialHotKeyState;
     _currentHotKeyState        = initialHotKeyState;
 }
        private void TextBoxKeyDown(object sender, KeyEventArgs e)
        {
            var hotKeyResult = _currentHotKeyState.GetHotKeyResult(_logEntryTextBox.Text, e);

            _currentHotKeyState = hotKeyResult.NewHotKeyState;
            if (!string.IsNullOrEmpty(hotKeyResult.TextResult))
            {
                _logEntryTextBox.Text += hotKeyResult.TextResult;
                MoveTextBoxCursorToEndOfText();
                e.Handled = e.SuppressKeyPress = true;
                return;
            }

            // Key @ is pressed. REMINDER! Duplicate knowledge, because @ is also hardcoded in LogEntryInputParser as special char for label.
            // An alternative is unknown to me how to make the below key configuration configurable.
            if (e.Shift && e.KeyCode == Keys.D2)
            {
                _autoFillListBoxController.DoAutoFillLabels();
                DetermineTextColor();
                return;
            }

            // Key ! is pressed. REMINDER! Duplicate knowledge, because ! is also hardcoded in LogEntryInputParser as special char for activity.
            // An alternative is unknown to me how to make the below key configuration configurable.
            if (e.Shift && e.KeyCode == Keys.D1)
            {
                _autoFillListBoxController.DoAutoFillActivities();
                DetermineTextColor();
                return;
            }

            if (e.KeyCode != Keys.Enter)
            {
                return;
            }

            if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab)
            {
                e.Handled = e.SuppressKeyPress = true;
            }
        }
Example #3
0
 public HotKeyResult(IHotKeyState newHotKeyState, string textResult)
 {
     NewHotKeyState = newHotKeyState;
     TextResult     = textResult;
 }
 private void ResetHotKeyState()
 {
     _currentHotKeyState = _initialHotKeyState;
 }