靠近边缘时重新归位

This commit is contained in:
YuanYixiao0014 2023-12-01 00:47:33 -05:00
parent f5a0341020
commit dfa4d3df3e
3 changed files with 36 additions and 0 deletions

View File

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

View File

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

View File

@ -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;