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();
}
}
}

View File

@@ -9,7 +9,8 @@ namespace ModernKeePass.Converters
{
public object Convert(object value, Type targetType, object parameter, string language)
{
var icon = (Icon)value;
return Enum.Parse(typeof(Symbol), value.ToString());
/*var icon = (Icon)value;
switch (icon)
{
case Icon.Delete: return Symbol.Delete;
@@ -62,12 +63,12 @@ namespace ModernKeePass.Converters
case Icon.Stop: return Symbol.Stop;
default:
throw new ArgumentOutOfRangeException();
}
}*/
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
var symbol = (Symbol)value;
/*var symbol = (Symbol)value;
var defaultIcon = parameter != null ? int.Parse(parameter as string) : -1;
switch (symbol)
{
@@ -120,7 +121,9 @@ namespace ModernKeePass.Converters
case Symbol.ReportHacked: return Icon.ReportHacked;
case Symbol.Stop: return Icon.Stop;
default: return defaultIcon;
}
}*/
return Enum.Parse(typeof(Icon), value.ToString());
}
}
}