You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.5 KiB
C#

using System;
using System.Globalization;
using Avalonia.Data.Converters;
namespace Sln.Wcs.UI.Converters;
public class CodeToTextConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is null) return "--";
var code = System.Convert.ToInt32(value);
var category = parameter as string;
return category switch
{
"TaskType" => code switch { 1 => "入库", 2 => "出库", _ => "--" },
"TaskCategory" => code switch { 1 => "包材", 2 => "成品", 3 => "托盘", _ => "--" },
"TaskStatus" => code switch { 1 => "待执行", 2 => "执行中", 3 => "已完成", _ => "--" },
"ExecutionMode" => code switch { 0 => "自动", 1 => "手动", _ => "--" },
"DeviceType" => code switch { 0 => "输送线", 1 => "AGV", 2 => "提升机", _ => "--" },
"DeviceStatus" => code switch { 0 => "正常", 1 => "在忙", 2 => "异常", _ => "--" },
"IsFlag" => code switch { 0 => "否", 1 => "是", _ => "--" },
"OperationType" => code switch { 0 => "默认读写", 1 => "只读", 2 => "只写", _ => "--" },
"LocationStatus" => code switch { 0 => "未使用", 1 => "已使用", 2 => "锁库", 3 => "异常", _ => "--" },
_ => code.ToString()
};
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}