initial commit
This commit is contained in:
24
Converters/BoolToPassFailBrushConverter.cs
Normal file
24
Converters/BoolToPassFailBrushConverter.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user