jonassvensson4

Untitled

Apr 18th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.43 KB | None | 0 0
  1. Ping ping = new Ping();
  2.  
  3. //Router  0
  4.  
  5. //Ping the Ethernet port
  6. PingReply pingresult = ping.Send(textBoxRouter0.Text, timeout, buffer, options);
  7.  
  8. //If it's a success then..
  9. if (pingresult.Status.ToString() == "Success")
  10. {
  11.     //Change the picture of the router to a green one
  12.     pictureBoxRouter0.Image = Properties.Resources.router_online;
  13.  
  14.     //Ping the Serial port
  15.     PingReply serialAB1 = ping.Send("192.168." + textBoxSerialAB.Text + ".2", timeout);
  16.  
  17.     //If it's a success or a failure, set the status of the port..
  18.     if (serialAB1.Status.ToString() == "Success") { _statusAB1 = " | UP"; } else { _statusAB1 = " | DOWN"; }
  19.  
  20.     //Set the ToolTip text based on the results
  21.     toolTip0.SetToolTip(pictureBoxRouter0, "Ethernet: " + textBoxRouter0.Text + " | UP" + Environment.NewLine + "Serial 0: Not needed" + Environment.NewLine + "Serial 1: " + "192.168." + textBoxSerialAB.Text + ".1" + _statusAB1);
  22.  
  23.     //Print out some basic information in the outputbox
  24.     richTextBoxOutput.Text += "-------------------------------------------";
  25.     richTextBoxOutput.Text += Environment.NewLine + "ROUTER - A";
  26.     richTextBoxOutput.Text += Environment.NewLine;
  27.     richTextBoxOutput.Text += Environment.NewLine + "Ethernet: " + pingresult.Address.ToString();
  28.     richTextBoxOutput.Text += Environment.NewLine + "Serial 0: " + "Not needed";
  29.     richTextBoxOutput.Text += Environment.NewLine + "Serial 1: " + "192.168." + textBoxSerialAB.Text + ".1";
  30.     richTextBoxOutput.Text += Environment.NewLine;
  31.     richTextBoxOutput.Text += Environment.NewLine + "Response time: " + pingresult.RoundtripTime + "ms";
  32.     richTextBoxOutput.Text += Environment.NewLine + "-------------------------------------------";
  33. }
  34. //If it's a failure then..
  35. else
  36. {
  37.     //Change the picture of the router to a red one
  38.     pictureBoxRouter0.Image = Properties.Resources.router_offline;
  39.  
  40.     //Ping the Serial port
  41.     PingReply serialAB1 = ping.Send("192.168." + textBoxSerialAB.Text + ".2", timeout);
  42.  
  43.     //If it's a success or a failure, set the status of the port..
  44.     if (serialAB1.Status.ToString() == "Success") { _statusAB1 = " | UP"; } else { _statusAB1 = " | DOWN"; }
  45.  
  46.     //Set the ToolTip text based on the results
  47.     toolTip0.SetToolTip(pictureBoxRouter0, "Ethernet: " + textBoxRouter0.Text + " | DOWN" + Environment.NewLine + "Serial 0: " + "Not needed" + Environment.NewLine + "Serial 1: " + "192.168." + textBoxSerialAB.Text + ".1" + _statusAB1);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment