Exemplo n.º 1
0
        private void connect_Click(object sender, EventArgs e)
        {
            ControllerInfoCollection controllers = scanner.Controllers;

            foreach (ControllerInfo info in controllers)
            {
                if (comboBox1.Text.Equals(info.ControllerName + " / " + info.IPAddress.ToString()))
                {
                    if (info.Availability == Availability.Available)
                    {
                        if (myRobot != null)
                        {
                            myRobot.Dispose(); // = LogOff
                            myRobot = null;
                        }
                        myRobot = new RobotClass(ControllerFactory.CreateFrom(info));
                        myRobot.StartRapidProgram();
                        myRobot.Controller.ConnectionChanged += new EventHandler <ConnectionChangedEventArgs>(ConnectionChanged);
                        connect_btn.BackColor = Color.Green;
                        break;
                    }
                }
                {
                    MessageBox.Show("Selected controller not available.");
                }
            }
            if (myRobot == null)
            {
                MessageBox.Show("Selected controller not available. (comboBox String != controller info)");
            }
        }
Exemplo n.º 2
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (myRobot != null)
     {
         myRobot.Dispose(); // = LogOff
         myRobot = null;
     }
 }