diff --git a/VPet-Simulator.Windows/Function/MWController.cs b/VPet-Simulator.Windows/Function/MWController.cs index d67b88e..43ef9df 100644 --- a/VPet-Simulator.Windows/Function/MWController.cs +++ b/VPet-Simulator.Windows/Function/MWController.cs @@ -1,4 +1,6 @@ -using VPet_Simulator.Core; +using System.Windows.Forms; +using System.Windows.Interop; +using VPet_Simulator.Core; namespace VPet_Simulator.Windows { @@ -13,26 +15,38 @@ namespace VPet_Simulator.Windows this.mw = mw; } - public double GetWindowsDistanceDown() - { - return mw.Dispatcher.Invoke(() => System.Windows.SystemParameters.PrimaryScreenHeight - mw.Top - mw.Height); - } - public double GetWindowsDistanceLeft() { return mw.Dispatcher.Invoke(() => mw.Left); } - public double GetWindowsDistanceRight() - { - return mw.Dispatcher.Invoke(() => System.Windows.SystemParameters.PrimaryScreenWidth - mw.Left - mw.Width); - } - public double GetWindowsDistanceUp() { return mw.Dispatcher.Invoke(() => mw.Top); } + public double GetWindowsDistanceRight() + { + return mw.Dispatcher.Invoke(() => + { + var windowInteropHelper = new WindowInteropHelper(mw); + var currentScreen = Screen.FromHandle(windowInteropHelper.Handle); + var currentScreenBorder = currentScreen.Bounds; + return currentScreenBorder.Width - mw.Left - mw.Width; + }); + } + + public double GetWindowsDistanceDown() + { + return mw.Dispatcher.Invoke(() => + { + var windowInteropHelper = new WindowInteropHelper(mw); + var currentScreen = Screen.FromHandle(windowInteropHelper.Handle); + var currentScreenBorder = currentScreen.Bounds; + return currentScreenBorder.Height - mw.Top - mw.Height; + }); + } + public void MoveWindows(double X, double Y) { mw.Dispatcher.Invoke(() => diff --git a/VPet-Simulator.Windows/WinDesign/winConsole.xaml b/VPet-Simulator.Windows/WinDesign/winConsole.xaml index 28bc300..a3c5207 100644 --- a/VPet-Simulator.Windows/WinDesign/winConsole.xaml +++ b/VPet-Simulator.Windows/WinDesign/winConsole.xaml @@ -1,108 +1,222 @@ - - - - -