mirror of
https://github.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies.git
synced 2026-07-25 06:14:31 +00:00
30 lines
774 B
C#
30 lines
774 B
C#
using System.Globalization;
|
|
using System.Windows.Data;
|
|
using System.Windows.Media;
|
|
using System;
|
|
|
|
namespace NebulaAuth.Converters;
|
|
|
|
[ValueConversion(typeof(Color), typeof(Brush))]
|
|
public class ColorToBrushConverter : IValueConverter
|
|
{
|
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
if (value is Color color)
|
|
{
|
|
SolidColorBrush rv = new(color);
|
|
rv.Freeze();
|
|
return rv;
|
|
}
|
|
return Binding.DoNothing;
|
|
}
|
|
|
|
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
if (value is SolidColorBrush brush)
|
|
{
|
|
return brush.Color;
|
|
}
|
|
return default(Color);
|
|
}
|
|
} |