diff --git a/Wox.Plugin.SystemPlugins/Sys.cs b/Wox.Plugin.SystemPlugins/Sys.cs index 9a9d28d80..fd85057f2 100644 --- a/Wox.Plugin.SystemPlugins/Sys.cs +++ b/Wox.Plugin.SystemPlugins/Sys.cs @@ -86,6 +86,24 @@ namespace Wox.Plugin.SystemPlugins } }); availableResults.Add(new Result + { + Title = "Restart Wox", + SubTitle = "Restart Wox", + Score = 110, + IcoPath = "Images\\restart.png", + Action = (c) => + { + ProcessStartInfo Info = new ProcessStartInfo(); + Info.Arguments = "/C ping 127.0.0.1 -n 1 && \"" + Application.ExecutablePath + "\""; + Info.WindowStyle = ProcessWindowStyle.Hidden; + Info.CreateNoWindow = true; + Info.FileName = "cmd.exe"; + Process.Start(Info); + context.CloseApp(); + return true; + } + }); + availableResults.Add(new Result { Title = "Setting", SubTitle = "Tweak this app", diff --git a/Wox/Images/restart.png b/Wox/Images/restart.png new file mode 100644 index 000000000..7230a66fc Binary files /dev/null and b/Wox/Images/restart.png differ diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index df5b560a2..b221b88fe 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();