-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: Settings & About GUI. Updated: Main GUI, API, README.
- Loading branch information
Ambratolm
authored and
Ambratolm
committed
Jun 10, 2021
1 parent
2f355da
commit f60ec62
Showing
46 changed files
with
2,205 additions
and
1,832 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace PingTesterAluminium | ||
{ | ||
public enum PingRating | ||
{ | ||
Unknown = 0, | ||
Amazing = 1, | ||
Excellent = 2, | ||
Good = 3, | ||
NotBad = 4, | ||
Bad = 5, | ||
Mediocre = 6, | ||
Poor = 7, | ||
Terrible = 8 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,78 @@ | ||
using System; | ||
using System.Drawing; | ||
using System.Net.NetworkInformation; | ||
using System.Net; | ||
|
||
namespace PingTesterAluminium | ||
{ | ||
public class PingResult | ||
{ | ||
public long Time { get; set; } | ||
public string Rating { get; set; } | ||
public Color Color { get; set; } | ||
public string Message { get; set; } | ||
public string Host { get; set; } | ||
public IPAddress Address { get; private set; } | ||
public Byte[] Buffer { get; private set; } | ||
public long Time { get; private set; } | ||
public IPStatus Status { get; private set; } | ||
public int Ttl { get; set; } | ||
public bool DontFragment { get; private set; } | ||
public PingRating Rating { get; private set; } | ||
public Color RatingColor { get; private set; } | ||
public Color StatusColor { get; private set; } | ||
public string ErrorMessage { get; private set; } | ||
public bool HasError { get; private set; } | ||
|
||
public PingResult(int time, string rating, Color color, string message, string host) | ||
public PingResult(PingReply reply = null) | ||
{ | ||
this.Time = time; | ||
this.Rating = rating; | ||
this.Color = color; | ||
this.Message = message; | ||
this.Host = host; | ||
if (reply == null) | ||
{ | ||
this.Time = -1; | ||
this.Status = IPStatus.Unknown; | ||
} | ||
else | ||
{ | ||
this.Address = reply.Address; | ||
this.Buffer = reply.Buffer; | ||
this.Time = reply.RoundtripTime; | ||
this.Status = reply.Status; | ||
this.Ttl = reply.Options.Ttl; | ||
this.DontFragment = reply.Options.DontFragment; | ||
} | ||
this.Rating = GetRating(this.Time); | ||
this.RatingColor = GetRatingColor(this.Time); | ||
this.StatusColor = GetStatusColor(this.Status); | ||
} | ||
|
||
public PingResult(string errorMessage) | ||
: this() | ||
{ | ||
this.ErrorMessage = errorMessage; | ||
this.HasError = true; | ||
} | ||
|
||
public static PingRating GetRating(long time = -1) | ||
{ | ||
if (time < 0) return PingRating.Unknown; | ||
if (time < 30) return PingRating.Amazing; | ||
if (time < 60) return PingRating.Excellent; | ||
if (time < 100) return PingRating.Good; | ||
if (time < 150) return PingRating.NotBad; | ||
if (time < 200) return PingRating.Bad; | ||
if (time < 250) return PingRating.Mediocre; | ||
if (time < 300) return PingRating.Poor; | ||
return PingRating.Terrible; | ||
} | ||
|
||
public static Color GetRatingColor(long time = -1) | ||
{ | ||
if (time < 0) return Color.Gray; | ||
if (time <= 100) return Color.Green; | ||
if (time <= 150) return Color.Yellow; | ||
return Color.Red; | ||
} | ||
|
||
public static Color GetStatusColor(IPStatus status = IPStatus.Unknown) | ||
{ | ||
if (status == IPStatus.Unknown) return Color.Gray; | ||
if (status == IPStatus.Success) return Color.Blue; | ||
else return Color.DarkRed; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using PingTesterAluminium.Properties; | ||
|
||
namespace PingTesterAluminium | ||
{ | ||
public static class PingTestManager | ||
{ | ||
public static string Host | ||
{ | ||
get | ||
{ | ||
return Settings.Default.Host; | ||
} | ||
set | ||
{ | ||
Settings.Default.Host = value; | ||
Settings.Default.Save(); | ||
} | ||
} | ||
public static int Interval | ||
{ | ||
get | ||
{ | ||
return Settings.Default.Interval; | ||
} | ||
set | ||
{ | ||
if (value < 100) value = 100; | ||
Settings.Default.Interval = value; | ||
Settings.Default.Save(); | ||
} | ||
} | ||
public static int Timeout | ||
{ | ||
get | ||
{ | ||
return Settings.Default.Timeout; | ||
} | ||
set | ||
{ | ||
if (value < 0) value = 0; | ||
Settings.Default.Timeout = value; | ||
Settings.Default.Save(); | ||
} | ||
} | ||
public static int BufferLength | ||
{ | ||
get | ||
{ | ||
return Settings.Default.BufferLength; | ||
} | ||
set | ||
{ | ||
if (value < 0) value = 0; | ||
if (value > 65500) value = 65500; | ||
Settings.Default.BufferLength = value; | ||
Settings.Default.Save(); | ||
} | ||
} | ||
public static int Ttl | ||
{ | ||
get | ||
{ | ||
return Settings.Default.Ttl; | ||
} | ||
set | ||
{ | ||
if (value < 0) value = 0; | ||
if (value > 255) value = 255; | ||
Settings.Default.Ttl = value; | ||
Settings.Default.Save(); | ||
} | ||
} | ||
public static bool DontFragment | ||
{ | ||
get | ||
{ | ||
return Settings.Default.DontFragment; | ||
} | ||
set | ||
{ | ||
Settings.Default.DontFragment = value; | ||
Settings.Default.Save(); | ||
} | ||
} | ||
|
||
public static PingResult RunPingTest() | ||
{ | ||
return PingTest.Run( | ||
host: Host, | ||
timeout: Timeout, | ||
bufferLength: BufferLength, | ||
ttl: Ttl, | ||
dontFragment: DontFragment | ||
); | ||
} | ||
} | ||
} |
Oops, something went wrong.