mirror of
https://github.com/Tribufu/ServerManagers
synced 2026-08-09 20:51:05 +00:00
32 lines
967 B
C#
32 lines
967 B
C#
using System;
|
|
using System.Globalization;
|
|
using System.Windows;
|
|
using System.Windows.Data;
|
|
|
|
namespace ServerManagerTool.Common.Converters
|
|
{
|
|
public class InvertBooleanToVisibilityConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
var flag = false;
|
|
if (value is bool)
|
|
{
|
|
flag = (bool)value;
|
|
}
|
|
else if (value is bool?)
|
|
{
|
|
bool? nullable = (bool?)value;
|
|
flag = nullable.HasValue && nullable.Value;
|
|
}
|
|
return flag ? Visibility.Collapsed : Visibility.Visible;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value is Visibility)
|
|
return (Visibility)value == Visibility.Collapsed;
|
|
return false;
|
|
}
|
|
}
|
|
}
|