2014-02-19 23:42:21 +08:00
|
|
|
using System;
|
2014-10-24 13:09:51 +08:00
|
|
|
using System.Collections.Generic;
|
2014-02-19 23:42:21 +08:00
|
|
|
using System.Globalization;
|
|
|
|
using System.Windows;
|
2014-10-24 13:09:51 +08:00
|
|
|
using Wox.Plugin;
|
2014-02-19 23:42:21 +08:00
|
|
|
|
2014-05-24 16:06:09 +08:00
|
|
|
namespace Wox.Converters
|
2014-02-19 23:42:21 +08:00
|
|
|
{
|
2014-05-24 16:06:09 +08:00
|
|
|
public class StringNullOrEmptyToVisibilityConverter : ConvertorBase<StringNullOrEmptyToVisibilityConverter>
|
2014-02-19 23:42:21 +08:00
|
|
|
{
|
2014-05-24 16:06:09 +08:00
|
|
|
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
2014-02-19 23:42:21 +08:00
|
|
|
{
|
2014-05-24 16:06:09 +08:00
|
|
|
return string.IsNullOrEmpty(value as string) ? Visibility.Collapsed : Visibility.Visible;
|
2014-02-19 23:42:21 +08:00
|
|
|
}
|
|
|
|
|
2014-05-24 16:06:09 +08:00
|
|
|
public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
2014-02-19 23:42:21 +08:00
|
|
|
{
|
2014-05-24 16:06:09 +08:00
|
|
|
return null;
|
2014-02-19 23:42:21 +08:00
|
|
|
}
|
|
|
|
|
2014-05-24 16:06:09 +08:00
|
|
|
public override object ProvideValue(IServiceProvider serviceProvider)
|
2014-02-19 23:42:21 +08:00
|
|
|
{
|
2014-05-24 16:06:09 +08:00
|
|
|
return this;
|
2014-02-19 23:42:21 +08:00
|
|
|
}
|
|
|
|
}
|
2014-10-24 13:09:51 +08:00
|
|
|
|
|
|
|
public class ContextMenuEmptyToWidthConverter : ConvertorBase<ContextMenuEmptyToWidthConverter>
|
|
|
|
{
|
|
|
|
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
|
{
|
|
|
|
List<Result> results = value as List<Result>;
|
|
|
|
return results == null || results.Count == 0 ? 0 : 17;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override object ProvideValue(IServiceProvider serviceProvider)
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
2014-02-19 23:42:21 +08:00
|
|
|
}
|