alielie
2026-04-16 1afe548ac40cc7f975917ef9bf2e156595cf81f3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Globalization;
using System.Windows.Data;
 
namespace HMI.UI.Converter
{
    public class ResultConverter : IValueConverter
    {
        public static ResultConverter Instance = new ResultConverter();
 
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null) return value;
            var str = value.ToString();
            if (str.Equals("ok", StringComparison.OrdinalIgnoreCase) || str.Equals("pass", StringComparison.OrdinalIgnoreCase))
            {
                return "PASS";
            }
            if (str.Equals("ng", StringComparison.OrdinalIgnoreCase) || str.Equals("fail", StringComparison.OrdinalIgnoreCase))
            {
                return "FAIL";
            }
            return value;
        }
 
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value;
        }
    }
}