From cb56b9822268a4020564b871caed5116a482c4b3 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Sun, 22 May 2016 20:50:06 +0100 Subject: [PATCH] Databinding for hotkey tab part of #660 --- Wox.Core/UserSettings/PluginHotkey.cs | 2 + Wox.Core/UserSettings/PluginSettings.cs | 2 + Wox.Core/UserSettings/Settings.cs | 3 +- Wox/CustomQueryHotkeySetting.xaml.cs | 4 +- Wox/SettingWindow.xaml | 76 ++++++++++++------------- Wox/SettingWindow.xaml.cs | 33 +++++------ Wox/ViewModel/SettingWindowViewModel.cs | 14 +++-- 7 files changed, 66 insertions(+), 68 deletions(-) diff --git a/Wox.Core/UserSettings/PluginHotkey.cs b/Wox.Core/UserSettings/PluginHotkey.cs index cedeaf0886..02b607b11a 100644 --- a/Wox.Core/UserSettings/PluginHotkey.cs +++ b/Wox.Core/UserSettings/PluginHotkey.cs @@ -1,7 +1,9 @@ using System; +using PropertyChanged; namespace Wox.Core.UserSettings { + [ImplementPropertyChanged] public class CustomPluginHotkey { public string Hotkey { get; set; } diff --git a/Wox.Core/UserSettings/PluginSettings.cs b/Wox.Core/UserSettings/PluginSettings.cs index bc19879129..0d9430325b 100644 --- a/Wox.Core/UserSettings/PluginSettings.cs +++ b/Wox.Core/UserSettings/PluginSettings.cs @@ -1,10 +1,12 @@ using System.Collections.Generic; using System.Linq; +using PropertyChanged; using Wox.Core.Plugin; using Wox.Plugin; namespace Wox.Core.UserSettings { + [ImplementPropertyChanged] public class PluginsSettings { public string PythonDirectory { get; set; } diff --git a/Wox.Core/UserSettings/Settings.cs b/Wox.Core/UserSettings/Settings.cs index 068e8217a9..3ca977abfd 100644 --- a/Wox.Core/UserSettings/Settings.cs +++ b/Wox.Core/UserSettings/Settings.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Drawing; using Newtonsoft.Json; using PropertyChanged; @@ -31,7 +32,7 @@ namespace Wox.Core.UserSettings // Order defaults to 0 or -1, so 1 will let this property appear last [JsonProperty(Order = 1)] public PluginsSettings PluginSettings { get; set; } = new PluginsSettings(); - public List CustomPluginHotkeys { get; set; } = new List(); + public ObservableCollection CustomPluginHotkeys { get; set; } = new ObservableCollection(); [Obsolete] public double Opacity { get; set; } = 1; diff --git a/Wox/CustomQueryHotkeySetting.xaml.cs b/Wox/CustomQueryHotkeySetting.xaml.cs index 0132756ab4..48194359ff 100644 --- a/Wox/CustomQueryHotkeySetting.xaml.cs +++ b/Wox/CustomQueryHotkeySetting.xaml.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Windows; using NHotkey; @@ -41,7 +42,7 @@ namespace Wox if (_settings.CustomPluginHotkeys == null) { - _settings.CustomPluginHotkeys = new List(); + _settings.CustomPluginHotkeys = new ObservableCollection(); } var pluginHotkey = new CustomPluginHotkey @@ -78,7 +79,6 @@ namespace Wox MessageBox.Show(InternationalizationManager.Instance.GetTranslation("succeed")); } - _settingWidow.ReloadCustomPluginHotkeyView(); Close(); } diff --git a/Wox/SettingWindow.xaml b/Wox/SettingWindow.xaml index 05bb39f69d..1db2782b90 100644 --- a/Wox/SettingWindow.xaml +++ b/Wox/SettingWindow.xaml @@ -3,6 +3,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:wox="clr-namespace:Wox" + xmlns:s="clr-namespace:Wox.Core.UserSettings;assembly=Wox.Core" xmlns:vm="clr-namespace:Wox.ViewModel" x:Class="Wox.SettingWindow" mc:Ignorable="d" @@ -237,56 +238,51 @@ - - + - - - + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -