mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-13 11:09:28 +08:00
fix #251 add auto center Wox option
This commit is contained in:
parent
b1a97eca39
commit
d93c705737
@ -83,6 +83,9 @@ namespace Wox.Core.UserSettings
|
||||
[JsonProperty]
|
||||
public bool HideWhenDeactive { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public bool RememberLastLaunchLocation { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string ProxyServer { get; set; }
|
||||
|
||||
@ -131,6 +134,7 @@ namespace Wox.Core.UserSettings
|
||||
LeaveCmdOpen = false;
|
||||
HideWhenDeactive = false;
|
||||
CustomPluginHotkeys = new List<CustomPluginHotkey>();
|
||||
RememberLastLaunchLocation = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
<system:String x:Key="cancelTopMostInThisQuery">Cancel topmost in this query</system:String>
|
||||
<system:String x:Key="executeQuery">Execute query:{0}</system:String>
|
||||
<system:String x:Key="lastExecuteTime">Last execute time:{0}</system:String>
|
||||
|
||||
|
||||
<!--Setting General-->
|
||||
<system:String x:Key="woxsettings">Wox Settings</system:String>
|
||||
@ -17,8 +16,10 @@
|
||||
<system:String x:Key="startWoxOnSystemStartup">Start Wox on system startup</system:String>
|
||||
<system:String x:Key="hideWoxWhenLoseFocus">Hide Wox when loses focus</system:String>
|
||||
<system:String x:Key="dontPromptUpdateMsg">Don't show upgrade msg if new version available</system:String>
|
||||
<system:String x:Key="rememberLastLocation">Remember last launch location</system:String>
|
||||
<system:String x:Key="language">Language</system:String>
|
||||
|
||||
|
||||
<!--Setting Plugin-->
|
||||
<system:String x:Key="plugin">Plugin</system:String>
|
||||
<system:String x:Key="browserMorePlugins">Browse more plugins</system:String>
|
||||
|
@ -16,6 +16,7 @@
|
||||
<system:String x:Key="startWoxOnSystemStartup">开机启动</system:String>
|
||||
<system:String x:Key="hideWoxWhenLoseFocus">失去焦点时自动隐藏Wox</system:String>
|
||||
<system:String x:Key="dontPromptUpdateMsg">不显示新版本提示</system:String>
|
||||
<system:String x:Key="rememberLastLocation">记住上次启动位置</system:String>
|
||||
<system:String x:Key="language">语言</system:String>
|
||||
|
||||
<!--设置,插件-->
|
||||
|
@ -16,6 +16,7 @@
|
||||
<system:String x:Key="startWoxOnSystemStartup">開機啟動</system:String>
|
||||
<system:String x:Key="hideWoxWhenLoseFocus">失去焦點時自動隱藏Wox</system:String>
|
||||
<system:String x:Key="dontPromptUpdateMsg">不顯示新版本提示</system:String>
|
||||
<system:String x:Key="rememberLastLocation">记住上次启动位置</system:String>
|
||||
<system:String x:Key="language">語言</system:String>
|
||||
|
||||
<!--設置,插件-->
|
||||
|
@ -262,19 +262,8 @@ namespace Wox
|
||||
|
||||
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (UserSettingStorage.Instance.WindowLeft == 0
|
||||
&& UserSettingStorage.Instance.WindowTop == 0)
|
||||
{
|
||||
Left = UserSettingStorage.Instance.WindowLeft
|
||||
= (SystemParameters.PrimaryScreenWidth - ActualWidth) / 2;
|
||||
Top = UserSettingStorage.Instance.WindowTop
|
||||
= (SystemParameters.PrimaryScreenHeight - ActualHeight) / 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
Left = UserSettingStorage.Instance.WindowLeft;
|
||||
Top = UserSettingStorage.Instance.WindowTop;
|
||||
}
|
||||
Left = GetWindowsLeft();
|
||||
Top = GetWindowsTop();
|
||||
|
||||
InitProgressbarAnimation();
|
||||
WindowIntelopHelper.DisableControlBox(this);
|
||||
@ -282,6 +271,39 @@ namespace Wox
|
||||
new ShellContextMenuManager().GetContextMenus(@"c:\Windows\write.exe");
|
||||
}
|
||||
|
||||
private double GetWindowsLeft()
|
||||
{
|
||||
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
||||
if (UserSettingStorage.Instance.RememberLastLaunchLocation)
|
||||
{
|
||||
var origScreen = Screen.FromRectangle(new Rectangle((int)Left, (int)Top, (int)ActualWidth, (int)ActualHeight));
|
||||
var coordX = (Left - origScreen.WorkingArea.Left) / (origScreen.WorkingArea.Width - ActualWidth);
|
||||
UserSettingStorage.Instance.WindowLeft = (screen.WorkingArea.Width - ActualWidth) * coordX + screen.WorkingArea.Left;
|
||||
}
|
||||
else
|
||||
{
|
||||
UserSettingStorage.Instance.WindowLeft = (screen.WorkingArea.Width - ActualWidth) / 2 + screen.WorkingArea.Left;
|
||||
}
|
||||
|
||||
return UserSettingStorage.Instance.WindowLeft;
|
||||
}
|
||||
|
||||
private double GetWindowsTop()
|
||||
{
|
||||
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
||||
if (UserSettingStorage.Instance.RememberLastLaunchLocation)
|
||||
{
|
||||
var origScreen = Screen.FromRectangle(new Rectangle((int)Left, (int)Top, (int)ActualWidth, (int)ActualHeight));
|
||||
var coordY = (Top - origScreen.WorkingArea.Top) / (origScreen.WorkingArea.Height - ActualHeight);
|
||||
UserSettingStorage.Instance.WindowTop = (screen.WorkingArea.Height - ActualHeight) * coordY + screen.WorkingArea.Top;
|
||||
}
|
||||
else
|
||||
{
|
||||
UserSettingStorage.Instance.WindowTop = (screen.WorkingArea.Height - ActualHeight) / 4 + screen.WorkingArea.Top;
|
||||
}
|
||||
return UserSettingStorage.Instance.WindowTop;
|
||||
}
|
||||
|
||||
private void CheckUpdate()
|
||||
{
|
||||
UpdaterManager.Instance.PrepareUpdateReady += OnPrepareUpdateReady;
|
||||
@ -454,6 +476,7 @@ namespace Wox
|
||||
{
|
||||
QueryHistoryStorage.Instance.Reset();
|
||||
}
|
||||
|
||||
private int GetSearchDelay(string query)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(query) && PluginManager.IsInstantQuery(query))
|
||||
@ -506,15 +529,8 @@ namespace Wox
|
||||
private void ShowWox(bool selectAll = true)
|
||||
{
|
||||
UserSettingStorage.Instance.IncreaseActivateTimes();
|
||||
if (!double.IsNaN(Left) && !double.IsNaN(Top))
|
||||
{
|
||||
var origScreen = Screen.FromRectangle(new Rectangle((int)Left, (int)Top, (int)ActualWidth, (int)ActualHeight));
|
||||
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
||||
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;
|
||||
}
|
||||
Left = GetWindowsLeft();
|
||||
Top = GetWindowsTop();
|
||||
|
||||
Show();
|
||||
Activate();
|
||||
|
@ -31,6 +31,9 @@
|
||||
<CheckBox x:Name="cbDontPromptUpdateMsg" Margin="10">
|
||||
<TextBlock Text="{DynamicResource dontPromptUpdateMsg}" ></TextBlock>
|
||||
</CheckBox>
|
||||
<CheckBox x:Name="cbRememberLastLocation" Margin="10">
|
||||
<TextBlock Text="{DynamicResource rememberLastLocation}" ></TextBlock>
|
||||
</CheckBox>
|
||||
<StackPanel Margin="10" Orientation="Horizontal">
|
||||
<TextBlock Text="{DynamicResource language}"></TextBlock>
|
||||
<ComboBox Margin="10 0 0 0" Width="100" x:Name="cbLanguages" />
|
||||
|
@ -62,6 +62,18 @@ namespace Wox
|
||||
UserSettingStorage.Instance.Save();
|
||||
};
|
||||
|
||||
cbRememberLastLocation.Checked += (o, e) =>
|
||||
{
|
||||
UserSettingStorage.Instance.RememberLastLaunchLocation = true;
|
||||
UserSettingStorage.Instance.Save();
|
||||
};
|
||||
|
||||
cbRememberLastLocation.Unchecked += (o, e) =>
|
||||
{
|
||||
UserSettingStorage.Instance.RememberLastLaunchLocation = false;
|
||||
UserSettingStorage.Instance.Save();
|
||||
};
|
||||
|
||||
cbDontPromptUpdateMsg.Checked += (o, e) =>
|
||||
{
|
||||
UserSettingStorage.Instance.DontPromptUpdateMsg = true;
|
||||
@ -77,6 +89,7 @@ namespace Wox
|
||||
cbStartWithWindows.IsChecked = CheckApplicationIsStartupWithWindow();
|
||||
cbHideWhenDeactive.IsChecked = UserSettingStorage.Instance.HideWhenDeactive;
|
||||
cbDontPromptUpdateMsg.IsChecked = UserSettingStorage.Instance.DontPromptUpdateMsg;
|
||||
cbRememberLastLocation.IsChecked = UserSettingStorage.Instance.RememberLastLaunchLocation;
|
||||
|
||||
LoadLanguages();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user