diff --git a/Wox.Core/Wox.Core.csproj b/Wox.Core/Wox.Core.csproj
index 908689e1f2..fcba73e752 100644
--- a/Wox.Core/Wox.Core.csproj
+++ b/Wox.Core/Wox.Core.csproj
@@ -13,6 +13,8 @@
512
..\
+
+
true
@@ -80,6 +82,10 @@
+
+ ..\packages\PropertyChanged.Fody.1.51.0\lib\dotnet\PropertyChanged.dll
+ False
+
..\packages\Splat.1.6.2\lib\Net45\Splat.dll
True
diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs
index 121c6c17e4..c3a2422a02 100644
--- a/Wox/App.xaml.cs
+++ b/Wox/App.xaml.cs
@@ -42,13 +42,13 @@ namespace Wox
{
RegisterDispatcherUnhandledException();
- var storage = new JsonStrorage();
- _settings = storage.Load();
+ var settingVM = new SettingWindowViewModel();
+ _settings = settingVM.Settings;
PluginManager.LoadPlugins(_settings.PluginSettings);
- var vm = new MainViewModel(_settings, storage);
- var window = new MainWindow(_settings, vm);
- API = new PublicAPIInstance(_settings, vm);
+ var mainVM = new MainViewModel(_settings);
+ var window = new MainWindow(_settings, mainVM);
+ API = new PublicAPIInstance(settingVM, mainVM);
PluginManager.InitializePlugins(API);
ImageLoader.PreloadImages();
diff --git a/Wox/PublicAPIInstance.cs b/Wox/PublicAPIInstance.cs
index 2078a27ffe..693edfb48d 100644
--- a/Wox/PublicAPIInstance.cs
+++ b/Wox/PublicAPIInstance.cs
@@ -20,13 +20,13 @@ namespace Wox
{
public class PublicAPIInstance : IPublicAPI
{
- private readonly Settings _settings;
+ private readonly SettingWindowViewModel _settingsViewModel;
#region Constructor
- public PublicAPIInstance(Settings settings, MainViewModel mainVM)
+ public PublicAPIInstance(SettingWindowViewModel settingsViewModel, MainViewModel mainVM)
{
- _settings = settings;
+ _settingsViewModel = settingsViewModel;
MainVM = mainVM;
//_settings = settings;
GlobalHotkey.Instance.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
@@ -100,7 +100,7 @@ namespace Wox
{
Application.Current.Dispatcher.Invoke(() =>
{
- SettingWindow sw = SingletonWindowOpener.Open(this, _settings);
+ SettingWindow sw = SingletonWindowOpener.Open(this, _settingsViewModel);
sw.SwitchTo(tabName);
});
}
diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs
index cec4abb3a0..086e2bff18 100644
--- a/Wox/SettingWindow.xaml.cs
+++ b/Wox/SettingWindow.xaml.cs
@@ -37,10 +37,11 @@ namespace Wox
private bool themeTabLoaded;
private Settings _settings;
- public SettingWindow(IPublicAPI api, Settings settings)
+ public SettingWindow(IPublicAPI api, SettingWindowViewModel viewModel)
{
InitializeComponent();
- _settings = settings;
+ _settings = viewModel.Settings;
+ DataContext = viewModel;
_api = api;
ResultListBoxPreview.DataContext = new ResultsViewModel(_settings);
Loaded += Setting_Loaded;
diff --git a/Wox/ViewModel/MainViewModel.cs b/Wox/ViewModel/MainViewModel.cs
index 780c6d6e91..04c08bbce1 100644
--- a/Wox/ViewModel/MainViewModel.cs
+++ b/Wox/ViewModel/MainViewModel.cs
@@ -38,7 +38,6 @@ namespace Wox.ViewModel
private string _queryTextBeforeLoadContextMenu;
private string _queryText;
- private readonly JsonStrorage _settingsStorage;
private readonly JsonStrorage _queryHistoryStorage;
private readonly JsonStrorage _userSelectedRecordStorage;
private readonly JsonStrorage _topMostRecordStorage;
@@ -55,14 +54,13 @@ namespace Wox.ViewModel
#region Constructor
- public MainViewModel(Settings settings, JsonStrorage storage)
+ public MainViewModel(Settings settings)
{
_saved = false;
_queryTextBeforeLoadContextMenu = "";
_queryText = "";
_lastQuery = new Query();
- _settingsStorage = storage;
_settings = settings;
// happlebao todo temp fix for instance code logic
@@ -659,7 +657,6 @@ namespace Wox.ViewModel
{
if (!_saved)
{
- _settingsStorage.Save();
_queryHistoryStorage.Save();
_userSelectedRecordStorage.Save();
_topMostRecordStorage.Save();
diff --git a/Wox/ViewModel/SettingWindowViewModel.cs b/Wox/ViewModel/SettingWindowViewModel.cs
new file mode 100644
index 0000000000..0258caefef
--- /dev/null
+++ b/Wox/ViewModel/SettingWindowViewModel.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Wox.Core.Resource;
+using Wox.Core.UserSettings;
+using Wox.Infrastructure.Storage;
+
+namespace Wox.ViewModel
+{
+ public class SettingWindowViewModel
+ {
+ private readonly JsonStrorage _storage;
+ public Settings Settings { get; set; }
+ public List Languages => InternationalizationManager.Instance.LoadAvailableLanguages();
+ public IEnumerable MaxResultsRange => Enumerable.Range(2, 16);
+ public SettingWindowViewModel()
+ {
+ _storage = new JsonStrorage();
+ Settings = _storage.Load();
+ }
+
+ public void Save()
+ {
+ _storage.Save();
+ }
+ }
+}
diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj
index 46082766a9..d4badef67c 100644
--- a/Wox/Wox.csproj
+++ b/Wox/Wox.csproj
@@ -30,6 +30,8 @@
1.0.0.%2a
false
true
+
+
AnyCPU
@@ -167,6 +169,7 @@
+
MSBuild:Compile
Designer