23 lines
684 B
C#
23 lines
684 B
C#
using System.Globalization;
|
|
using System.Windows;
|
|
using System.Windows.Data;
|
|
|
|
namespace EmbyToolbox.Converters;
|
|
|
|
public sealed class BooleanToVisibilityConverter : IValueConverter
|
|
{
|
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
var flag = value is true;
|
|
if (parameter is string p && string.Equals(p, "Invert", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
flag = !flag;
|
|
}
|
|
|
|
return flag ? Visibility.Visible : Visibility.Collapsed;
|
|
}
|
|
|
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) =>
|
|
value is Visibility.Visible;
|
|
}
|