2022-01-27 13:40:04 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
|
2022-07-23 19:23:32 +00:00
|
|
|
|
namespace MSFSPopoutPanelManager.WpfApp
|
2022-01-27 13:40:04 +00:00
|
|
|
|
{
|
|
|
|
|
[ValueConversion(typeof(bool), typeof(Visibility))]
|
|
|
|
|
public sealed class BoolToVisibilityConverter : IValueConverter
|
|
|
|
|
{
|
|
|
|
|
public Visibility TrueValue { get; set; }
|
|
|
|
|
public Visibility FalseValue { get; set; }
|
|
|
|
|
|
|
|
|
|
public BoolToVisibilityConverter()
|
|
|
|
|
{
|
|
|
|
|
// set defaults
|
|
|
|
|
TrueValue = Visibility.Visible;
|
|
|
|
|
FalseValue = Visibility.Collapsed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object Convert(object value, Type targetType,
|
|
|
|
|
object parameter, CultureInfo culture)
|
|
|
|
|
{
|
|
|
|
|
if (!(value is bool))
|
|
|
|
|
return null;
|
|
|
|
|
return (bool)value ? TrueValue : FalseValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType,
|
|
|
|
|
object parameter, CultureInfo culture)
|
|
|
|
|
{
|
|
|
|
|
if (Equals(value, TrueValue))
|
|
|
|
|
return true;
|
|
|
|
|
if (Equals(value, FalseValue))
|
|
|
|
|
return false;
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|