-
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.
Adding: New GUI (Custom Form & Controls)
- Loading branch information
Ambratolm
authored and
Ambratolm
committed
Jun 9, 2021
1 parent
0e70196
commit 2f355da
Showing
44 changed files
with
2,562 additions
and
342 deletions.
There are no files selected for viewing
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,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Drawing; | ||
using PingTesterAluminium.Properties; | ||
|
||
namespace PingTesterAluminium | ||
{ | ||
public static class Constants | ||
{ | ||
public static FontFamily VisitorFontFamily { get; private set; } | ||
|
||
static Constants() | ||
{ | ||
Constants.VisitorFontFamily = Resources.visitor.ToFontFamily(); | ||
} | ||
} | ||
} |
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,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
using System.Drawing; | ||
|
||
namespace PingTesterAluminium | ||
{ | ||
public static class ButtonExtension | ||
{ | ||
public static void EnableHoverEffects(this Button button) | ||
{ | ||
Image backgroundImage = button.BackgroundImage; | ||
Color backColor = button.BackColor; | ||
|
||
button.MouseEnter += (s, e) => | ||
{ | ||
button.BackgroundImage = null; | ||
button.BackColor = Color.FromArgb(230, 230, 230); | ||
}; | ||
|
||
button.MouseLeave += (s, e) => | ||
{ | ||
button.BackgroundImage = backgroundImage; | ||
button.BackColor = backColor; | ||
}; | ||
} | ||
} | ||
} |
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,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Drawing; | ||
|
||
namespace PingTesterAluminium | ||
{ | ||
public static class ImageExtension | ||
{ | ||
public static Icon ToIcon(this Image image) | ||
{ | ||
return Icon.FromHandle(((Bitmap)image).GetHicon()); | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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,121 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
using PingTesterAluminium.Properties; | ||
|
||
namespace PingTesterAluminium | ||
{ | ||
public partial class Form1 : AluminiumForm | ||
{ | ||
public int Counter { get; set; } | ||
public List<ProgressBar> ProgressBars { get; set; } | ||
|
||
public Form1() | ||
{ | ||
InitializeComponent(); | ||
ProgressBars = new List<ProgressBar>(); | ||
foreach (Control control in panel_time.Controls) | ||
{ | ||
if (control is ProgressBar) | ||
{ | ||
ProgressBars.Add(control as ProgressBar); | ||
} | ||
} | ||
timer_main.Start(); | ||
} | ||
|
||
public void IncrementCounter() | ||
{ | ||
if (Counter < ProgressBars.Count - 1) | ||
{ | ||
Counter++; | ||
} | ||
else | ||
{ | ||
Counter = 0; | ||
} | ||
} | ||
|
||
public void UpdateProgressBar(ProgressBar progressBar, PingResult response) | ||
{ | ||
if (response.Time > progressBar.Maximum) | ||
{ | ||
progressBar.Value = progressBar.Maximum; | ||
} | ||
else if (response.Time < progressBar.Minimum) | ||
{ | ||
progressBar.Value = progressBar.Minimum; | ||
} | ||
else | ||
{ | ||
progressBar.Value = (int)response.Time; | ||
} | ||
progressBar.ForeColor = response.Color; | ||
} | ||
|
||
public void UpdateProgressBar(PingResult response) | ||
{ | ||
UpdateProgressBar(ProgressBars[Counter], response); | ||
IncrementCounter(); | ||
} | ||
|
||
private void timer_main_Tick(object sender, EventArgs e) | ||
{ | ||
if (Settings.Default.Interval < 1000) | ||
{ | ||
timer_main.Interval = 1000; | ||
} | ||
else | ||
{ | ||
timer_main.Interval = Settings.Default.Interval; | ||
} | ||
|
||
if (timer_main.Interval != Settings.Default.Interval) | ||
{ | ||
Settings.Default.Interval = timer_main.Interval; | ||
Settings.Default.Save(); | ||
} | ||
|
||
if (!backgroundWorker_main.IsBusy) | ||
{ | ||
backgroundWorker_main.RunWorkerAsync(Settings.Default.Host); | ||
} | ||
} | ||
|
||
private void backgroundWorker_main_DoWork(object sender, DoWorkEventArgs e) | ||
{ | ||
e.Result = PingTest.Ping(e.Argument as string); | ||
} | ||
|
||
private void backgroundWorker_main_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) | ||
{ | ||
PingResult response = e.Result as PingResult; | ||
|
||
label_time.Text = response.Time > 0 ? response.Time.ToString() + " ms" : "Timeout"; | ||
label_time.ForeColor = response.Color; | ||
|
||
UpdateProgressBar(response); | ||
|
||
label_rating.Text = response.Rating; | ||
label_rating.ForeColor = response.Color; | ||
|
||
label_host.Text = response.Host; | ||
|
||
if (response.Host != Settings.Default.Host) | ||
{ | ||
Settings.Default.Host = response.Host; | ||
Settings.Default.Save(); | ||
} | ||
} | ||
|
||
private void button_play_Click(object sender, EventArgs e) | ||
{ | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.