Skip to content

Commit c4f82c6

Browse files
committed
feat: check for fullscreen when closing the app
1 parent 02c0b31 commit c4f82c6

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

AtlasToolbox/Utils/AppBehaviorHelper.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
using System;
1+
using Microsoft.UI.Xaml;
2+
using System;
23
using System.Collections.Generic;
34
using System.Linq;
45
using System.Text;
56
using System.Threading.Tasks;
6-
using Microsoft.UI.Xaml;
7+
using Windows.UI.ViewManagement;
78
using WinUIEx;
89

910
namespace AtlasToolbox.Utils
@@ -20,17 +21,23 @@ public static void HideApp(object sender, WindowEventArgs e)
2021
e.Handled = true;
2122
App.m_window.Hide();
2223
}
24+
2325
public static void CloseApp(object sender, WindowEventArgs e)
2426
{
2527
// Get & save the current app size
26-
27-
// TODO: Check if the window is maximised, if it is then don't save the size
2828
int width, height;
29+
ApplicationView applicationView = ApplicationView.GetForCurrentView();
2930
MainWindow mWindow = App.m_window as MainWindow;
30-
mWindow.GetWindowSize(out width, out height);
31-
RegistryHelper.SetValue(@"HKLM\SOFTWARE\AtlasOS\Toolbox", "AppWidth", width, Microsoft.Win32.RegistryValueKind.String);
32-
RegistryHelper.SetValue(@"HKLM\SOFTWARE\AtlasOS\Toolbox", "AppHeight", height, Microsoft.Win32.RegistryValueKind.String);
3331

32+
// Check if app is fullscreen
33+
// if true then don't save screen size
34+
if (!applicationView.IsFullScreenMode)
35+
{
36+
mWindow.GetWindowSize(out width, out height);
37+
RegistryHelper.SetValue(@"HKLM\SOFTWARE\AtlasOS\Toolbox", "AppWidth", width, Microsoft.Win32.RegistryValueKind.String);
38+
RegistryHelper.SetValue(@"HKLM\SOFTWARE\AtlasOS\Toolbox", "AppHeight", height, Microsoft.Win32.RegistryValueKind.String);
39+
}
40+
// Exit the app
3441
App.Current.Exit();
3542
}
3643
}

0 commit comments

Comments
 (0)