From dfa4d3df3e316f3997a86933d0b3a54b27810946 Mon Sep 17 00:00:00 2001 From: YuanYixiao0014 <1014346709@qq.com> Date: Fri, 1 Dec 2023 00:47:33 -0500 Subject: [PATCH] =?UTF-8?q?=E9=9D=A0=E8=BF=91=E8=BE=B9=E7=BC=98=E6=97=B6?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E5=BD=92=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Core/Display/MainDisplay.cs | 1 + VPet-Simulator.Core/Handle/IController.cs | 6 ++++ .../Function/MWController.cs | 29 +++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/VPet-Simulator.Core/Display/MainDisplay.cs b/VPet-Simulator.Core/Display/MainDisplay.cs index 08f3251..b325e11 100644 --- a/VPet-Simulator.Core/Display/MainDisplay.cs +++ b/VPet-Simulator.Core/Display/MainDisplay.cs @@ -28,6 +28,7 @@ namespace VPet_Simulator.Core /// public void DisplayToNomal() { + this.Core.Controller.ResetPosition(); switch (State) { default: diff --git a/VPet-Simulator.Core/Handle/IController.cs b/VPet-Simulator.Core/Handle/IController.cs index 2456661..2fd018d 100644 --- a/VPet-Simulator.Core/Handle/IController.cs +++ b/VPet-Simulator.Core/Handle/IController.cs @@ -49,6 +49,12 @@ /// 显示面板窗体 /// void ShowPanel(); + + /// + /// 在边缘时重新靠边,防止被阻挡 + /// + void ResetPosition(); + /// /// 启用计算等数据功能 /// diff --git a/VPet-Simulator.Windows/Function/MWController.cs b/VPet-Simulator.Windows/Function/MWController.cs index 939ab50..f2ebcb6 100644 --- a/VPet-Simulator.Windows/Function/MWController.cs +++ b/VPet-Simulator.Windows/Function/MWController.cs @@ -107,6 +107,35 @@ namespace VPet_Simulator.Windows panelWindow.Show(); } + public void ResetPosition() + { + mw.Dispatcher.Invoke(() => + { + if (RePostionActive) + { + if (mw.Core.Controller.GetWindowsDistanceUp() < -0.25 * mw.Height && mw.Core.Controller.GetWindowsDistanceDown() < System.Windows.SystemParameters.PrimaryScreenHeight) + { + mw.Core.Controller.MoveWindows(0, -mw.Core.Controller.GetWindowsDistanceUp() / mw.Core.Controller.ZoomRatio); + } + else if (mw.Core.Controller.GetWindowsDistanceDown() < -0.25 * mw.Height && mw.Core.Controller.GetWindowsDistanceUp() < System.Windows.SystemParameters.PrimaryScreenHeight) + { + mw.Core.Controller.MoveWindows(0, mw.Core.Controller.GetWindowsDistanceDown() / mw.Core.Controller.ZoomRatio); + } + if (mw.Core.Controller.GetWindowsDistanceLeft() < -0.25 * mw.Width && mw.Core.Controller.GetWindowsDistanceRight() < System.Windows.SystemParameters.PrimaryScreenWidth) + { + mw.Core.Controller.MoveWindows(-mw.Core.Controller.GetWindowsDistanceLeft() / mw.Core.Controller.ZoomRatio, 0); + } + else if (mw.Core.Controller.GetWindowsDistanceRight() < -0.25 * mw.Width && mw.Core.Controller.GetWindowsDistanceLeft() < System.Windows.SystemParameters.PrimaryScreenWidth) + { + mw.Core.Controller.MoveWindows(mw.Core.Controller.GetWindowsDistanceRight() / mw.Core.Controller.ZoomRatio, 0); + } + } + }); + } + + + public bool RePostionActive = true; + public double ZoomRatio => mw.Set.ZoomLevel; public int PressLength => mw.Set.PressLength;