using System; using System.Windows.Data; using System.Windows.Media; namespace DTS.Common.Converters { public class BooleanToColorConverter : IValueConverter { public bool Background { get; set; } = false; public bool Inverted { get; set; } = false; public bool AttentionBrush { get; set; } = false; public bool WarningBrush { get; set; } = false; public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { value = Inverted ? !(bool)value : value; if ((bool)value) { return Background ? Brushes.Transparent : BrushesAndColors.Brush_NoError; } return AttentionBrush ? BrushesAndColors.Brush_Attention : WarningBrush ? BrushesAndColors.Brush_Warning : BrushesAndColors.Brush_Error; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return null; } } }