This commit is contained in:
ZouJin 2023-12-01 15:10:49 +08:00
commit 69c64b83ae
3 changed files with 36 additions and 0 deletions

View File

@ -28,6 +28,7 @@ namespace VPet_Simulator.Core
/// </summary> /// </summary>
public void DisplayToNomal() public void DisplayToNomal()
{ {
this.Core.Controller.ResetPosition();
switch (State) switch (State)
{ {
default: default:

View File

@ -49,6 +49,12 @@
/// 显示面板窗体 /// 显示面板窗体
/// </summary> /// </summary>
void ShowPanel(); void ShowPanel();
/// <summary>
/// 在边缘时重新靠边,防止被阻挡
/// </summary>
void ResetPosition();
/// <summary> /// <summary>
/// 启用计算等数据功能 /// 启用计算等数据功能
/// </summary> /// </summary>

View File

@ -107,6 +107,35 @@ namespace VPet_Simulator.Windows
panelWindow.Show(); 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 double ZoomRatio => mw.Set.ZoomLevel;
public int PressLength => mw.Set.PressLength; public int PressLength => mw.Set.PressLength;