Example #1
0
        private void Commandlist_SelectedIndexChanged(object sender, EventArgs e)
        {
            Stream myStream = null;

            Byte[] buffer;
            string filename = "commands/";
            string str      = Commandlist.Items[Commandlist.SelectedIndex].ToString();

            string[] newstr = str.Split(' ');
            filename += newstr[0];
            filename += ".txt";
            try
            {
                myStream = File.OpenRead(filename);
                using (myStream)
                {
                    if (myStream.Length > 2 * 1024)
                    {
                        MessageBox.Show("文件有点大,换个小点的吧!");
                        myStream.Close();
                    }
                    buffer = new Byte[myStream.Length];
                    myStream.Read(buffer, 0, (int)myStream.Length);
                    str = System.Text.Encoding.Default.GetString(buffer);
                    string[] strarray = str.Split(' ');
                    str = String.Join(String.Empty, strarray);
                    CommandBox.Clear();
                    CommandBox.Text = str;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: 无法打开指定文件. Original error: " + ex.Message);
            }
        }
        private void CommandBox_KeyDown(object sender, KeyEventArgs e)
        {
            //Show command hints
            if (e.Key == Key.Tab)
            {
                //ServerProcess.StandardInput.Write(CommandBox.Text + Key.Tab);
            }

            //Send Command(s)
            if (e.Key == Key.Enter && ServerIsRunning)
            {
                string[] CommandsToSend = CommandBox.Text.Split(';');
                foreach (var item in CommandsToSend)
                {
                    ServerProcess.StandardInput.WriteLine(item.Trim());
                    CommandHistoryListBox.Items.Add(item.Trim());
                }
                CommandBox.Clear();
            }

            /*
             * if (e.Key == Key.Up) //Cycle through command history backwards
             * {
             *  CommandBox.Text = CommandHistoryListBox.Items.GetItemAt(CommandHistoryListBox.Items.Count - 1 - CommandHistoryOffset).ToString();
             * }
             *
             * if (e.Key == Key.Down) //Cycle through command history forwards
             * {
             *
             * }*/
        }
 private void CommandBox_MouseWheel(object sender, MouseWheelEventArgs e)
 {
     if (e.MiddleButton == MouseButtonState.Pressed)
     {
         CommandBox.Clear();
     }
 }
        private void SendCommandToPuppetMaster()
        {
            string cmd = CommandBox.Text;

            CommandBox.Clear();
            Log(">>> " + cmd);
            this.PuppetMaster.ParseCommand(cmd);
        }
 //Commands
 private void SendCommand_Click(object sender, RoutedEventArgs e)
 {
     string[] CommandsToSend = CommandBox.Text.Split(Convert.ToChar(";"));
     foreach (var item in CommandsToSend)
     {
         ServerProcess.StandardInput.WriteLine(item.Trim());
         CommandHistoryListBox.Items.Add(item.Trim());
     }
     CommandBox.Clear();
     //UpdateCommandHistory();
 }
Example #6
0
        private void LoadBtn_Click(object sender, EventArgs e)
        {
            string str;
            Stream myStream = null;

            openFileDialog.Filter      = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog.FilterIndex = 2;
            Byte[] buffer;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((myStream = openFileDialog.OpenFile()) != null)
                    {
                        using (myStream)
                        {
                            if (myStream.Length > 2 * 1024)
                            {
                                MessageBox.Show("文件有点大!");
                                myStream.Close();
                            }
                            buffer = new Byte[myStream.Length];
                            myStream.Read(buffer, 0, (int)myStream.Length);
                            str = System.Text.Encoding.Default.GetString(buffer);
                            //str.Replace(" ",String.Empty);
                            string[] newstr = str.Split(' ');
                            str = String.Join(String.Empty, newstr);
                            CommandBox.Clear();
                            CommandBox.Text = str;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: 无法打开指定文件. Original error: " + ex.Message);
                }
            }
        }
 private void SendBTN_Click(object sender, EventArgs e)
 {
     if (CommandTextBox.Text.ToLower() == "cmds")         //check if the user send cmds so we can display the commands
     {
         CommandBox.AppendText(Functions.TextToBox[0]);   //Append text to the command richtextbox
         CommandTextBox.Clear();                          //clear the command textbox
     }
     else if (CommandTextBox.Text.ToLower() == "credits") //check if the user send credits so we can display the credits
     {
         CommandBox.AppendText(Functions.TextToBox[1]);   //Append text to the command richtextbox
         CommandTextBox.Clear();                          //clear the command textbox
     }
     else if (CommandTextBox.Text.ToLower() == "clear")
     {
         CommandBox.Clear();
         CommandTextBox.Clear();
     }
     else
     {
         NamedPipes.CommandPipe(CommandTextBox.Text); //command pipe function to send the text in the command textbox
         CommandTextBox.Clear();                      //clear the command textbox
     }
 }
Example #8
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     GameConsole.Text += "\r\n" + _program.InputCommand(CommandBox.Text);
     CommandBox.Clear();
 }