aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSyndamia <kami02882@gmail.com>2019-11-16 19:42:32 +0200
committerSyndamia <kami02882@gmail.com>2019-11-16 19:42:32 +0200
commit9e0c390b0b6580cde9eae1d791f0acb63be680cc (patch)
tree427f1ebd4408e44a25416fb680bcc521ec3696ac
parent78cc8af9f418e9cacccc945186a242f02e9e049e (diff)
downloadShower-9e0c390b0b6580cde9eae1d791f0acb63be680cc.tar
Shower-9e0c390b0b6580cde9eae1d791f0acb63be680cc.tar.gz
Shower-9e0c390b0b6580cde9eae1d791f0acb63be680cc.zip
Added a indication of when a ping is occuring in Pinger program
-rw-r--r--Pinger/Pinger/Form1.Designer.cs57
-rw-r--r--Pinger/Pinger/Form1.cs19
2 files changed, 45 insertions, 31 deletions
diff --git a/Pinger/Pinger/Form1.Designer.cs b/Pinger/Pinger/Form1.Designer.cs
index 1d8c034..6ac811d 100644
--- a/Pinger/Pinger/Form1.Designer.cs
+++ b/Pinger/Pinger/Form1.Designer.cs
@@ -23,22 +23,23 @@
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
this.lblPing = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.lblPingStatus = new System.Windows.Forms.Label();
this.lblErrorMessage = new System.Windows.Forms.Label();
this.cbPingAddress = new System.Windows.Forms.ComboBox();
+ this.lblNotifyPingEvent = new System.Windows.Forms.Label();
this.SuspendLayout();
//
- // label1
+ // lblPing
//
- this.label1.AutoSize = true;
- this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.label1.Location = new System.Drawing.Point(31, 57);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(44, 20);
- this.label1.TabIndex = 0;
- this.label1.Text = "Ping:";
+ this.lblPing.AutoSize = true;
+ this.lblPing.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.lblPing.Location = new System.Drawing.Point(31, 57);
+ this.lblPing.Name = "lblPing";
+ this.lblPing.Size = new System.Drawing.Size(44, 20);
+ this.lblPing.TabIndex = 0;
+ this.lblPing.Text = "Ping:";
//
// label2
//
@@ -49,16 +50,16 @@
this.label2.TabIndex = 2;
this.label2.Text = "Address to ping:";
//
- // lblPing
+ // lblPingStatus
//
- this.lblPing.BackColor = System.Drawing.Color.Red;
- this.lblPing.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.lblPing.Location = new System.Drawing.Point(135, 45);
- this.lblPing.Name = "lblPing";
- this.lblPing.Size = new System.Drawing.Size(125, 40);
- this.lblPing.TabIndex = 3;
- this.lblPing.Text = "-1";
- this.lblPing.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.lblPingStatus.BackColor = System.Drawing.Color.Red;
+ this.lblPingStatus.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.lblPingStatus.Location = new System.Drawing.Point(135, 45);
+ this.lblPingStatus.Name = "lblPingStatus";
+ this.lblPingStatus.Size = new System.Drawing.Size(125, 40);
+ this.lblPingStatus.TabIndex = 3;
+ this.lblPingStatus.Text = "-1";
+ this.lblPingStatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblErrorMessage
//
@@ -85,6 +86,14 @@
this.cbPingAddress.TabIndex = 5;
this.cbPingAddress.Text = "8.8.8.8";
//
+ // lblNotifyPingEvent
+ //
+ this.lblNotifyPingEvent.BackColor = System.Drawing.Color.Black;
+ this.lblNotifyPingEvent.Location = new System.Drawing.Point(134, 44);
+ this.lblNotifyPingEvent.Name = "lblNotifyPingEvent";
+ this.lblNotifyPingEvent.Size = new System.Drawing.Size(127, 42);
+ this.lblNotifyPingEvent.TabIndex = 6;
+ //
// myNetForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -92,9 +101,10 @@
this.ClientSize = new System.Drawing.Size(289, 144);
this.Controls.Add(this.cbPingAddress);
this.Controls.Add(this.lblErrorMessage);
- this.Controls.Add(this.lblPing);
+ this.Controls.Add(this.lblPingStatus);
this.Controls.Add(this.label2);
- this.Controls.Add(this.label1);
+ this.Controls.Add(this.lblPing);
+ this.Controls.Add(this.lblNotifyPingEvent);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "myNetForm";
this.Text = "Pinger";
@@ -106,11 +116,12 @@
#endregion
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label lblPing;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label lblPingStatus;
private System.Windows.Forms.Label lblErrorMessage;
private System.Windows.Forms.ComboBox cbPingAddress;
+ private System.Windows.Forms.Label lblNotifyPingEvent;
}
}
diff --git a/Pinger/Pinger/Form1.cs b/Pinger/Pinger/Form1.cs
index 007bab2..5b4e89b 100644
--- a/Pinger/Pinger/Form1.cs
+++ b/Pinger/Pinger/Form1.cs
@@ -25,26 +25,29 @@ namespace Pinger {
PingReply pr;
while(true) {
+ lblNotifyPingEvent.Visible = true;
try {
pr = p.Send(cbPingAddress.Text);
lblErrorMessage.Text = "";
if (pr.Status == IPStatus.Success) {
- lblPing.Text = pr.RoundtripTime + "";
+ lblPingStatus.Text = pr.RoundtripTime + "";
- if (pr.RoundtripTime > 300) lblPing.BackColor = Color.Red;
- else if (pr.RoundtripTime > 100) lblPing.BackColor = Color.Orange;
- else if (pr.RoundtripTime > 10) lblPing.BackColor = Color.Yellow;
- else lblPing.BackColor = Color.LightGreen;
+ if (pr.RoundtripTime > 300) lblPingStatus.BackColor = Color.Red;
+ else if (pr.RoundtripTime > 100) lblPingStatus.BackColor = Color.Orange;
+ else if (pr.RoundtripTime > 10) lblPingStatus.BackColor = Color.Yellow;
+ else lblPingStatus.BackColor = Color.LightGreen;
}
else throw new Exception(pr.Status.ToString());
} catch (Exception ex) {
lblErrorMessage.Text = ex.Message;
- lblPing.BackColor = Color.Red;
- lblPing.Text = "-1";
+ lblPingStatus.BackColor = Color.Red;
+ lblPingStatus.Text = "-1";
}
- Thread.Sleep(1000);
+ Thread.Sleep(200);
+ lblNotifyPingEvent.Visible = false;
+ Thread.Sleep(800);
}
}