From 94f217f4d7533e1851676494c2edad00a6940a5c Mon Sep 17 00:00:00 2001 From: Yeechan Lu Date: Sun, 30 Mar 2014 15:42:33 +0800 Subject: [PATCH] Use a better method to calculate relative coordinates while moving among screens --- Wox/MainWindow.xaml.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index df5b560a2f..b221b88fe8 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -247,10 +247,10 @@ namespace Wox { var origScreen = Screen.FromRectangle(new Rectangle((int) Left, (int) Top, (int) ActualWidth, (int) ActualHeight)); var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position); - var croodX = (Left + ActualWidth / 2.0 - (origScreen.Bounds.Left + origScreen.Bounds.Right) / 2.0) / origScreen.Bounds.Width; - var croodY = (Top + ActualHeight / 2.0 - (origScreen.Bounds.Top + origScreen.Bounds.Bottom) / 2.0) / origScreen.Bounds.Height; - Left = croodX * screen.Bounds.Width - ActualWidth / 2.0 + (screen.Bounds.Left + screen.Bounds.Right) / 2.0; - Top = croodY * screen.Bounds.Height - ActualHeight / 2.0 + (screen.Bounds.Top + screen.Bounds.Bottom) / 2.0; + var coordX = (Left - origScreen.WorkingArea.Left)/(origScreen.WorkingArea.Width - ActualWidth); + var coordY = (Top - origScreen.WorkingArea.Top)/(origScreen.WorkingArea.Height - ActualHeight); + Left = (screen.WorkingArea.Width - ActualWidth)*coordX + screen.WorkingArea.Left; + Top = (screen.WorkingArea.Height - ActualHeight)*coordY + screen.WorkingArea.Top; } Show();