Skip to content

Commit cd1acfc

Browse files
committed
fix: maximised window doesnt save size
1 parent 73d3c85 commit cd1acfc

10 files changed

+35
-68
lines changed

AtlasToolbox/MainWindow.xaml.cs

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
using System;
2-
using System.Linq;
1+
using AtlasToolbox.Utils;
2+
using AtlasToolbox.ViewModels;
3+
using AtlasToolbox.Views;
4+
using CommunityToolkit.Mvvm.Input;
5+
using CommunityToolkit.WinUI;
6+
using Microsoft.Extensions.DependencyInjection;
7+
using Microsoft.UI.Windowing;
38
using Microsoft.UI.Xaml;
49
using Microsoft.UI.Xaml.Controls;
5-
using Microsoft.UI.Xaml.Navigation;
610
using Microsoft.UI.Xaml.Media.Animation;
11+
using Microsoft.UI.Xaml.Navigation;
12+
using System;
13+
using System.Collections.Generic;
14+
using System.Linq;
715
using System.Runtime.InteropServices;
8-
using AtlasToolbox.Utils;
9-
using CommunityToolkit.WinUI;
10-
using System.Windows.Input;
11-
using CommunityToolkit.Mvvm.Input;
12-
using AtlasToolbox.Views;
1316
using System.Threading.Tasks;
14-
using System.Collections.Generic;
15-
using Microsoft.Extensions.DependencyInjection;
16-
using AtlasToolbox.ViewModels;
17-
using Microsoft.UI.Windowing;
17+
using System.Windows.Input;
1818
using WinUIEx;
1919

2020
namespace AtlasToolbox
2121
{
2222
public sealed partial class MainWindow : Window
2323
{
2424
public List<IConfigurationItem> RootList { get; set; }
25+
2526
public MainWindow()
2627
{
2728
this.InitializeComponent();
2829

29-
3030
OverlappedPresenter presenter = OverlappedPresenter.Create();
3131
presenter.PreferredMinimumWidth = 516;
3232
presenter.PreferredMinimumHeight = 491;
@@ -81,6 +81,22 @@ public MainWindow()
8181
else this.Closed += AppBehaviorHelper.CloseApp;
8282
}
8383

84+
public bool IsFullscreen()
85+
{
86+
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
87+
var windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(hWnd);
88+
AppWindow appWindow = AppWindow.GetFromWindowId(windowId);
89+
90+
if (appWindow.Presenter is OverlappedPresenter presenter)
91+
{
92+
if (presenter.State == OverlappedPresenterState.Maximized)
93+
{
94+
return true;
95+
}
96+
}
97+
return false;
98+
}
99+
84100
private async void CheckUpdates()
85101
{
86102
bool update = await Task.Run(() => ToolboxUpdateHelper.CheckUpdates());

AtlasToolbox/Utils/AppBehaviorHelper.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
using Microsoft.UI.Xaml;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
7-
using Windows.UI.ViewManagement;
82
using WinUIEx;
93

104
namespace AtlasToolbox.Utils
@@ -26,12 +20,11 @@ public static void CloseApp(object sender, WindowEventArgs e)
2620
{
2721
// Get & save the current app size
2822
int width, height;
29-
ApplicationView applicationView = ApplicationView.GetForCurrentView();
3023
MainWindow mWindow = App.m_window as MainWindow;
3124

3225
// Check if app is fullscreen
3326
// if true then don't save screen size
34-
if (!applicationView.IsFullScreenMode)
27+
if (!mWindow.IsFullscreen())
3528
{
3629
mWindow.GetWindowSize(out width, out height);
3730
RegistryHelper.SetValue(@"HKLM\SOFTWARE\AtlasOS\Toolbox", "AppWidth", width, Microsoft.Win32.RegistryValueKind.String);

AtlasToolbox/Utils/CommandPromptHelper.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Diagnostics;
4-
using System.Linq;
5-
using System.ServiceProcess;
6-
using System.Text;
7-
using System.Threading.Tasks;
8-
using Windows.UI.Notifications;
1+
using System.Diagnostics;
92

103
namespace AtlasToolbox.Utils
114
{

AtlasToolbox/Utils/CompatibilityHelper.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Configuration;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
1+
using System.Configuration;
72

83
namespace AtlasToolbox.Utils
94
{

AtlasToolbox/Utils/ComputerStateHelper.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using System;
2-
using Microsoft.UI.Xaml;
3-
using Microsoft.UI.Xaml.Controls;
4-
using AtlasOSToolbox;
5-
6-
namespace AtlasToolbox.Utils
1+
namespace AtlasToolbox.Utils
72
{
83
public static class ComputerStateHelper
94
{

AtlasToolbox/Utils/ProfileSerializing.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Text.Json;
7-
using System.Threading.Tasks;
8-
using System.Xml.Linq;
94
using AtlasToolbox.Models;
105
using AtlasToolbox.Models.ProfileModels;
116
using AtlasToolbox.ViewModels;
12-
using ICSharpCode.Decompiler.CSharp.Syntax;
137
using Microsoft.Extensions.DependencyInjection;
148
using Newtonsoft.Json;
159

AtlasToolbox/Utils/RecentTogglesHelper.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
74
using AtlasToolbox.Models;
8-
using AtlasToolbox.Models.ProfileModels;
95
using Newtonsoft.Json;
106

117
namespace AtlasToolbox.Utils

AtlasToolbox/Utils/ServiceHelper.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using AtlasToolbox.Utils;
2-
using System.ServiceProcess;
1+
using System.ServiceProcess;
32

43
namespace AtlasToolbox.Utils
54
{

AtlasToolbox/Utils/SettingsBehaviorHelper.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using Microsoft.UI.Xaml.Controls;
1+
using Microsoft.UI.Xaml.Controls;
72
using Microsoft.UI.Xaml;
8-
using AtlasToolbox.Utils;
93

104
namespace AtlasToolbox.Utils
115
{

AtlasToolbox/Utils/ToolboxUpdateHelper.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Linq;
4-
using System.Net.Http;
53
using System.Text.Json;
6-
using System.Text;
7-
using System.Threading.Tasks;
8-
using static System.Runtime.InteropServices.JavaScript.JSType;
9-
using Newtonsoft.Json;
10-
using WinRT;
114
using System.IO;
12-
using ICSharpCode.Decompiler.CSharp.Syntax;
135

146
namespace AtlasToolbox.Utils
157
{

0 commit comments

Comments
 (0)