diff --git a/VPet-Simulator.Windows/Function/MWController.cs b/VPet-Simulator.Windows/Function/MWController.cs index 4e0baea..e1d5987 100644 --- a/VPet-Simulator.Windows/Function/MWController.cs +++ b/VPet-Simulator.Windows/Function/MWController.cs @@ -16,38 +16,30 @@ namespace VPet_Simulator.Windows this.mw = mw; } - private bool _screenDetected = false; - private Rectangle _screenBorder; - private bool _isPrimaryScreen = true; - public bool IsPrimaryScreen + private static Rectangle _screenBorder; + private static bool _isPrimaryScreen = true; + public static bool IsPrimaryScreen { get { - if(!_screenDetected) DetectCurrentScreen(); return _isPrimaryScreen; } } - public Rectangle ScreenBorder + public static Rectangle ScreenBorder { get { - if (!_screenDetected) DetectCurrentScreen(); return _screenBorder; } + set + { + _screenBorder = value; + _isPrimaryScreen = false; + } } - private void DetectCurrentScreen() + public static void ResetScreenBorder() { - var windowInteropHelper = new WindowInteropHelper(mw); - var currentScreen = Screen.FromHandle(windowInteropHelper.Handle); - // TODO 多屏+非100%缩放下以上API跟Left、Top一样都是错的 - - _isPrimaryScreen = currentScreen.Primary; - _screenBorder = currentScreen.Bounds; - _screenDetected = true; - } - public void ClearScreenBorderCache() - { - _screenDetected = false; + _isPrimaryScreen = true; } public double GetWindowsDistanceLeft() @@ -92,7 +84,6 @@ namespace VPet_Simulator.Windows { mw.Left += X * ZoomRatio; mw.Top += Y * ZoomRatio; - ClearScreenBorderCache(); }); } diff --git a/VPet-Simulator.Windows/MainWindow.xaml.cs b/VPet-Simulator.Windows/MainWindow.xaml.cs index 9931343..17c76eb 100644 --- a/VPet-Simulator.Windows/MainWindow.xaml.cs +++ b/VPet-Simulator.Windows/MainWindow.xaml.cs @@ -655,7 +655,6 @@ namespace VPet_Simulator.Windows Main.DisplayToNomal(); Left = (SystemParameters.PrimaryScreenWidth - Width) / 2; Top = (SystemParameters.PrimaryScreenHeight - Height) / 2; - (Core.Controller as MWController).ClearScreenBorderCache(); })); m_menu.MenuItems.Add(new MenuItem("反馈中心".Translate(), (x, y) => { new winReport(this).Show(); })); m_menu.MenuItems.Add(new MenuItem("开发控制台".Translate(), (x, y) => { new winConsole(this).Show(); })); diff --git a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml index 6f4fec0..7145431 100644 --- a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml +++ b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml @@ -377,6 +377,8 @@ + + - + @@ -491,7 +493,37 @@ - + + + + + + + + + + + + + + diff --git a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs index 3d5d4d8..2609522 100644 --- a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs +++ b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs @@ -615,6 +615,25 @@ namespace VPet_Simulator.Windows } } + private void BtnSetScreen_Default_Click(object sender, RoutedEventArgs e) + { + MWController.ResetScreenBorder(); + } + + private void BtnSetScreen_DetectScreen_Click(object sender, RoutedEventArgs e) + { + var windowInteropHelper = new System.Windows.Interop.WindowInteropHelper(mw); + var currentScreen = System.Windows.Forms.Screen.FromHandle(windowInteropHelper.Handle); + MWController.ScreenBorder = currentScreen.Bounds; + } + + private void BtnSetScreen_Window_Click(object sender, RoutedEventArgs e) + { + MWController.ScreenBorder = new System.Drawing.Rectangle( + (int)Left, (int)Top, + (int)Width, (int)Height + ); + } private void hyper_moreInfo(object sender, RoutedEventArgs e) {