Example #1
0
 public void Stop()
 {
     Running = false;
     SetStartButtonText("Start");
     if (this.Worker != null)
     {
         this.Worker.Join();
         this.Worker = null;
     }
     CommandsDisplay.Hide();
     CommandsInput.Show();
 }
Example #2
0
 public void Start()
 {
     if (CommandsInput.TextLength > 1)
     {
         Running = true;
         SetStartButtonText("Stop");
         this.Worker = new Thread(new ThreadStart(this.ExecuteCommands));
         this.Worker.IsBackground = true;
         this.Worker.Start();
         CommandsInput.Hide();
         CommandsDisplay.Show();
     }
 }
Example #3
0
 private void ExecuteCommands()
 {
     while (Running)
     {
         int currentline = 0;
         foreach (string Line in Commands)
         {
             if (!this.Launcher.PerformanceMode.Checked)
             {
                 this.BeginInvoke(new MethodInvoker(delegate()
                 {
                     CommandsDisplay.Clear();
                     currentline++;
                     int currentInstruction = 0;
                     foreach (string instruction in Commands)
                     {
                         currentInstruction++;
                         if (currentline == currentInstruction)
                         {
                             int from = this.CommandsDisplay.TextLength;
                             this.CommandsDisplay.AppendText(instruction);
                             int to = this.CommandsDisplay.TextLength;
                             this.CommandsDisplay.Select(from, to);
                             this.CommandsDisplay.SelectionColor = Color.Red;
                             this.CommandsDisplay.ScrollToCaret();
                             this.CommandsDisplay.Select(0, 0);
                         }
                         else
                         {
                             this.CommandsDisplay.AppendText(instruction);
                         }
                         this.CommandsDisplay.AppendText("\n");
                     }
                 }));
             }
             string[] Arguments = Line.Trim().Split(' ');
             if (Arguments.Length > 0)
             {
                 if (Arguments[0] == "keypress")
                 {
                     Ditto.Commands.Keypress.Execute(this, Arguments);
                 }
                 else if (Arguments[0] == "rightclick")
                 {
                     Ditto.Commands.Rightclick.Execute(this, Arguments);
                 }
                 else if (Arguments[0] == "leftclick")
                 {
                     Ditto.Commands.Leftclick.Execute(this, Arguments);
                 }
                 else if (Arguments[0] == "wait")
                 {
                     Ditto.Commands.Wait.Execute(this, Arguments);
                 }
                 else if (Arguments[0] == "stop")
                 {
                     Ditto.Commands.Stop.Execute(this, Arguments);
                 }
                 else if (Arguments[0] == "start")
                 {
                     Ditto.Commands.Start.Execute(this, Arguments);
                 }
                 else if (Arguments[0] == "cursor")
                 {
                     Ditto.Commands.Cursor.Execute(this, Arguments);
                 }
                 else if (Arguments[0] == "pixel")
                 {
                     Ditto.Commands.Pixel.Execute(this, Arguments);
                 }
             }
             Thread.Sleep(100);
         }
     }
 }