コード例 #1
0
ファイル: FrmMain.cs プロジェクト: gaknoia/babbot
        private void commandPrompt1_Command(object sender, CommandEventArgs e)
        {
            string command = e.Command.ToLower();

            switch (command)
            {
                case "cls":
                    cmd.ClearMessages();
                    e.Cancel = true;
                    break;

                case "inject":
                    e.Message = InjectLUAHost();
                    break;

                case "exit":
                    Application.Exit();
                    break;

                case "kill":
                    Process[] processes = Process.GetProcessesByName("wow");
                    foreach (Process p in processes)
                    {
                        e.Message = string.Format("[{0}] WoW has been killed", p.Id);
                        p.Kill();
                    }
                    IsInjected = false;
                    break;

                default:
                    e.Message = string.Format(" invalid command {0}", e.Command);
                    break;
            }
        }
コード例 #2
0
ファイル: Prompt.cs プロジェクト: gaknoia/babbot
        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;
            }
        }
コード例 #3
0
ファイル: Prompt.cs プロジェクト: gaknoia/babbot
 protected virtual void OnCommand(CommandEventArgs e)
 {
     if (Command != null)
         Command(this, e);
 }