24 lines
765 B
C#
24 lines
765 B
C#
using System;
|
|
using Avalonia.Data.Converters;
|
|
using Avalonia.Media;
|
|
|
|
namespace StreamPlayer.Desktop.Converters;
|
|
|
|
public sealed class BooleanToBrushConverter : IValueConverter
|
|
{
|
|
public IBrush TrueBrush { get; set; } = Brushes.White;
|
|
public IBrush FalseBrush { get; set; } = Brushes.Gray;
|
|
|
|
public object? Convert(object? value, Type targetType, object? parameter, System.Globalization.CultureInfo culture)
|
|
{
|
|
if (value is bool boolean)
|
|
{
|
|
return boolean ? TrueBrush : FalseBrush;
|
|
}
|
|
return Avalonia.AvaloniaProperty.UnsetValue;
|
|
}
|
|
|
|
public object? ConvertBack(object? value, Type targetType, object? parameter, System.Globalization.CultureInfo culture) =>
|
|
Avalonia.AvaloniaProperty.UnsetValue;
|
|
}
|