You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.5 KiB
53 lines
1.5 KiB
2 years ago
|
using BBWY.Client.Models;
|
||
|
using EnumsNET;
|
||
|
using SixLabors.ImageSharp;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Globalization;
|
||
|
using System.Reflection;
|
||
|
using System.Text;
|
||
|
using System.Windows;
|
||
|
using System.Windows.Data;
|
||
|
|
||
|
namespace BBWY.Client.Converters
|
||
|
{
|
||
|
internal class EnumToColorConverter : IValueConverter
|
||
|
{
|
||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
if (value == null) return DependencyProperty.UnsetValue;
|
||
|
Assembly assem = Assembly.GetExecutingAssembly();
|
||
|
Type type = assem.GetType(parameter.ToString());
|
||
|
var enumName = Enum.Parse(type, value.ToString());
|
||
|
if (value.ToString() == TaskState.已到货.GetName())
|
||
|
{
|
||
|
return "#C1FFC1";
|
||
|
}
|
||
|
if (value.ToString() == "部分到货")
|
||
|
{
|
||
|
return "#FFDEAD";
|
||
|
}
|
||
|
if (value.ToString() == "未到货")
|
||
|
{
|
||
|
return "#FFDAB9";
|
||
|
|
||
|
}
|
||
|
return enumName;
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
// Logger.Error(nameof(TemplateTypeConverter), e);
|
||
|
return string.Empty;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|