From abc2b5dd199259778a17c8c07c32e3eb0f6cc1d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BE=89=E9=B8=AD=E8=9B=8B?= Date: Thu, 29 Jan 2026 01:02:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E6=90=9C=E7=B4=A2=E7=AA=97=E5=8F=A3DPI?= =?UTF-8?q?=E7=BC=A9=E6=94=BE=E5=92=8C=E5=85=B3=E9=97=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复地图标签搜索窗口在高DPI缩放下的定位问题,调整计算方式以适配系统缩放比例。 同时确保地图点选择器关闭时同步隐藏搜索窗口,避免窗口残留。 --- BetterGenshinImpact/View/MaskWindow.xaml | 539 ++++++++++---------- BetterGenshinImpact/View/MaskWindow.xaml.cs | 26 +- 2 files changed, 298 insertions(+), 267 deletions(-) diff --git a/BetterGenshinImpact/View/MaskWindow.xaml b/BetterGenshinImpact/View/MaskWindow.xaml index b449be55..090609b2 100644 --- a/BetterGenshinImpact/View/MaskWindow.xaml +++ b/BetterGenshinImpact/View/MaskWindow.xaml @@ -11,6 +11,7 @@ xmlns:converters="clr-namespace:BetterGenshinImpact.View.Converters" xmlns:controls="clr-namespace:BetterGenshinImpact.View.Controls" xmlns:gif="https://github.com/XamlAnimatedGif/XamlAnimatedGif" + xmlns:sys="clr-namespace:System;assembly=System.Runtime" Title="MaskWindow" Width="500" Height="800" @@ -57,6 +58,8 @@ + 0.62 + -12 @@ -667,268 +670,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -960,6 +704,277 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BetterGenshinImpact/View/MaskWindow.xaml.cs b/BetterGenshinImpact/View/MaskWindow.xaml.cs index 18833388..234a5ef1 100644 --- a/BetterGenshinImpact/View/MaskWindow.xaml.cs +++ b/BetterGenshinImpact/View/MaskWindow.xaml.cs @@ -144,7 +144,11 @@ public partial class MaskWindow : Window return; } - (DataContext as MaskWindowViewModel)?.PointInfoPopup.CloseCommand.Execute(null); + if (DataContext is MaskWindowViewModel vm) + { + vm.PointInfoPopup.CloseCommand.Execute(null); + vm.IsMapPointPickerOpen = false; + } if (_mapLabelSearchWindow != null) { @@ -159,7 +163,11 @@ public partial class MaskWindow : Window return; } - (DataContext as MaskWindowViewModel)?.PointInfoPopup.CloseCommand.Execute(null); + if (DataContext is MaskWindowViewModel vm) + { + vm.PointInfoPopup.CloseCommand.Execute(null); + vm.IsMapPointPickerOpen = false; + } } private void OnLoaded(object sender, RoutedEventArgs e) @@ -249,6 +257,14 @@ public partial class MaskWindow : Window Dispatcher.Invoke(UpdateClickThroughState); } + if (e.PropertyName == nameof(MaskWindowViewModel.IsMapPointPickerOpen)) + { + if (_viewModel?.IsMapPointPickerOpen != true && _mapLabelSearchWindow != null) + { + Dispatcher.Invoke(() => _mapLabelSearchWindow.Hide()); + } + } + if (e.PropertyName == nameof(MaskWindowViewModel.MapPointLabels)) { Dispatcher.Invoke(() => @@ -385,8 +401,8 @@ public partial class MaskWindow : Window var point = textbox.PointToScreen(new Point(0, 0)); var popupHeight = _mapLabelSearchWindow.ActualHeight > 0 ? _mapLabelSearchWindow.ActualHeight : _mapLabelSearchWindow.Height; - _mapLabelSearchWindow.Left = point.X; - _mapLabelSearchWindow.Top = point.Y - popupHeight - 4; + _mapLabelSearchWindow.Left = point.X / DpiHelper.ScaleY; + _mapLabelSearchWindow.Top = (point.Y - 4) / DpiHelper.ScaleY - popupHeight; if (!_mapLabelSearchWindow.IsVisible) { @@ -604,4 +620,4 @@ file static class MaskWindowExtension style |= (int)User32.WindowStyles.WS_CHILD; _ = User32.SetWindowLong(hWnd, User32.WindowLongFlags.GWL_STYLE, style); } -} \ No newline at end of file +}