From 479945455b6f60f1a916b3db7346342f11fb504d Mon Sep 17 00:00:00 2001 From: Yeechan Lu Date: Sat, 29 Mar 2014 14:42:43 +0800 Subject: [PATCH] Move ProgramSetting into Feature --- Wox.Infrastructure/StringEmptyConverter.cs | 29 +++++++ .../StringNullOrEmptyToVisibilityConverter.cs | 26 +++++++ Wox.Infrastructure/Wox.Infrastructure.csproj | 3 + Wox.Plugin.System/ProgramSetting.xaml | 56 +++++++++++++ Wox.Plugin.System/ProgramSetting.xaml.cs | 78 +++++++++++++++++++ .../ProgramSourceSetting.xaml | 2 +- .../ProgramSourceSetting.xaml.cs | 12 +-- Wox.Plugin.System/Wox.Plugin.System.csproj | 19 +++++ Wox/SettingWindow.xaml | 51 +----------- Wox/SettingWindow.xaml.cs | 42 ---------- Wox/Wox.csproj | 7 -- 11 files changed, 219 insertions(+), 106 deletions(-) create mode 100644 Wox.Infrastructure/StringEmptyConverter.cs create mode 100644 Wox.Infrastructure/StringNullOrEmptyToVisibilityConverter.cs create mode 100644 Wox.Plugin.System/ProgramSetting.xaml create mode 100644 Wox.Plugin.System/ProgramSetting.xaml.cs rename {Wox => Wox.Plugin.System}/ProgramSourceSetting.xaml (97%) rename {Wox => Wox.Plugin.System}/ProgramSourceSetting.xaml.cs (92%) diff --git a/Wox.Infrastructure/StringEmptyConverter.cs b/Wox.Infrastructure/StringEmptyConverter.cs new file mode 100644 index 0000000000..f553695737 --- /dev/null +++ b/Wox.Infrastructure/StringEmptyConverter.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Wox.Infrastructure +{ + public class StringEmptyConverter : MarkupExtension, IValueConverter + { + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + return string.IsNullOrEmpty((string)value) ? parameter : value; + } + + public object ConvertBack( + object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotSupportedException(); + } + + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} diff --git a/Wox.Infrastructure/StringNullOrEmptyToVisibilityConverter.cs b/Wox.Infrastructure/StringNullOrEmptyToVisibilityConverter.cs new file mode 100644 index 0000000000..841b446a51 --- /dev/null +++ b/Wox.Infrastructure/StringNullOrEmptyToVisibilityConverter.cs @@ -0,0 +1,26 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Wox.Infrastructure +{ + public class StringNullOrEmptyToVisibilityConverter : MarkupExtension, IValueConverter + { + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return string.IsNullOrEmpty(value as string) ? Visibility.Collapsed : Visibility.Visible; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Wox.Infrastructure/Wox.Infrastructure.csproj b/Wox.Infrastructure/Wox.Infrastructure.csproj index 435388f399..33d9868d26 100644 --- a/Wox.Infrastructure/Wox.Infrastructure.csproj +++ b/Wox.Infrastructure/Wox.Infrastructure.csproj @@ -37,6 +37,7 @@ ..\packages\Newtonsoft.Json.5.0.8\lib\net35\Newtonsoft.Json.dll + @@ -60,6 +61,8 @@ + + diff --git a/Wox.Plugin.System/ProgramSetting.xaml b/Wox.Plugin.System/ProgramSetting.xaml new file mode 100644 index 0000000000..ffb082efa3 --- /dev/null +++ b/Wox.Plugin.System/ProgramSetting.xaml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +