From c2d4859bd79e2974b6c95599ea5d8c7fb34143f2 Mon Sep 17 00:00:00 2001 From: Scighost Date: Sat, 30 Dec 2023 23:46:19 +0800 Subject: [PATCH] optimize window class --- src/Starward/MyWindows/InstallGameWindow.xaml.cs | 2 +- src/Starward/MyWindows/MainWindow.xaml.cs | 3 +-- src/Starward/MyWindows/SystemTrayWindow.xaml.cs | 2 +- src/Starward/MyWindows/WelcomeWindow.xaml.cs | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Starward/MyWindows/InstallGameWindow.xaml.cs b/src/Starward/MyWindows/InstallGameWindow.xaml.cs index 13861170b..b3e4291ca 100644 --- a/src/Starward/MyWindows/InstallGameWindow.xaml.cs +++ b/src/Starward/MyWindows/InstallGameWindow.xaml.cs @@ -29,7 +29,7 @@ public InstallGameWindow() - private void InitializeWindow(string? action = null) + private void InitializeWindow() { Title = "Starward - Install Game"; AppWindow.TitleBar.ExtendsContentIntoTitleBar = true; diff --git a/src/Starward/MyWindows/MainWindow.xaml.cs b/src/Starward/MyWindows/MainWindow.xaml.cs index b9ba77f51..f6be08e7c 100644 --- a/src/Starward/MyWindows/MainWindow.xaml.cs +++ b/src/Starward/MyWindows/MainWindow.xaml.cs @@ -72,10 +72,9 @@ private void InitializeMainWindow() AppWindow.TitleBar.ExtendsContentIntoTitleBar = true; AppWindow.TitleBar.IconShowOptions = IconShowOptions.ShowIconAndSystemMenu; AppWindow.Closing += AppWindow_Closing; - var len = (int)(48 * UIScale); ChangeWindowSize(); AdaptTitleBarButtonColorToActuallTheme(); - SetDragRectangles(new RectInt32(0, 0, 100000, len)); + SetDragRectangles(new RectInt32(0, 0, 100000, (int)(48 * UIScale))); AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, @"Assets\logo.ico")); WTSRegisterSessionNotification(WindowHandle, 0); if (AppWindow.Presenter is OverlappedPresenter presenter) diff --git a/src/Starward/MyWindows/SystemTrayWindow.xaml.cs b/src/Starward/MyWindows/SystemTrayWindow.xaml.cs index 7dbbcb6d2..45f7eee8a 100644 --- a/src/Starward/MyWindows/SystemTrayWindow.xaml.cs +++ b/src/Starward/MyWindows/SystemTrayWindow.xaml.cs @@ -106,9 +106,9 @@ public override void Show() [RelayCommand] public override void Hide() { - base.Hide(); try { + base.Hide(); AppWindow.ResizeClient(new Windows.Graphics.SizeInt32(1000, 1000)); } catch { } diff --git a/src/Starward/MyWindows/WelcomeWindow.xaml.cs b/src/Starward/MyWindows/WelcomeWindow.xaml.cs index 73321274e..6ed9bc65d 100644 --- a/src/Starward/MyWindows/WelcomeWindow.xaml.cs +++ b/src/Starward/MyWindows/WelcomeWindow.xaml.cs @@ -47,8 +47,7 @@ private void InitializeWindow() AppWindow.TitleBar.IconShowOptions = IconShowOptions.HideIconAndSystemMenu; ChangeWindowSize(AppConfig.WindowSizeMode); AdaptTitleBarButtonColorToActuallTheme(); - int len = (int)(48 * UIScale); - SetDragRectangles(new RectInt32(0, 0, 10000, len)); + SetDragRectangles(new RectInt32(0, 0, 10000, (int)(48 * UIScale))); AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, @"Assets\logo.ico")); if (AppWindow.Presenter is OverlappedPresenter presenter) {