diff --git a/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs index 97456bea1..b959cc518 100644 --- a/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs +++ b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs @@ -49,14 +49,15 @@ private void ButtonAdd_OnClick(object sender, RoutedEventArgs e) if(_editing == null) { - _settings.ProgramSources.Add(new ProgramSource + var source = new ProgramSource { Location = Directory.Text, MaxDepth = max, Suffixes = Suffixes.Text.Split(ProgramSource.SuffixSeperator), Type = "FileSystemProgramSource", Enabled = true - }); + }; + _settings.ProgramSources.Add(source); } else { diff --git a/Plugins/Wox.Plugin.Program/StringEmptyConverter.cs b/Plugins/Wox.Plugin.Program/LocationConverter.cs similarity index 53% rename from Plugins/Wox.Plugin.Program/StringEmptyConverter.cs rename to Plugins/Wox.Plugin.Program/LocationConverter.cs index d09806362..bd28bc944 100644 --- a/Plugins/Wox.Plugin.Program/StringEmptyConverter.cs +++ b/Plugins/Wox.Plugin.Program/LocationConverter.cs @@ -5,20 +5,26 @@ namespace Wox.Plugin.Program { - public class StringEmptyConverter : MarkupExtension, IValueConverter + public class LocationConverter : MarkupExtension, IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - return string.IsNullOrEmpty((string)value) ? parameter : value; + var text = value as string; + if (string.IsNullOrEmpty(text)) + { + return string.Empty; + } + else + { + return text; + } } - public object ConvertBack( - object value, Type targetType, object parameter, CultureInfo culture) + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotSupportedException(); } - public override object ProvideValue(IServiceProvider serviceProvider) { return this; diff --git a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml index af8616cab..5711e2383 100644 --- a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml +++ b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml @@ -28,14 +28,14 @@ - + - + diff --git a/Plugins/Wox.Plugin.Program/SuffixesConverter.cs b/Plugins/Wox.Plugin.Program/SuffixesConverter.cs new file mode 100644 index 000000000..11d76e5b3 --- /dev/null +++ b/Plugins/Wox.Plugin.Program/SuffixesConverter.cs @@ -0,0 +1,33 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Wox.Plugin.Program +{ + public class SuffixesConvert : MarkupExtension, IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + var text = value as string[]; + if (text != null) + { + return string.Join("", text); + } + else + { + return string.Empty; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotSupportedException(); + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} diff --git a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj index 4d2807a9c..4b38f99d9 100644 --- a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj +++ b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj @@ -62,6 +62,7 @@ + @@ -77,7 +78,7 @@ ProgramSuffixes.xaml - +