Files
HC_APTBS/Converters/BoolToPassFailBrushConverter.cs
2026-04-11 12:45:18 +02:00

25 lines
995 B
C#

using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
namespace HC_APTBS.Converters
{
/// <summary>
/// Converts a boolean pass/fail value to a background brush for result rows.
/// <see langword="true"/> → light green; <see langword="false"/> → light red.
/// </summary>
[ValueConversion(typeof(bool), typeof(SolidColorBrush))]
public sealed class BoolToPassFailBrushConverter : IValueConverter
{
private static readonly SolidColorBrush PassBrush = new(Color.FromRgb(0xC8, 0xFF, 0xC8));
private static readonly SolidColorBrush FailBrush = new(Color.FromRgb(0xFF, 0xC8, 0xC8));
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
=> value is bool b && b ? PassBrush : FailBrush;
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
=> throw new NotSupportedException();
}
}