滚回 #137 和 #0875c50

This commit is contained in:
ZouJin 2023-09-01 02:19:41 +08:00
parent ebed8c191e
commit 7a419d1b52

View File

@ -1,7 +1,4 @@
using System.Windows.Forms;
using System.Windows.Interop;
using System.Drawing;
using VPet_Simulator.Core;
using VPet_Simulator.Core;
namespace VPet_Simulator.Windows
{
@ -16,43 +13,24 @@ namespace VPet_Simulator.Windows
this.mw = mw;
}
private Rectangle? _screenBorder = null;
private Rectangle ScreenBorder
public double GetWindowsDistanceDown()
{
get
{
if (_screenBorder == null)
{
var windowInteropHelper = new WindowInteropHelper(mw);
var currentScreen = Screen.FromHandle(windowInteropHelper.Handle);
_screenBorder = currentScreen.Bounds;
}
return (Rectangle)_screenBorder;
}
}
public void ClearScreenBorderCache()
{
_screenBorder = null;
return mw.Dispatcher.Invoke(() => System.Windows.SystemParameters.PrimaryScreenHeight - mw.Top - mw.Height);
}
public double GetWindowsDistanceLeft()
{
return mw.Dispatcher.Invoke(() => mw.Left - ScreenBorder.X);
}
public double GetWindowsDistanceUp()
{
return mw.Dispatcher.Invoke(() => mw.Top - ScreenBorder.Y);
return mw.Dispatcher.Invoke(() => mw.Left);
}
public double GetWindowsDistanceRight()
{
return mw.Dispatcher.Invoke(() => ScreenBorder.Width + ScreenBorder.X - mw.Left - mw.Width);
return mw.Dispatcher.Invoke(() => System.Windows.SystemParameters.PrimaryScreenWidth - mw.Left - mw.Width);
}
public double GetWindowsDistanceDown()
public double GetWindowsDistanceUp()
{
return mw.Dispatcher.Invoke(() => ScreenBorder.Height + ScreenBorder.Y - mw.Top - mw.Height);
return mw.Dispatcher.Invoke(() => mw.Top);
}
public void MoveWindows(double X, double Y)
@ -61,7 +39,6 @@ namespace VPet_Simulator.Windows
{
mw.Left += X * ZoomRatio;
mw.Top += Y * ZoomRatio;
ClearScreenBorderCache();
});
}