diff --git a/src/Starward/App.xaml.cs b/src/Starward/App.xaml.cs index a4946c679..138026f12 100644 --- a/src/Starward/App.xaml.cs +++ b/src/Starward/App.xaml.cs @@ -7,6 +7,7 @@ using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Media; using Microsoft.Windows.AppLifecycle; +using Starward.Frameworks; using Starward.Helpers; using System; using System.Globalization; diff --git a/src/Starward/MyWindows/WindowEx.cs b/src/Starward/Frameworks/WindowEx.cs similarity index 74% rename from src/Starward/MyWindows/WindowEx.cs rename to src/Starward/Frameworks/WindowEx.cs index 4612638f3..bd237e51f 100644 --- a/src/Starward/MyWindows/WindowEx.cs +++ b/src/Starward/Frameworks/WindowEx.cs @@ -1,15 +1,13 @@ -using CommunityToolkit.Mvvm.Messaging; -using Microsoft.UI; +using Microsoft.UI; using Microsoft.UI.Windowing; using Microsoft.UI.Xaml; -using Starward.Messages; using System; using System.Runtime.InteropServices; using Vanara.PInvoke; using Windows.Graphics; using Windows.UI; -namespace Starward.MyWindows; +namespace Starward.Frameworks; public abstract partial class WindowEx : Window { @@ -17,7 +15,7 @@ public abstract partial class WindowEx : Window public IntPtr WindowHandle { get; private init; } - public IntPtr BridgeHandle { get; private init; } + private IntPtr InputSiteHandle { get; init; } public double UIScale => User32.GetDpiForWindow(WindowHandle) / 96d; @@ -28,11 +26,12 @@ public abstract partial class WindowEx : Window public WindowEx() { WindowHandle = (IntPtr)AppWindow.Id.Value; - BridgeHandle = (IntPtr)User32.FindWindowEx(WindowHandle, IntPtr.Zero, "Microsoft.UI.Content.DesktopChildSiteBridge", null); + HWND bridge = (IntPtr)User32.FindWindowEx(WindowHandle, IntPtr.Zero, "Microsoft.UI.Content.DesktopChildSiteBridge", null); + InputSiteHandle = (IntPtr)User32.FindWindowEx(bridge, IntPtr.Zero, "InputSiteWindowClass", null); windowSubclassProc = new(WindowSubclassProc); - bridgeSubclassProc = new(BridgeSubclassProc); + inputSiteSubclassProc = new(InputSiteSubclassProc); ComCtl32.SetWindowSubclass(WindowHandle, windowSubclassProc, 1001, IntPtr.Zero); - ComCtl32.SetWindowSubclass(BridgeHandle, bridgeSubclassProc, 1002, IntPtr.Zero); + ComCtl32.SetWindowSubclass(InputSiteHandle, inputSiteSubclassProc, 1002, IntPtr.Zero); } @@ -44,18 +43,18 @@ public WindowEx() private readonly ComCtl32.SUBCLASSPROC windowSubclassProc; - private readonly ComCtl32.SUBCLASSPROC bridgeSubclassProc; + private readonly ComCtl32.SUBCLASSPROC inputSiteSubclassProc; - public unsafe virtual IntPtr WindowSubclassProc(HWND hWnd, uint uMsg, IntPtr wParam, IntPtr lParam, nuint uIdSubclass, IntPtr dwRefData) + protected unsafe virtual IntPtr WindowSubclassProc(HWND hWnd, uint uMsg, IntPtr wParam, IntPtr lParam, nuint uIdSubclass, IntPtr dwRefData) { return ComCtl32.DefSubclassProc(hWnd, uMsg, wParam, lParam); } - public unsafe virtual IntPtr BridgeSubclassProc(HWND hWnd, uint uMsg, IntPtr wParam, IntPtr lParam, nuint uIdSubclass, IntPtr dwRefData) + protected unsafe virtual IntPtr InputSiteSubclassProc(HWND hWnd, uint uMsg, IntPtr wParam, IntPtr lParam, nuint uIdSubclass, IntPtr dwRefData) { return ComCtl32.DefSubclassProc(hWnd, uMsg, wParam, lParam); } @@ -78,7 +77,6 @@ public virtual void Show() AppWindow.MoveInZOrderAtTop(); User32.ShowWindow(WindowHandle, ShowWindowCommand.SW_SHOWNORMAL); User32.SetForegroundWindow(WindowHandle); - WeakReferenceMessenger.Default.Send(new WindowStateChangedMessage(false)); } @@ -86,7 +84,6 @@ public virtual void Show() public virtual void Hide() { AppWindow.Hide(); - WeakReferenceMessenger.Default.Send(new WindowStateChangedMessage(true)); } @@ -113,31 +110,6 @@ public virtual void CenterInScreen(int? width = null, int? height = null) - - public bool IsTopMost - { - get - { - User32.WindowStylesEx flags = (User32.WindowStylesEx)User32.GetWindowLong(WindowHandle, User32.WindowLongFlags.GWL_EXSTYLE); - return flags.HasFlag(User32.WindowStylesEx.WS_EX_TOPMOST); - } - set - { - User32.WindowStylesEx flags = (User32.WindowStylesEx)User32.GetWindowLong(WindowHandle, User32.WindowLongFlags.GWL_EXSTYLE); - if (value) - { - flags |= User32.WindowStylesEx.WS_EX_TOPMOST; - } - else - { - flags &= ~User32.WindowStylesEx.WS_EX_TOPMOST; - } - User32.SetWindowLong(WindowHandle, User32.WindowLongFlags.GWL_EXSTYLE, (nint)flags); - } - } - - - public void SetIcon(string? iconPath = null) { if (string.IsNullOrWhiteSpace(iconPath)) @@ -159,9 +131,18 @@ public void SetIcon(string? iconPath = null) - #region Title Bar + #region Theme + + public void SetDragRectangles(params RectInt32[] value) + { + if (AppWindowTitleBar.IsCustomizationSupported() && AppWindow.TitleBar.ExtendsContentIntoTitleBar == true) + { + AppWindow.TitleBar.SetDragRectangles(value); + } + } + public void AdaptTitleBarButtonColorToActuallTheme() { @@ -197,24 +178,6 @@ public void AdaptTitleBarButtonColorToActuallTheme() - public void SetDragRectangles(params RectInt32[] value) - { - if (AppWindowTitleBar.IsCustomizationSupported() && AppWindow.TitleBar.ExtendsContentIntoTitleBar == true) - { - AppWindow.TitleBar.SetDragRectangles(value); - } - } - - - - #endregion - - - - - #region Accent Color - - public virtual void ChangeAccentColor(Color? backColor = null, Color? foreColor = null) { if (Content is FrameworkElement element) @@ -234,13 +197,14 @@ public virtual void ChangeAccentColor(Color? backColor = null, Color? foreColor } - #endregion - - [return: MarshalAs(UnmanagedType.Bool)] [LibraryImport("uxtheme.dll", EntryPoint = "#138", SetLastError = true)] protected static partial bool ShouldSystemUseDarkMode(); + + #endregion + + } diff --git a/src/Starward/MyWindows/CloudGameGachaWindow.xaml b/src/Starward/MyWindows/CloudGameGachaWindow.xaml index 8ad240711..7a7a4eb24 100644 --- a/src/Starward/MyWindows/CloudGameGachaWindow.xaml +++ b/src/Starward/MyWindows/CloudGameGachaWindow.xaml @@ -1,12 +1,13 @@ - + - + diff --git a/src/Starward/MyWindows/CloudGameGachaWindow.xaml.cs b/src/Starward/MyWindows/CloudGameGachaWindow.xaml.cs index d61ec64fd..3781b23b8 100644 --- a/src/Starward/MyWindows/CloudGameGachaWindow.xaml.cs +++ b/src/Starward/MyWindows/CloudGameGachaWindow.xaml.cs @@ -1,6 +1,7 @@ using CommunityToolkit.Mvvm.Messaging; using Microsoft.UI.Xaml; using Starward.Core; +using Starward.Frameworks; using Starward.Messages; using System; using System.Text.Json.Nodes; @@ -50,7 +51,7 @@ private void RootGrid_Loaded(object sender, RoutedEventArgs e) { try { - // todo WinAppSDK Éý¼¶µ½ 1.5 ºó£¬ÎªÔÆÓÎÏ·µÄÍøÒ³»º´æÉèÖõ¥¶ÀµÄÎļþ¼Ð + // todo WinAppSDK ������ 1.5 ��Ϊ����Ϸ����ҳ�������õ������ļ��� if (GameBiz.ToGame() == GameBiz.hk4e) { webview.Source = new Uri("https://ys.mihoyo.com/cloud/"); diff --git a/src/Starward/MyWindows/GameNoticesWindow.xaml b/src/Starward/MyWindows/GameNoticesWindow.xaml index 923a10e3b..1f59b31ba 100644 --- a/src/Starward/MyWindows/GameNoticesWindow.xaml +++ b/src/Starward/MyWindows/GameNoticesWindow.xaml @@ -1,11 +1,12 @@ - + - + diff --git a/src/Starward/MyWindows/GameNoticesWindow.xaml.cs b/src/Starward/MyWindows/GameNoticesWindow.xaml.cs index cdcac2bac..5f2df21cb 100644 --- a/src/Starward/MyWindows/GameNoticesWindow.xaml.cs +++ b/src/Starward/MyWindows/GameNoticesWindow.xaml.cs @@ -4,6 +4,7 @@ using Microsoft.UI.Xaml; using Starward.Core; using Starward.Core.Launcher; +using Starward.Frameworks; using Starward.Helpers; using Starward.Messages; using Starward.Models; @@ -90,7 +91,7 @@ private void InitializeWindow() - public override nint BridgeSubclassProc(HWND hWnd, uint uMsg, nint wParam, nint lParam, nuint uIdSubclass, nint dwRefData) + protected override nint InputSiteSubclassProc(HWND hWnd, uint uMsg, nint wParam, nint lParam, nuint uIdSubclass, nint dwRefData) { if (uMsg == (uint)User32.WindowMessage.WM_KEYDOWN) { @@ -102,7 +103,7 @@ public override nint BridgeSubclassProc(HWND hWnd, uint uMsg, nint wParam, nint return 0; } } - return base.BridgeSubclassProc(hWnd, uMsg, wParam, lParam, uIdSubclass, dwRefData); + return base.InputSiteSubclassProc(hWnd, uMsg, wParam, lParam, uIdSubclass, dwRefData); } diff --git a/src/Starward/MyWindows/InstallGameWindow.xaml b/src/Starward/MyWindows/InstallGameWindow.xaml index 45b23971c..39c9fd976 100644 --- a/src/Starward/MyWindows/InstallGameWindow.xaml +++ b/src/Starward/MyWindows/InstallGameWindow.xaml @@ -1,15 +1,16 @@ - + - + diff --git a/src/Starward/MyWindows/InstallGameWindow.xaml.cs b/src/Starward/MyWindows/InstallGameWindow.xaml.cs index ff0d6525e..8b2bdf250 100644 --- a/src/Starward/MyWindows/InstallGameWindow.xaml.cs +++ b/src/Starward/MyWindows/InstallGameWindow.xaml.cs @@ -1,4 +1,5 @@ using Microsoft.UI.Windowing; +using Starward.Frameworks; using System; using System.IO; using Vanara.PInvoke; @@ -47,7 +48,7 @@ private void InitializeWindow() - public override nint WindowSubclassProc(HWND hWnd, uint uMsg, nint wParam, nint lParam, nuint uIdSubclass, nint dwRefData) + protected override nint WindowSubclassProc(HWND hWnd, uint uMsg, nint wParam, nint lParam, nuint uIdSubclass, nint dwRefData) { if (uMsg == (uint)User32.WindowMessage.WM_SYSCOMMAND) { diff --git a/src/Starward/MyWindows/MainWindow.xaml b/src/Starward/MyWindows/MainWindow.xaml index a2b73f2f1..645c51cc7 100644 --- a/src/Starward/MyWindows/MainWindow.xaml +++ b/src/Starward/MyWindows/MainWindow.xaml @@ -1,17 +1,18 @@  - + @@ -36,4 +37,4 @@ - + diff --git a/src/Starward/MyWindows/MainWindow.xaml.cs b/src/Starward/MyWindows/MainWindow.xaml.cs index f366287b2..d32b9e611 100644 --- a/src/Starward/MyWindows/MainWindow.xaml.cs +++ b/src/Starward/MyWindows/MainWindow.xaml.cs @@ -7,6 +7,7 @@ using Microsoft.UI.Xaml.Media; using Microsoft.UI.Xaml.Media.Animation; using Starward.Controls; +using Starward.Frameworks; using Starward.Models; using Starward.Services.Download; using System; @@ -227,7 +228,7 @@ public void CloseOverlayPage() - public override nint WindowSubclassProc(HWND hWnd, uint uMsg, nint wParam, nint lParam, nuint uIdSubclass, nint dwRefData) + protected override nint WindowSubclassProc(HWND hWnd, uint uMsg, nint wParam, nint lParam, nuint uIdSubclass, nint dwRefData) { if (uMsg == (uint)User32.WindowMessage.WM_SYSCOMMAND) { @@ -254,7 +255,7 @@ public override nint WindowSubclassProc(HWND hWnd, uint uMsg, nint wParam, nint } - public unsafe override nint BridgeSubclassProc(HWND hWnd, uint uMsg, nint wParam, nint lParam, nuint uIdSubclass, nint dwRefData) + protected unsafe override nint InputSiteSubclassProc(HWND hWnd, uint uMsg, nint wParam, nint lParam, nuint uIdSubclass, nint dwRefData) { bool handled = false; if (uMsg == (uint)User32.WindowMessage.WM_KEYDOWN) @@ -272,7 +273,7 @@ public unsafe override nint BridgeSubclassProc(HWND hWnd, uint uMsg, nint wParam return IntPtr.Zero; } } - return base.BridgeSubclassProc(hWnd, uMsg, wParam, lParam, uIdSubclass, dwRefData); + return base.InputSiteSubclassProc(hWnd, uMsg, wParam, lParam, uIdSubclass, dwRefData); } diff --git a/src/Starward/MyWindows/SystemTrayWindow.xaml b/src/Starward/MyWindows/SystemTrayWindow.xaml index d770631af..ac19f494b 100644 --- a/src/Starward/MyWindows/SystemTrayWindow.xaml +++ b/src/Starward/MyWindows/SystemTrayWindow.xaml @@ -1,14 +1,15 @@ - + - + diff --git a/src/Starward/MyWindows/SystemTrayWindow.xaml.cs b/src/Starward/MyWindows/SystemTrayWindow.xaml.cs index 18c0b35f6..0779e2218 100644 --- a/src/Starward/MyWindows/SystemTrayWindow.xaml.cs +++ b/src/Starward/MyWindows/SystemTrayWindow.xaml.cs @@ -2,6 +2,7 @@ using CommunityToolkit.Mvvm.Input; using Microsoft.UI.Windowing; using Microsoft.UI.Xaml; +using Starward.Frameworks; using Starward.Helpers; using System; using System.IO; diff --git a/src/Starward/MyWindows/TestUrlProtocolWindow.xaml b/src/Starward/MyWindows/TestUrlProtocolWindow.xaml index 632e65a55..db5bc2fe8 100644 --- a/src/Starward/MyWindows/TestUrlProtocolWindow.xaml +++ b/src/Starward/MyWindows/TestUrlProtocolWindow.xaml @@ -1,10 +1,11 @@ - + - + diff --git a/src/Starward/MyWindows/TestUrlProtocolWindow.xaml.cs b/src/Starward/MyWindows/TestUrlProtocolWindow.xaml.cs index e82566756..1d578f649 100644 --- a/src/Starward/MyWindows/TestUrlProtocolWindow.xaml.cs +++ b/src/Starward/MyWindows/TestUrlProtocolWindow.xaml.cs @@ -2,6 +2,7 @@ using Microsoft.UI.Windowing; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Media; +using Starward.Frameworks; using System; using System.Diagnostics; using System.Linq; @@ -53,7 +54,7 @@ private void InitializeWindow() - public override nint WindowSubclassProc(HWND hWnd, uint uMsg, nint wParam, nint lParam, nuint uIdSubclass, nint dwRefData) + protected override nint WindowSubclassProc(HWND hWnd, uint uMsg, nint wParam, nint lParam, nuint uIdSubclass, nint dwRefData) { if (uMsg == (uint)User32.WindowMessage.WM_SYSCOMMAND) { diff --git a/src/Starward/MyWindows/UpdateContentWindow.xaml b/src/Starward/MyWindows/UpdateContentWindow.xaml index f384606b8..eca43206a 100644 --- a/src/Starward/MyWindows/UpdateContentWindow.xaml +++ b/src/Starward/MyWindows/UpdateContentWindow.xaml @@ -1,12 +1,13 @@ - + @@ -78,4 +79,4 @@ - + diff --git a/src/Starward/MyWindows/UpdateContentWindow.xaml.cs b/src/Starward/MyWindows/UpdateContentWindow.xaml.cs index 3a2346520..a4b4e42ea 100644 --- a/src/Starward/MyWindows/UpdateContentWindow.xaml.cs +++ b/src/Starward/MyWindows/UpdateContentWindow.xaml.cs @@ -6,6 +6,7 @@ using NuGet.Versioning; using Starward.Core.Metadata; using Starward.Core.Metadata.Github; +using Starward.Frameworks; using System; using System.Diagnostics; using System.IO; diff --git a/src/Starward/MyWindows/WelcomeWindow.xaml b/src/Starward/MyWindows/WelcomeWindow.xaml index 681d64ffa..d570ff993 100644 --- a/src/Starward/MyWindows/WelcomeWindow.xaml +++ b/src/Starward/MyWindows/WelcomeWindow.xaml @@ -1,12 +1,13 @@ - + - + diff --git a/src/Starward/MyWindows/WelcomeWindow.xaml.cs b/src/Starward/MyWindows/WelcomeWindow.xaml.cs index 7a432b74f..2a3a439c2 100644 --- a/src/Starward/MyWindows/WelcomeWindow.xaml.cs +++ b/src/Starward/MyWindows/WelcomeWindow.xaml.cs @@ -1,6 +1,7 @@ using Microsoft.UI.Windowing; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Media.Animation; +using Starward.Frameworks; using Starward.Pages.Welcome; using Starward.Services; using System; @@ -124,7 +125,7 @@ public void OpenMainWindow() - public override nint WindowSubclassProc(HWND hWnd, uint uMsg, nint wParam, nint lParam, nuint uIdSubclass, nint dwRefData) + protected override nint WindowSubclassProc(HWND hWnd, uint uMsg, nint wParam, nint lParam, nuint uIdSubclass, nint dwRefData) { if (uMsg == (uint)User32.WindowMessage.WM_SYSCOMMAND) {