2020-04-14 17:49:29 +02:00
|
|
|
|
using ModernKeePass.Extensions;
|
|
|
|
|
using System;
|
2017-10-03 16:06:49 +02:00
|
|
|
|
using System.Drawing;
|
|
|
|
|
using Windows.UI.Xaml.Data;
|
|
|
|
|
using Windows.UI.Xaml.Media;
|
|
|
|
|
|
|
|
|
|
namespace ModernKeePass.Converters
|
|
|
|
|
{
|
|
|
|
|
public class ColorToBrushConverter : IValueConverter
|
|
|
|
|
{
|
|
|
|
|
public object Convert(object value, Type targetType, object parameter, string language)
|
|
|
|
|
{
|
2020-04-14 17:49:29 +02:00
|
|
|
|
var color = value as Color? ?? Color.Empty;
|
2017-10-03 16:06:49 +02:00
|
|
|
|
if (color == Color.Empty && parameter is SolidColorBrush) return (SolidColorBrush) parameter;
|
2020-04-14 17:49:29 +02:00
|
|
|
|
return color.ToSolidColorBrush();
|
2017-10-03 16:06:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
|
|
|
|
{
|
2018-06-26 15:01:02 +02:00
|
|
|
|
var brush = value as SolidColorBrush;
|
2020-04-14 17:49:29 +02:00
|
|
|
|
return brush?.ToColor() ?? new Color();
|
2017-10-03 16:06:49 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|