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
{
///
/// houseSN转换器 Foreground
///
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();
}
}
///
/// 培养信息图片转换器
///
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();
}
}
///
/// 温度压力图片转换器
///
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();
}
}
///
/// 培养信息转换器 Foreground
///
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();
}
}
///
/// 培养信息展示转换器
///
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();
}
}
///
/// 培养信息字体颜色转换器
///
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();
}
}
}