Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
bao-qian committed Apr 24, 2016
2 parents 49a6a9b + a922195 commit 10259dc
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 10 deletions.
5 changes: 3 additions & 2 deletions Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Plugins/Wox.Plugin.Program/ProgramSetting.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
<GridViewColumn Header="{DynamicResource wox_plugin_program_location}" Width="250">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Location, ConverterParameter=(null), Converter={program:StringEmptyConverter}}"/>
<TextBlock Text="{Binding Location, ConverterParameter=(null), Converter={program:LocationConverter}}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="{DynamicResource wox_plugin_program_suffixes_header}" Width="220">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Suffixes, ConverterParameter=(null), Converter={program:StringEmptyConverter}}"/>
<TextBlock Text="{Binding Suffixes, ConverterParameter=(null), Converter={program:SuffixesConvert}}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
Expand Down
33 changes: 33 additions & 0 deletions Plugins/Wox.Plugin.Program/SuffixesConverter.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
3 changes: 2 additions & 1 deletion Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
</Compile>
<Compile Include="FileChangeWatcher.cs" />
<Compile Include="IProgramSource.cs" />
<Compile Include="SuffixesConverter.cs" />
<Compile Include="Program.cs" />
<Compile Include="ProgramIndexCache.cs" />
<Compile Include="Programs.cs" />
Expand All @@ -77,7 +78,7 @@
<Compile Include="ProgramSuffixes.xaml.cs">
<DependentUpon>ProgramSuffixes.xaml</DependentUpon>
</Compile>
<Compile Include="StringEmptyConverter.cs" />
<Compile Include="LocationConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down

0 comments on commit 10259dc

Please sign in to comment.