From c3f553d7d1a88b5ac75c43cee59bf26fe9c799a9 Mon Sep 17 00:00:00 2001 From: YukkuriC <799433638@qq.com> Date: Tue, 5 Sep 2023 23:58:35 +0800 Subject: [PATCH] =?UTF-8?q?=E9=82=AA=E9=81=93api=E5=BA=94=E5=AF=B9?= =?UTF-8?q?=E6=9C=80=E5=A4=A7=E5=8C=96=E8=8E=B7=E5=8F=96=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WinDesign/winGameSetting.xaml.cs | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs index 9e7e1f2..061ac62 100644 --- a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs +++ b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs @@ -645,13 +645,31 @@ namespace VPet_Simulator.Windows UpdateMoveAreaText(); } + private static System.Reflection.FieldInfo leftGetter, topGetter; private void BtnSetMoveArea_Window_Click(object sender, RoutedEventArgs e) { var mwCtrl = mw.Core.Controller as MWController; - mwCtrl.ScreenBorder = new System.Drawing.Rectangle( - (int)Left, (int)Top, - (int)Width, (int)Height - ); + System.Drawing.Rectangle bounds; + if (WindowState == WindowState.Maximized) + { + // 反射捞一下左上角 + if (leftGetter == null) leftGetter = typeof(Window).GetField("_actualLeft", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); + if (topGetter == null) topGetter = typeof(Window).GetField("_actualTop", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); + var actualLeft = Convert.ToInt32(leftGetter.GetValue(this)); + var actualTop = Convert.ToInt32(topGetter.GetValue(this)); + bounds = new System.Drawing.Rectangle( + actualLeft, actualTop, + (int)ActualWidth, (int)ActualHeight + ); + } + else + { + bounds = new System.Drawing.Rectangle( + (int)Left, (int)Top, + (int)Width, (int)Height + ); + } + mwCtrl.ScreenBorder = bounds; UpdateMoveAreaText(); }