Added shared UI library and finished the ColorPicker

This commit is contained in:
Robert committed 2019-12-09 13:02:59 +01:00
1 parent 5e876dc8ca
commit b9471abdec
30 files changed
+875 -321

No files matched your search

@@ -0,0 +1,39 @@
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
namespace Artemis.UI.Shared.Converters
{
/// <inheritdoc />
/// <summary>
/// Converts <see cref="T:System.Windows.Media.Color" /> into <see cref="T:System.String" />.
/// </summary>
[ValueConversion(typeof(Color), typeof(string))]
internal class ColorToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value?.ToString();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
try
{
if (string.IsNullOrWhiteSpace((string) value))
return default(Color);
var color = ColorConverter.ConvertFromString((string) value);
if (color is Color c)
return c;
return default(Color);
}
catch (FormatException)
{
return default(Color);
}
}
}
}