Ejemplo n.º 1
0
        private void InputBox_PreviewKeyUp(object sender, KeyEventArgs e)
        {
            CommandLine commandLine;
            string      command;

            try
            {
                switch (e.Key)
                {
                case Key.Return:

                    command = CommandInputBox.Text;
                    if (command.Length == 0)
                    {
                        return;
                    }
                    for (var i = 0; i < _commandHistory.Count; i++)
                    {
                        if (command == (string)_commandHistory[i])
                        {
                            _commandHistory.RemoveAt(i);
                            i = _commandHistory.Count;
                        }
                    }
                    _commandHistory.Insert(0, command);
                    commandLine           = new CommandLine(command.Replace("\r\n", ""), _table);
                    command              += "\r\n[" + commandLine.Result + "]\r\n";
                    ImmediateWindow.Text += command;
                    ImmediateWindow.ScrollToEnd();
                    CommandInputBox.Text = "";
                    break;

                case Key.Up:
                    if (_historyCounter < _commandHistory.Count)
                    {
                        CommandInputBox.Text = _commandHistory[_historyCounter] as string;
                        _historyCounter++;
                    }
                    break;

                case Key.Down:
                    if (_historyCounter > 0)
                    {
                        _historyCounter--;
                        CommandInputBox.Text = _commandHistory[_historyCounter] as string;
                    }
                    break;

                default:

                    _historyCounter = 0;
                    break;
                }
                //If the count of Dots in the command line changed, perform a new search for members.
                //Note: the ComboBox is using the up/down key to search for the previous/next item.
                if (!(e.Key == Key.Down || e.Key == Key.Up))
                {
                    CheckDots();
                }
                OnError(null);
            }
            catch (Exception exception)
            {
                OnError(exception);
            }
        }