diff --git a/src/BD.WTTS.Client.Plugins.GameTools/BD.WTTS.Client.Plugins.GameTools.csproj b/src/BD.WTTS.Client.Plugins.GameTools/BD.WTTS.Client.Plugins.GameTools.csproj index 570f2977195..e0c92f96572 100644 --- a/src/BD.WTTS.Client.Plugins.GameTools/BD.WTTS.Client.Plugins.GameTools.csproj +++ b/src/BD.WTTS.Client.Plugins.GameTools/BD.WTTS.Client.Plugins.GameTools.csproj @@ -12,6 +12,7 @@ + @@ -19,6 +20,7 @@ + diff --git a/src/BD.WTTS.Client.Plugins.GameTools/UI/Assets/movecross_hide.png b/src/BD.WTTS.Client.Plugins.GameTools/UI/Assets/movecross_hide.png new file mode 100644 index 00000000000..b297ee2e929 Binary files /dev/null and b/src/BD.WTTS.Client.Plugins.GameTools/UI/Assets/movecross_hide.png differ diff --git a/src/BD.WTTS.Client.Plugins.GameTools/UI/ViewModels/BorderlessGamePageViewModel.cs b/src/BD.WTTS.Client.Plugins.GameTools/UI/ViewModels/BorderlessGamePageViewModel.cs index b850d1f90a3..1b3c8e4d672 100644 --- a/src/BD.WTTS.Client.Plugins.GameTools/UI/ViewModels/BorderlessGamePageViewModel.cs +++ b/src/BD.WTTS.Client.Plugins.GameTools/UI/ViewModels/BorderlessGamePageViewModel.cs @@ -1,5 +1,6 @@ using Avalonia.Platform; using BD.WTTS.UI.Views.Pages; +using static System.Net.Mime.MediaTypeNames; namespace BD.WTTS.UI.ViewModels; @@ -44,7 +45,16 @@ public ObservableCollection WindowList public BorderlessGamePageViewModel() { + } + public async void CopyGameInfo_Click() + { + var text = $"{Strings.GameRelated_Borderless_Title}: {SelectWindow!.Title}\n" + + $"{Strings.GameRelated_Borderless_Title}: {SelectWindow!.Title}\n" + + $"{Strings.GameRelated_Borderless_ClassName}: {SelectWindow!.Name}\n" + + $"{Strings.GameRelated_Borderless_Path}: {SelectWindow!.Path}"; + await Clipboard2.SetTextAsync(text); + Toast.Show(ToastIcon.Success, Strings.CopyToClipboard); } public void Cross_MouseDown() @@ -52,7 +62,8 @@ public void Cross_MouseDown() windowApi.GetMoveMouseDownWindow((window) => { SelectWindow = window; - WindowList.Insert(0, window); + if (window is not null) + WindowList.Insert(0, window); }); } diff --git a/src/BD.WTTS.Client.Plugins.GameTools/UI/Views/BorderlessGamePage.axaml b/src/BD.WTTS.Client.Plugins.GameTools/UI/Views/BorderlessGamePage.axaml index 82e05a307df..bf5061885cb 100644 --- a/src/BD.WTTS.Client.Plugins.GameTools/UI/Views/BorderlessGamePage.axaml +++ b/src/BD.WTTS.Client.Plugins.GameTools/UI/Views/BorderlessGamePage.axaml @@ -10,7 +10,7 @@ xmlns:spp="https://steampp.net/ui" xmlns:ui="using:FluentAvalonia.UI.Controls" Title="游戏无边框窗口化" - d:DesignHeight="450" + d:DesignHeight="850" d:DesignWidth="800" x:CompileBindings="True" x:DataType="spp:BorderlessGamePageViewModel" @@ -103,102 +103,214 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/BD.WTTS.Client.Plugins.GameTools/UI/Views/BorderlessGamePage.axaml.cs b/src/BD.WTTS.Client.Plugins.GameTools/UI/Views/BorderlessGamePage.axaml.cs index 5ae13fe3a06..abcdee8a676 100644 --- a/src/BD.WTTS.Client.Plugins.GameTools/UI/Views/BorderlessGamePage.axaml.cs +++ b/src/BD.WTTS.Client.Plugins.GameTools/UI/Views/BorderlessGamePage.axaml.cs @@ -6,5 +6,16 @@ public BorderlessGamePage() { InitializeComponent(); DataContext ??= new BorderlessGamePageViewModel(); + + move.PointerPressed += (_, _) => move.IsVisible = false; + move.PointerReleased += (_, _) => move.IsVisible = true; + + const int threeLineButtonWidth = 554; + const int fourLineButtonWidth = 418; + Observable.FromEventPattern(ButtonGroup, nameof(ButtonGroup.SizeChanged)) + .Select(eventPattern => eventPattern.EventArgs.NewSize.Width) + .Select(width => width < fourLineButtonWidth ? 200 : width < threeLineButtonWidth ? 150 : 100) + .DistinctUntilChanged() + .Subscribe(newHeight => ButtonGroup.Height = newHeight); } } diff --git a/src/BD.WTTS.Client/Services.Implementation/Platform/Windows/WindowsPlatformServiceImpl.NativeWindow.cs b/src/BD.WTTS.Client/Services.Implementation/Platform/Windows/WindowsPlatformServiceImpl.NativeWindow.cs index e1ca1900ec4..c7d5c4bc5ca 100644 --- a/src/BD.WTTS.Client/Services.Implementation/Platform/Windows/WindowsPlatformServiceImpl.NativeWindow.cs +++ b/src/BD.WTTS.Client/Services.Implementation/Platform/Windows/WindowsPlatformServiceImpl.NativeWindow.cs @@ -11,8 +11,8 @@ partial class WindowsPlatformServiceImpl /// /// 拖拽指针获取目标窗口 /// - /// 目标窗口回调 - public void GetMoveMouseDownWindow(Action action) + /// 目标窗口回调 + public void GetMoveMouseDownWindow(Action updateWindowCallback) { void MouseHook_OnMouseUp(object? sender, PointD p) { @@ -27,11 +27,9 @@ void MouseHook_OnMouseUp(object? sender, PointD p) //Name = Control.MousePosition.X + "," + Control.MousePosition.Y; User32.GetCursorPos(out var pointInt); var handle = User32.WindowFromPoint(pointInt); - Span title = stackalloc char[256]; - User32.GetWindowText(handle, title); // 得到窗口的标题 - Span className = stackalloc char[256]; - User32.GetClassName(handle, className); - // 得得到窗口的句柄 类名 + var title = User32.GetWindowText(handle); // 得到窗口的标题 + var className = User32.GetClassName(handle); + // 得到窗口的句柄 类名 //SelectWindow.Title = title.ToString(); //SelectWindow.ClassName = className.ToString(); User32.GetWindowThreadProcessId(handle, out int pid); @@ -39,6 +37,12 @@ void MouseHook_OnMouseUp(object? sender, PointD p) try { var process = Process.GetProcessById(pid); + if (process.Id == Environment.ProcessId) + { + updateWindowCallback?.Invoke(null!); + return; + } + string? path = null; if (process != null) { @@ -58,7 +62,7 @@ void MouseHook_OnMouseUp(object? sender, PointD p) process, path, process?.ProcessName); - action?.Invoke(window); + updateWindowCallback?.Invoke(window); } catch (Exception e) {