using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; using System.Windows.Media; namespace MegaRobo.C00225155App.Converters { /// /// 反应瓶是否有液体的背景颜色转换器 /// public class ReactBoolToBackgroundConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is bool havebottle) { if (!havebottle) { return (Brush)new BrushConverter().ConvertFrom("#ccc7c7"); } else { return (Brush)new BrushConverter().ConvertFrom("#aff0b3"); } } return Brushes.Transparent; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } /// /// 粉末瓶是否有粉末的背景颜色转换器 /// public class PowderStringToBackgroundConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is string powderName) { if (!string.IsNullOrEmpty(powderName)) //有名称 { return (Brush)new BrushConverter().ConvertFrom("#ccc7c7"); } else { return (Brush)new BrushConverter().ConvertFrom("#FFFAFAF7"); //#FFFAFAF7 } } return Brushes.Transparent; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } /// /// 液体瓶是否有液体的背景颜色转换器 /// public class StringToBackgroundConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is string liquidName) { if (!string.IsNullOrEmpty(liquidName)) //有名称 { return (Brush)new BrushConverter().ConvertFrom("#ccc7c7"); } else { return (Brush)new BrushConverter().ConvertFrom("#FFFAFAF7");//#FFFAFAF7 } } return Brushes.Transparent; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } /// /// 反应瓶工装,是否配置有反应瓶,边框背景颜色转换器 /// public class ReactBottleBoxToBrushConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is bool boolValue && boolValue) return Brushes.Green; return Brushes.Gray; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } }