Add remember window position support.

This commit is contained in:
zlsun 2014-06-16 14:06:24 +08:00
parent fcd3a86589
commit 12b03518ee
3 changed files with 23 additions and 2 deletions

2
.gitignore vendored
View File

@ -117,3 +117,5 @@ UpgradeLog*.XML
Wox/Images/websearch/Thumbs.db
Wox/Images/Thumbs.db
Wox/Wox.csproj
*.sublime-*

View File

@ -44,6 +44,12 @@ namespace Wox.Infrastructure.Storage.UserSettings
[JsonProperty]
public List<WebSearch> WebSearches { get; set; }
[JsonProperty]
public double WindowLeft { get; set; }
[JsonProperty]
public double WindowTop { get; set; }
[JsonProperty]
public List<ProgramSource> ProgramSources { get; set; }

View File

@ -140,13 +140,26 @@ namespace Wox {
}
void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
UserSettingStorage.Instance.WindowLeft = Left;
UserSettingStorage.Instance.WindowTop = Top;
UserSettingStorage.Instance.Save();
this.HideWox();
e.Cancel = true;
}
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) {
Left = (SystemParameters.PrimaryScreenWidth - ActualWidth) / 2;
Top = (SystemParameters.PrimaryScreenHeight - ActualHeight) / 3;
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;
}
Plugins.Init();