From 4fb0279f9ab07e7a78fe840cb1338b2030aeb769 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Thu, 14 Aug 2014 19:45:48 +0800 Subject: [PATCH] Expose index suffix setting --- .../UserSettings/UserSettingStorage.cs | 14 +++----- .../Program/ProgramSetting.xaml | 2 +- .../ProgramSources/FileSystemProgramSource.cs | 2 +- .../Program/ProgramSuffixes.xaml | 35 ++++++------------- .../Program/ProgramSuffixes.xaml.cs | 22 ++++++------ 5 files changed, 27 insertions(+), 48 deletions(-) diff --git a/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs b/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs index 81de46546..d4e941a30 100644 --- a/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs +++ b/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs @@ -68,7 +68,7 @@ namespace Wox.Infrastructure.Storage.UserSettings public double Opacity { get; set; } [JsonProperty] - public List ProgramSuffixes { get; set; } + public string ProgramSuffixes { get; set; } [JsonProperty] public OpacityMode OpacityMode { get; set; } @@ -165,16 +165,10 @@ namespace Wox.Infrastructure.Storage.UserSettings { storage.CustomizedPluginConfigs = new List(); } - if (storage.ProgramSuffixes == null || storage.ProgramSuffixes.Count == 0) + if (string.IsNullOrEmpty(storage.ProgramSuffixes)) { - storage.ProgramSuffixes = new List() - { - "lnk", - "exe", - "appref-ms", - "bat" - }; - } + storage.ProgramSuffixes = "lnk;exe;appref-ms;bat"; + } } } diff --git a/Wox.Plugin.SystemPlugins/Program/ProgramSetting.xaml b/Wox.Plugin.SystemPlugins/Program/ProgramSetting.xaml index f2fe7fbb8..ded91a25c 100644 --- a/Wox.Plugin.SystemPlugins/Program/ProgramSetting.xaml +++ b/Wox.Plugin.SystemPlugins/Program/ProgramSetting.xaml @@ -17,7 +17,7 @@ - + diff --git a/Wox.Plugin.SystemPlugins/Program/ProgramSources/FileSystemProgramSource.cs b/Wox.Plugin.SystemPlugins/Program/ProgramSources/FileSystemProgramSource.cs index 3650f1a61..28e00f7fb 100644 --- a/Wox.Plugin.SystemPlugins/Program/ProgramSources/FileSystemProgramSource.cs +++ b/Wox.Plugin.SystemPlugins/Program/ProgramSources/FileSystemProgramSource.cs @@ -34,7 +34,7 @@ namespace Wox.Plugin.SystemPlugins.Program.ProgramSources { foreach (string file in Directory.GetFiles(path)) { - if (UserSettingStorage.Instance.ProgramSuffixes.Any(o => file.EndsWith("." + o))) + if (UserSettingStorage.Instance.ProgramSuffixes.Split(';').Any(o => file.EndsWith("." + o))) { Program p = CreateEntry(file); list.Add(p); diff --git a/Wox.Plugin.SystemPlugins/Program/ProgramSuffixes.xaml b/Wox.Plugin.SystemPlugins/Program/ProgramSuffixes.xaml index 9b2a8927c..82acfc2d2 100644 --- a/Wox.Plugin.SystemPlugins/Program/ProgramSuffixes.xaml +++ b/Wox.Plugin.SystemPlugins/Program/ProgramSuffixes.xaml @@ -4,29 +4,14 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" - d:DesignHeight="300" d:DesignWidth="300"> - - - - - - - - - - - - - - - - - - - - + diff --git a/Wox.Plugin.SystemPlugins/Program/ProgramSuffixes.xaml.cs b/Wox.Plugin.SystemPlugins/Program/ProgramSuffixes.xaml.cs index 49e2ea9c7..62bb90a03 100644 --- a/Wox.Plugin.SystemPlugins/Program/ProgramSuffixes.xaml.cs +++ b/Wox.Plugin.SystemPlugins/Program/ProgramSuffixes.xaml.cs @@ -11,6 +11,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Wox.Infrastructure.Storage.UserSettings; namespace Wox.Plugin.SystemPlugins.Program { @@ -22,21 +23,20 @@ namespace Wox.Plugin.SystemPlugins.Program public ProgramSuffixes() { InitializeComponent(); + + tbSuffixes.Text = UserSettingStorage.Instance.ProgramSuffixes; } - private void btnDelete_OnClick(object sender, RoutedEventArgs e) + private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { - - } + if (string.IsNullOrEmpty(tbSuffixes.Text)) + { + MessageBox.Show("File suffixes can't be empty"); + return; + } - private void btnEdit_OnClick(object sender, RoutedEventArgs e) - { - - } - - private void btnAdd_OnClick(object sender, RoutedEventArgs e) - { - + UserSettingStorage.Instance.ProgramSuffixes = tbSuffixes.Text; + MessageBox.Show("Sucessfully update file suffixes"); } } }