Skip to content

Commit

Permalink
Added notification when a test is completed (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo-Peyronnet committed Jul 7, 2021
1 parent ab535ad commit 83b499d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions InternetTest/InternetTest/Pages/ConnectionPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ namespace InternetTest.Pages
/// </summary>
public partial class ConnectionPage : Page
{
System.Windows.Forms.NotifyIcon notifyIcon = new System.Windows.Forms.NotifyIcon();
public ConnectionPage()
{
InitializeComponent();
notifyIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(AppDomain.CurrentDomain.BaseDirectory + @"\InternetTest.exe");
if (!Global.Settings.LaunchTestOnStart.HasValue ? true : Global.Settings.LaunchTestOnStart.Value)
{
Test(Global.Settings.TestSite); // Launch a test
Expand All @@ -75,13 +77,21 @@ private async void Test(string customSite)
InternetIconTxt.Text = "\uF299"; // Set the icon
InternetIconTxt.Foreground = new SolidColorBrush { Color = (Color)ColorConverter.ConvertFromString(App.Current.Resources["Green"].ToString()) }; // Set the foreground
HistoricDisplayer.Children.Add(new ConnectionHistoricItem(true, HistoricDisplayer));

notifyIcon.Visible = true; // Show
notifyIcon.ShowBalloonTip(5000, Properties.Resources.InternetTest, Properties.Resources.Connected, System.Windows.Forms.ToolTipIcon.Info);
notifyIcon.Visible = false; // Hide
}
else
{
ConnectionStatusTxt.Text = Properties.Resources.NotConnected; // Set text of the label
InternetIconTxt.Text = "\uF36E"; // Set the icon
InternetIconTxt.Foreground = new SolidColorBrush { Color = (Color)ColorConverter.ConvertFromString(App.Current.Resources["Red"].ToString()) }; // Set the foreground
HistoricDisplayer.Children.Add(new ConnectionHistoricItem(false, HistoricDisplayer));

notifyIcon.Visible = true; // Show
notifyIcon.ShowBalloonTip(5000, Properties.Resources.InternetTest, Properties.Resources.NotConnected, System.Windows.Forms.ToolTipIcon.Info);
notifyIcon.Visible = false; // Hide
}
}
else
Expand All @@ -92,13 +102,21 @@ private async void Test(string customSite)
InternetIconTxt.Text = "\uF299"; // Set the icon
InternetIconTxt.Foreground = new SolidColorBrush { Color = (Color)ColorConverter.ConvertFromString(App.Current.Resources["Green"].ToString()) }; // Set the foreground
HistoricDisplayer.Children.Add(new ConnectionHistoricItem(true, HistoricDisplayer));

notifyIcon.Visible = true; // Show
notifyIcon.ShowBalloonTip(5000, Properties.Resources.InternetTest, Properties.Resources.Connected, System.Windows.Forms.ToolTipIcon.Info);
notifyIcon.Visible = false; // Hide
}
else
{
ConnectionStatusTxt.Text = Properties.Resources.NotConnected; // Set text of the label
InternetIconTxt.Text = "\uF36E"; // Set the icon
InternetIconTxt.Foreground = new SolidColorBrush { Color = (Color)ColorConverter.ConvertFromString(App.Current.Resources["Red"].ToString()) }; // Set the foreground
HistoricDisplayer.Children.Add(new ConnectionHistoricItem(false, HistoricDisplayer));

notifyIcon.Visible = true; // Show
notifyIcon.ShowBalloonTip(5000, Properties.Resources.InternetTest, Properties.Resources.NotConnected, System.Windows.Forms.ToolTipIcon.Info);
notifyIcon.Visible = false; // Hide
}
}
}
Expand Down

0 comments on commit 83b499d

Please sign in to comment.