diff --git a/SlnMesnac.WPF/Converter/AgvAndTask/AgvNameConverter.cs b/SlnMesnac.WPF/Converter/AgvAndTask/AgvNameConverter.cs new file mode 100644 index 0000000..c6b8ee2 --- /dev/null +++ b/SlnMesnac.WPF/Converter/AgvAndTask/AgvNameConverter.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace SlnMesnac.WPF.Converter.AgvAndTask +{ + public class AgvNameConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is long nextPointId) // 检查是否为 long 类型 + { + return nextPointId switch + { + 8 => "3楼叉车", + 9 => "2楼叉车", + _ => "未知AGV", + }; + } + + return "未知AGV"; // 如果值不是 long 类型,返回未知AGV + + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/SlnMesnac.WPF/Converter/AgvAndTask/TaskStatusConverter .cs b/SlnMesnac.WPF/Converter/AgvAndTask/TaskStatusConverter .cs new file mode 100644 index 0000000..95940d9 --- /dev/null +++ b/SlnMesnac.WPF/Converter/AgvAndTask/TaskStatusConverter .cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace SlnMesnac.WPF.Converter.AgvAndTask +{ + public class TaskStatusConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is int status) + { + return status switch + { + 0 => "未下发", + 1 => "已下发", + > 1 and < 6 => "执行中", + >= 6 => "执行完成", + _ => "未知状态", + }; + } + return "未知状态"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/SlnMesnac.WPF/MainWindow.xaml b/SlnMesnac.WPF/MainWindow.xaml index 2552eee..8333b75 100644 --- a/SlnMesnac.WPF/MainWindow.xaml +++ b/SlnMesnac.WPF/MainWindow.xaml @@ -65,8 +65,8 @@