示例#1
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     if (Sensor1IpAddress.Text != null && NetworkUtilities.ValidateIPAddress(Sensor1IpAddress.Text, true))
     {
         NetworkUtilities.ParseAddressWithPort(Sensor1IpAddress.Text, out string ip, out int port);
         controller.ConnectToSensor1(ip, port, buffersize);
         Sensor1ConnectionStatus.BackColor = Color.Gold;
         Sensor1ConnectionStatus.Text      = "Testing...";
         Sensor1IpAddress.Enabled          = false;
     }
     if (Sensor2IpAddress.Text != null && NetworkUtilities.ValidateIPAddress(Sensor2IpAddress.Text, true))
     {
         NetworkUtilities.ParseAddressWithPort(Sensor2IpAddress.Text, out string ip, out int port);
         controller.ConnectToSensor2(ip, port, buffersize);
         Sensor2ConnectionStatus.BackColor = Color.Gold;
         Sensor2ConnectionStatus.Text      = "Testing...";
         Sensor2IpAddress.Enabled          = false;
     }
     if (Robot1IpAddress.Text != string.Empty && Robot2IpAddress.Text != string.Empty && RobotServerPort.Text != string.Empty)
     {
         if (NetworkUtilities.ValidateIPAddress(Robot1IpAddress.Text, false) && NetworkUtilities.ValidateIPAddress(Robot2IpAddress.Text, false))
         {
             int port = Convert.ToInt32(RobotServerPort.Text);
             controller.Robot1IpAddress = Robot1IpAddress.Text;
             controller.Robot2IpAddress = Robot2IpAddress.Text;
             controller.StartRobotServer(port, buffersize);
             RobotConnectionSave.BackColor = Color.OliveDrab;
             RobotConnectionSave.ForeColor = Color.White;
             RobotConnectionSave.Text      = "Server Started";
             RobotConnectionSave.Enabled   = false;
         }
     }
 }
示例#2
0
 private void Sensor2ConnectionStatus_Click(object sender, EventArgs e)
 {
     NetworkUtilities.ParseAddressWithPort(Sensor2IpAddress.Text, out string ip, out int port);
     controller.ConnectToSensor2(ip, port, buffersize);
     Sensor2ConnectionStatus.BackColor = Color.Gold;
     Sensor2ConnectionStatus.Text      = "Testing...";
     Sensor2IpAddress.Enabled          = false;
 }