Skip to content

Commit

Permalink
Notifications are no longer shown on start (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo-Peyronnet committed Jul 7, 2021
1 parent bd7804e commit 6f8f1db
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions InternetTest/InternetTest/Pages/ConnectionPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,22 @@ public ConnectionPage()
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
Test(Global.Settings.TestSite, true); // Launch a test
}
else
{
ConnectionStatusTxt.Text = Properties.Resources.LaunchTestToCheckConnection; // Set text of the label
InternetIconTxt.Text = "\uF4AB"; // Set the icon
InternetIconTxt.Foreground = new SolidColorBrush { Color = (Color)ColorConverter.ConvertFromString(App.Current.Resources["Gray"].ToString()) }; // Set the foreground
}
Focus();
}

/// <summary>
/// Launch a network test.
/// </summary>
/// <param name="customSite">Leave empty if you don't want to specify a custom website.</param>
private async void Test(string customSite)
private async void Test(string customSite, bool fromStart = false)
{
if (string.IsNullOrEmpty(customSite)) // If a custom site isn't specified
{
Expand All @@ -78,7 +79,7 @@ private async void Test(string customSite)
InternetIconTxt.Foreground = new SolidColorBrush { Color = (Color)ColorConverter.ConvertFromString(App.Current.Resources["Green"].ToString()) }; // Set the foreground
HistoricDisplayer.Children.Add(new ConnectionHistoricItem(true, HistoricDisplayer));

if (Global.Settings.TestNotification.Value)
if (Global.Settings.TestNotification.Value && !fromStart)
{
notifyIcon.Visible = true; // Show
notifyIcon.ShowBalloonTip(5000, Properties.Resources.InternetTest, Properties.Resources.Connected, System.Windows.Forms.ToolTipIcon.Info);
Expand All @@ -92,7 +93,7 @@ private async void Test(string customSite)
InternetIconTxt.Foreground = new SolidColorBrush { Color = (Color)ColorConverter.ConvertFromString(App.Current.Resources["Red"].ToString()) }; // Set the foreground
HistoricDisplayer.Children.Add(new ConnectionHistoricItem(false, HistoricDisplayer));

if (Global.Settings.TestNotification.Value)
if (Global.Settings.TestNotification.Value && !fromStart)
{
notifyIcon.Visible = true; // Show
notifyIcon.ShowBalloonTip(5000, Properties.Resources.InternetTest, Properties.Resources.NotConnected, System.Windows.Forms.ToolTipIcon.Info);
Expand All @@ -109,7 +110,7 @@ private async void Test(string customSite)
InternetIconTxt.Foreground = new SolidColorBrush { Color = (Color)ColorConverter.ConvertFromString(App.Current.Resources["Green"].ToString()) }; // Set the foreground
HistoricDisplayer.Children.Add(new ConnectionHistoricItem(true, HistoricDisplayer));

if (Global.Settings.TestNotification.Value)
if (Global.Settings.TestNotification.Value && !fromStart)
{
notifyIcon.Visible = true; // Show
notifyIcon.ShowBalloonTip(5000, Properties.Resources.InternetTest, Properties.Resources.Connected, System.Windows.Forms.ToolTipIcon.Info);
Expand All @@ -123,7 +124,7 @@ private async void Test(string customSite)
InternetIconTxt.Foreground = new SolidColorBrush { Color = (Color)ColorConverter.ConvertFromString(App.Current.Resources["Red"].ToString()) }; // Set the foreground
HistoricDisplayer.Children.Add(new ConnectionHistoricItem(false, HistoricDisplayer));

if (Global.Settings.TestNotification.Value)
if (Global.Settings.TestNotification.Value && !fromStart)
{
notifyIcon.Visible = true; // Show
notifyIcon.ShowBalloonTip(5000, Properties.Resources.InternetTest, Properties.Resources.NotConnected, System.Windows.Forms.ToolTipIcon.Info);
Expand Down

0 comments on commit 6f8f1db

Please sign in to comment.