Ejemplo n.º 1
0
 protected virtual void OnParameterEntered(ParameterEnteredEventArgs e)
 {
     if (ParameterEntered != null)
     {
         ParameterEntered(this, e);
     }
 }
Ejemplo n.º 2
0
        private void txtInput_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Return)
            {
                e.Handled = true;
                return;
            }

            if (e.KeyChar == (char)Keys.Back)
            {
                // Hide tooltip if character to be deleted is a delimiter
                if (txtInput.Text.Length > 0)
                {
                    char del = txtInput.Text[txtInput.Text.Length - 1];
                    foreach (char ch in delimiters)
                    {
                        if (ch == del)
                        {
                            bool flag = true;
                            // Check if previous character is delimiter
                            if (txtInput.Text.Length > 1)
                            {
                                char temp = txtInput.Text[txtInput.Text.Length - 2];
                                foreach (char c in delimiters)
                                {
                                    if (c == temp)
                                    {
                                        flag = false;
                                        break;
                                    }
                                }
                            }

                            if (flag == true)
                            {
                                HideToolTip();
                            }
                            break;
                        }
                    }
                }
                return;
            }

            // Fire the ParameterEntered event
            bool paramFlag = false;

            foreach (char ch in delimiters)
            {
                if (e.KeyChar == ch)
                {
                    paramFlag = true;
                    break;
                }
            }

            if (paramFlag == true)
            {
                ParameterEnteredEventArgs parameterEnteredArgs = new ParameterEnteredEventArgs(txtInput.Text, ParseInput());
                OnParameterEntered(parameterEnteredArgs);

                if (parameterEnteredArgs.ToolTip != "")
                {
                    HideToolTip();
                    ShowToolTip(parameterEnteredArgs.ToolTip);
                }
            }
        }
Ejemplo n.º 3
0
        private void txtInput_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Return)
            {
                if (txtInput.Text != "" && IgnoreBlankCommands)
                {
                    SuspendLayout();

                    string prevPrompt      = lblPrompt.Text;
                    Color  prevPromptColor = PromptColor;
                    // Raise the parameter entered event
                    ParameterEnteredEventArgs parameterEnteredArgs = new ParameterEnteredEventArgs(txtInput.Text, ParseInput(), true);
                    OnParameterEntered(parameterEnteredArgs);

                    // Raise the command event
                    CommandEventArgs args = new CommandEventArgs(txtInput.Text, ParseInput());
                    OnCommand(args);

                    if (args.Cancel == false)
                    {
                        //if (rtbMessages.Lines.Length > 0)
                        //    rtbMessages.AppendText("\r\n");

                        //AddCommand(prevPrompt, prevPromptColor, txtInput.Text);

                        if (args.Message != "")
                        {
                            AddMessage(args.Message);
                        }

                        rtbMessages.ScrollToCaret();
                        prevMessages.Add(txtInput.Text);
                        if (autoCompleteStore == true && args.Record == true)
                        {
                            txtInput.AutoCompleteCustomSource.Add(txtInput.Text);
                        }

                        currentLine = prevMessages.Count - 1;
                    }

                    txtInput.Text = "";
                    ResumeLayout();
                }
                e.Handled = true;
                HideToolTip();
                return;
            }

            if (e.KeyCode == Keys.Up)
            {
                if (currentLine >= 0 && prevMessages.Count > 0)
                {
                    txtInput.Text            = prevMessages[currentLine].ToString();
                    txtInput.SelectionLength = 0;
                    txtInput.SelectionStart  = txtInput.Text.Length;

                    currentLine--;
                }

                e.Handled = true;
                HideToolTip();
                return;
            }

            if (e.KeyCode == Keys.Down)
            {
                if (currentLine < prevMessages.Count - 2)
                {
                    currentLine++;

                    txtInput.Text            = prevMessages[currentLine + 1].ToString();
                    txtInput.SelectionLength = 0;
                    txtInput.SelectionStart  = txtInput.Text.Length;
                }

                e.Handled = true;
                HideToolTip();
                return;
            }

            if (e.KeyCode == Keys.Escape)
            {
                if (txtInput.SelectionLength > 0 && txtInput.AutoCompleteMode != AutoCompleteMode.None)
                {
                    txtInput.Text           = txtInput.Text.Substring(0, txtInput.SelectionStart);
                    txtInput.SelectionStart = txtInput.Text.Length;
                }
                else
                {
                    if (toolTipCommand.Active == false && cancelOnEsc == true)
                    {
                        txtInput.Text = "";
                    }
                }
                HideToolTip();
                e.Handled = true;
                return;
            }
        }