| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398 |
- using ivf_tl_Entity.Entity.balance;
- 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;
- using System.Windows.Media.Imaging;
- namespace ivf_tl_Manage.Converts
- {
- /// <summary>
- /// houseSN转换器 Foreground
- /// </summary>
- public class HouseSnForegroundConvert : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- string rsColor = null;
- var state = values[0].ToString();
- var temperatureAlarm = values[1].ToString();
- var pressureAlarm = values[2].ToString();
- if (state == "1")//在线
- {
- if (temperatureAlarm == "1" || pressureAlarm == "1")
- {
- rsColor = "#C85553";
- }
- else
- {
- rsColor = "#FFB000";
- }
- }
- else//非在线状态
- {
- rsColor = "#E39D00";
- }
- return new SolidColorBrush((Color)ColorConverter.ConvertFromString(rsColor));
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- /// <summary>
- /// 培养信息图片转换器
- /// </summary>
- public class HouseInfoImageConvert : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- var sourceType = parameter.ToString();
- var state = values[0].ToString();
- var value1 = values[1];
- if (value1 != null && value1 is Dish dish && dish.id > 0)
- {
- if (state == "1")
- {
- switch (sourceType)
- {
- case "DishHeadshot":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishHeadshot.png", UriKind.Absolute));
- case "DishStartTime":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStartTimeIcon.png", UriKind.Absolute));
- case "DishStage":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStageIcon.png", UriKind.Absolute));
- }
- }
- else
- {
- switch (sourceType)
- {
- case "DishHeadshot":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishState0Headshot.png", UriKind.Absolute));
- case "DishStartTime":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStartTimeState0Icon.png", UriKind.Absolute));
- case "DishStage":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStageState0Icon.png", UriKind.Absolute));
- }
- }
- }
- else
- {
- if (state == "1")
- {
- switch (sourceType)
- {
- case "DishHeadshot":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataHeadshot.png", UriKind.Absolute));
- case "DishStartTime":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataStartTimeIcon.png", UriKind.Absolute));
- case "DishStage":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataStageIcon.png", UriKind.Absolute));
- }
- }
- else
- {
- switch (sourceType)
- {
- case "DishHeadshot":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataState0Headshot.png", UriKind.Absolute));
- case "DishStartTime":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataState0StartTimeIcon.png", UriKind.Absolute));
- case "DishStage":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataState0StageIcon.png", UriKind.Absolute));
- }
- }
- }
- return null;
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- public class HouseInfoImageConvert1 : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- var sourceType = parameter.ToString();
- var state = values[0].ToString();
- var value1 = values[1];
- var value2 = values[2];
- if ((value1 != null && value1 is Dish dish && dish.id > 0) || (value2 != null && value2 is Balance balance && balance.id > 0))
- {
- if (state == "1")
- {
- switch (sourceType)
- {
- case "DishHeadshot":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishHeadshot.png", UriKind.Absolute));
- case "DishStartTime":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStartTimeIcon.png", UriKind.Absolute));
- case "DishStage":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStageIcon.png", UriKind.Absolute));
- }
- }
- else
- {
- switch (sourceType)
- {
- case "DishHeadshot":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishState0Headshot.png", UriKind.Absolute));
- case "DishStartTime":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStartTimeState0Icon.png", UriKind.Absolute));
- case "DishStage":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishStageState0Icon.png", UriKind.Absolute));
- }
- }
- }
- else
- {
- if (state == "1")
- {
- switch (sourceType)
- {
- case "DishHeadshot":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataHeadshot.png", UriKind.Absolute));
- case "DishStartTime":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataStartTimeIcon.png", UriKind.Absolute));
- case "DishStage":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataStageIcon.png", UriKind.Absolute));
- }
- }
- else
- {
- switch (sourceType)
- {
- case "DishHeadshot":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataState0Headshot.png", UriKind.Absolute));
- case "DishStartTime":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataState0StartTimeIcon.png", UriKind.Absolute));
- case "DishStage":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishNoDataState0StageIcon.png", UriKind.Absolute));
- }
- }
- }
- return null;
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- /// <summary>
- /// 温度压力图片转换器
- /// </summary>
- public class HouseInfoAlarmImageConvert : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- var sourceType = parameter.ToString();
- string rsSource = null;
- var state = values[0].ToString();
- var alarmSign = values[1].ToString();
- if (state == "1")//在线
- {
- if (alarmSign == "1")
- {
- switch (sourceType)
- {
- case "HouseTemperature":
- rsSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/HouseTemperatureAlarmIcon.png";
- break;
- case "HousePressure":
- rsSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/HousePressureAlarmIcon.png";
- break;
- }
- }
- else
- {
- switch (sourceType)
- {
- case "HouseTemperature":
- rsSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/HouseTemperatureIcon.png";
- break;
- case "HousePressure":
- rsSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/HousePressureIcon.png";
- break;
- }
- }
- }
- else//非在线状态
- {
- switch (sourceType)
- {
- case "HouseTemperature":
- rsSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/HouseTemperatureState0Icon.png";
- break;
- case "HousePressure":
- rsSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/HousePressureState0Icon.png";
- break;
- }
- }
- return new BitmapImage(new Uri(rsSource, UriKind.Absolute));
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- /// <summary>
- /// 培养信息转换器 Foreground
- /// </summary>
- public class DishInfoForegroundConver : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- var typePar = parameter.ToString();
- if (value.ToString() == "1")
- {
- switch (typePar)
- {
- case "button":
- return "#9B9B9B";
- case "text":
- return "#4D4D4D";
- case "housesn":
- return "#FFB000";
- case "funcSelected":
- return "#4D4D4D";
- }
- }
- else
- {
- switch (typePar)
- {
- case "button":
- return "#AAAAAA";
- case "text":
- return "#707070";
- case "housesn":
- return "#E39D00";
- case "funcSelected":
- return "#9B9B9B";
- }
- }
- return "#4D4D4D";
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- /// <summary>
- /// 培养信息展示转换器
- /// </summary>
- public class HouseInfoDishConvert : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- var typePar = parameter.ToString();
- if (value != null && (value is Dish dish) && dish.id > 0)
- {
- switch (typePar)
- {
- case "name":
- return $"{dish.wife}/{dish.husband}";
- }
- }
- else
- {
- switch (typePar)
- {
- case "name":
- return $"--/--";
- }
- }
- return null;
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- /// <summary>
- /// 培养信息字体颜色转换器
- /// </summary>
- public class HouseInfoForegroundConver : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- //var sourceType = parameter.ToString();
- string rsColor = null;
- var state = values[0].ToString();
- var value1 = values[1];
- if (state != null && value1 is Dish dish && dish.id > 0)
- {
- if (state == "1")
- {
- rsColor = "#4D4D4D";
- }
- else
- {
- rsColor = "#707070";
- }
- }
- else
- {
- rsColor = "#ABABAB";
- }
- return new SolidColorBrush((Color)ColorConverter.ConvertFromString(rsColor));
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- public class HouseInfoForegroundConver1 : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- //var sourceType = parameter.ToString();
- string rsColor = null;
- var state = values[0].ToString();
- var value1 = values[1];
- var value2 = values[2];
- if ((value1 != null && value1 is Dish dish && dish.id > 0) || (value2 != null && value2 is Balance balance && balance.id > 0))
- {
- if (state == "1")
- {
- rsColor = "#4D4D4D";
- }
- else
- {
- rsColor = "#707070";
- }
- }
- else
- {
- rsColor = "#ABABAB";
- }
- return new SolidColorBrush((Color)ColorConverter.ConvertFromString(rsColor));
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- }
|