Skip to content

Commit

Permalink
Additional work on start minimized. #22
Browse files Browse the repository at this point in the history
  • Loading branch information
Timthreetwelve committed Nov 4, 2023
1 parent ecf405f commit d1e9f05
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
4 changes: 2 additions & 2 deletions GetMyIP/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
global using System.Windows.Input;
global using System.Windows.Markup;
global using System.Windows.Media;
global using System.Windows.Navigation;

global using CommandLine;

Expand All @@ -39,7 +38,8 @@
global using GetMyIP.Helpers;
global using GetMyIP.Models;
global using GetMyIP.ViewModels;
global using GetMyIP.Views;

global using H.NotifyIcon;

global using MaterialDesignColors;
global using MaterialDesignThemes.Wpf;
Expand Down
30 changes: 26 additions & 4 deletions GetMyIP/Helpers/MainWindowHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Tim Kennedy. All Rights Reserved. Licensed under the MIT License.

using H.NotifyIcon;

namespace GetMyIP.Helpers;

internal static class MainWindowHelpers
Expand All @@ -14,19 +16,38 @@ internal static async void GetMyIPStartUp()
if (CommandLineHelpers.ProcessCommandLine())
{
MainWindowUIHelpers.ApplyUISettings();

string returnedJson = await IpHelpers.GetAllInfoAsync();
IpHelpers.ProcessProvider(returnedJson);
EnableTrayIcon(UserSettings.Setting.MinimizeToTray);
if (UserSettings.Setting.StartMinimized)

if (UserSettings.Setting.StartMinimized && UserSettings.Setting.MinimizeToTray)
{
EnableTrayIcon(true);
WindowExtensions.Hide(_mainWindow);
}
else if (UserSettings.Setting.StartMinimized && !UserSettings.Setting.MinimizeToTray)
{
_mainWindow.WindowState = WindowState.Minimized;
_mainWindow.Visibility = Visibility.Visible;
EnableTrayIcon(false);
}
else if (!UserSettings.Setting.StartMinimized && UserSettings.Setting.MinimizeToTray)
{
_mainWindow.WindowState = WindowState.Normal;
_mainWindow.Visibility = Visibility.Visible;
EnableTrayIcon(true);
}
else
{
_mainWindow.WindowState = WindowState.Normal;
_mainWindow.Visibility = Visibility.Visible;
EnableTrayIcon(false);
}
}
else
{
_mainWindow.Visibility = Visibility.Hidden;
string returnedJson = await IpHelpers.GetExternalInfo();
IpHelpers.LogIPInfo(returnedJson);

_mainWindow.Close();
}
}
Expand Down Expand Up @@ -196,6 +217,7 @@ public static void EnableTrayIcon(bool value)
{
if (value)
{
_mainWindow.tbIcon.ForceCreate();
_mainWindow.tbIcon.Visibility = Visibility.Visible;
CustomToolTip.Instance.ToolTipText = ToolTipHelper.BuildToolTip();
}
Expand Down
2 changes: 1 addition & 1 deletion GetMyIP/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private static void StartWithWindows(RoutedEventArgs e)
}
}
}
else
else if (RegRun.RegRunEntry(_getmyip))
{
string result = RegRun.RemoveRegEntry(_getmyip);
if (result == "OK")
Expand Down

0 comments on commit d1e9f05

Please sign in to comment.