From 826c5717738754c2d72d3c636a3c1f28c1685ac6 Mon Sep 17 00:00:00 2001 From: Hakoyu Date: Sun, 27 Aug 2023 20:58:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E5=BC=80=E5=8F=91=E8=80=85=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=8F=B0=E6=B7=BB=E5=8A=A0=E7=A7=BB=E5=8A=A8=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=20=E5=AE=9E=E7=8E=B0=20#109?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Function/MWController.cs | 36 +- .../WinDesign/winConsole.xaml | 326 ++++++++++++------ .../WinDesign/winConsole.xaml.cs | 20 ++ 3 files changed, 265 insertions(+), 117 deletions(-) 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 @@ - - - - -