Icons work again

Colors work again
This commit is contained in:
Geoffroy BONNEVILLE
2020-04-14 17:49:29 +02:00
parent 3def21bc7d
commit 9603c1ff01
14 changed files with 103 additions and 61 deletions

View File

@@ -1,4 +1,5 @@
using System;
using ModernKeePass.Extensions;
using System;
using System.Drawing;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Media;
@@ -9,19 +10,15 @@ namespace ModernKeePass.Converters
{
public object Convert(object value, Type targetType, object parameter, string language)
{
var color = value is Color ? (Color?) value : Color.Empty;
var color = value as Color? ?? Color.Empty;
if (color == Color.Empty && parameter is SolidColorBrush) return (SolidColorBrush) parameter;
return new SolidColorBrush(Windows.UI.Color.FromArgb(
color.Value.A,
color.Value.R,
color.Value.G,
color.Value.B));
return color.ToSolidColorBrush();
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
var brush = value as SolidColorBrush;
return brush == null ? new Color() : Color.FromArgb(brush.Color.A, brush.Color.R, brush.Color.G, brush.Color.B);
return brush?.ToColor() ?? new Color();
}
}
}