From 12b03518eed7f57b98d295e0c3246e1396d9b391 Mon Sep 17 00:00:00 2001 From: zlsun Date: Mon, 16 Jun 2014 14:06:24 +0800 Subject: [PATCH] Add remember window position support. --- .gitignore | 2 ++ .../Storage/UserSettings/UserSettingStorage.cs | 6 ++++++ Wox/MainWindow.xaml.cs | 17 +++++++++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f6adb8394c..d25f19e773 100644 --- a/.gitignore +++ b/.gitignore @@ -117,3 +117,5 @@ UpgradeLog*.XML Wox/Images/websearch/Thumbs.db Wox/Images/Thumbs.db Wox/Wox.csproj + +*.sublime-* diff --git a/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs b/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs index da16cc9315..8a6f8a1935 100644 --- a/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs +++ b/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs @@ -44,6 +44,12 @@ namespace Wox.Infrastructure.Storage.UserSettings [JsonProperty] public List WebSearches { get; set; } + [JsonProperty] + public double WindowLeft { get; set; } + + [JsonProperty] + public double WindowTop { get; set; } + [JsonProperty] public List ProgramSources { get; set; } diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index c7215905be..e48e743782 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -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();