Beispiel #1
0
        private void MenuItemHelp_Click(object sender, EventArgs e)
        {
            // put the line into an arguments array
            string[] args = new string[1];
            args[0] = "/Help";

            VDeskTool.CVDT program = new VDeskTool.CVDT();
            richTextBox1.Text = program.VDTRun(args);

            // display the form with the output
            this.WindowState = FormWindowState.Normal;
            Show();
        }
Beispiel #2
0
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (textBox1.Lines.Count() > 1)
            {
                string command = textBox1.Lines[0];

                richTextBox1.Text += "Input:  " + command + "\n";
                textBox1.Text      = "";


                // put the line into an arguments array
                string[] args = command.Split(' ');

                VDeskTool.CVDT program = new VDeskTool.CVDT();
                richTextBox1.Text += program.VDTRun(args);

                // set the caret to the end
                richTextBox1.SelectionStart = richTextBox1.Text.Length;
                // scroll to the caret
                richTextBox1.ScrollToCaret();
            }
        }
Beispiel #3
0
        private void MenuItemLoadScript_Click(object sender, EventArgs e)
        {
            System.IO.Stream stream          = null;
            OpenFileDialog   openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = @"c:\";
            openFileDialog1.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 2;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((stream = openFileDialog1.OpenFile()) != null)
                    {
                        System.IO.StreamReader streamReader = new System.IO.StreamReader(stream);
                        string        line = "";
                        List <string> list = new List <string>();

                        // empty richTextBox1
                        richTextBox1.Text = "";

                        // get the first line
                        line = streamReader.ReadLine();

                        // process the line
                        while (line != null && line.Length > 0)
                        {
                            // add the line
                            list.Add(line);

                            // get the next line
                            line = streamReader.ReadLine();
                        }

                        if (list.Count > 0)
                        {
                            // load the arguments
                            string[] args = new string[list.Count];
                            for (int i = 0; i < list.Count; i++)
                            {
                                args[i] = list[i];
                            }

                            // run the script and save the output
                            VDeskTool.CVDT program = new VDeskTool.CVDT();
                            richTextBox1.Text = program.VDTRun(args);

                            // display the form with the output
                            this.WindowState = FormWindowState.Normal;
                            Show();
                        }
                        else
                        {
                            // something is wrong, show them the help text
                            MenuItemHelp_Click(sender, e);
                        }
                    }
                }
                catch (Exception ex)
                {
                    string text    = "There was a problem opening or running the script. Original error:\n" + ex.Message;
                    string caption = "You're exceptional!";

                    MessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }