| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 | using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Data;using System.Windows.Media;namespace CyberX8_Themes.Converters{    internal class IntToColorConverter : IValueConverter    {        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)        {            switch (value)            {                //Init                case 0:                    return new SolidColorBrush(Colors.Yellow);                //Idle状态 无色                case 1:                    return new SolidColorBrush(Colors.Transparent);                //Busy状态 绿色                case 2:                    return new SolidColorBrush(Colors.Lime);                //Disable状态 深灰色                case 3:                    return new SolidColorBrush(Colors.DarkGray);                //Error状态 红色                case 4:                    return new SolidColorBrush(Colors.Red);                default:                    return new SolidColorBrush(Colors.Transparent);            }        }        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)        {            if (!(value is bool))                return false;            return !(bool)value;        }    }}
 |