|
- using BPASmartClient.CustomResource.UserControls.Enum;
- 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 BPASmartClient.Academy.Converter
- {
- public class DeviceCtrlConvert : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (parameter.ToString() == "1")//流向正向
- {
- if (value is bool)
- {
- bool value_get = (bool)value;
- if (value_get)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- else
- {
- return 0;
- }
-
- }
- else if (parameter.ToString() == "2")//管道颜色
- {
- if (value is bool)
- {
- bool value_get = (bool)value;
- if (value_get)
- {
- return Color.FromRgb(227,26,26);
- }
- else
- {
- return Color.FromRgb(255,255,255);
- }
- }
- else
- {
- return Color.FromRgb(255, 255, 255);
- }
- }
- else if(parameter.ToString() == "3")//电机颜色
- {
- if (value is bool)
- {
- bool value_get = (bool)value;
- if (value_get)
- {
- return MotorColor.Green;
- }
- else
- {
- return MotorColor.Gray;
- }
- }
- else
- {
- return MotorColor.Gray;
- }
- }
- else if(parameter.ToString()=="4")//字体颜色
- {
- if (value is bool)
- {
- bool value_get = (bool)value;
- if (value_get)
- {
- return new SolidColorBrush(Color.FromRgb(227, 26, 26));
- }
- else
- {
- return new SolidColorBrush(Color.FromRgb(255, 255, 255));
- }
- }
- else
- {
- return new SolidColorBrush(Color.FromRgb(255, 255, 255));
- }
- }
- else if(parameter.ToString() == "5")//流向反向
- {
- if (value is bool)
- {
- bool value_get = (bool)value;
- if (value_get)
- {
- return 2;
- }
- else
- {
- return 0;
- }
- }
- else
- {
- return 0;
- }
- }
- else if (parameter.ToString() == "6")//冷凝水颜色
- {
- if (value is bool)
- {
- bool value_get = (bool)value;
- if (value_get)
- {
- return Color.FromRgb(0, 255, 0);
- }
- else
- {
- return Color.FromRgb(255, 255, 255);
- }
- }
- else
- {
- return Color.FromRgb(255, 255, 255);
- }
- }
- else //冷凝水、疏水管道颜色
- {
- if (value is bool)
- {
- bool value_get = (bool)value;
- if (value_get)
- {
- return Color.FromRgb(0, 255, 0);
- }
- else
- {
- return Color.FromRgb(227, 26, 26);
- }
- }
- else
- {
- return Color.FromRgb(227, 26, 26);
- }
- }
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- }
|