20240801_FJEQ_upperpc/FujianEarthquake_seabed/FujianEarthquake/Common/ValueToBrushConvert/ValueToBrushConvertShoreBaseStationCurrent.cs
XuMin 1f5631afb3 1 研究上下位机通信协议,编写协议解析代码;
2 研究岸基站可编程电源通信协议,编写岸基站状态数据显示页面;
2024-08-29 18:03:03 +08:00

42 lines
1.2 KiB
C#

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 FujianEarthquake.Common.ValueToBrushConvert
{
public class ValueToBrushConvertShoreBaseStationCurrent : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
double number = ConvertToDouble(value);
if (number > ConvertToDouble(parameter) || number < 0)
{
return new SolidColorBrush(Colors.Red); // 返回大于某个值的颜色
}
else
{
return new SolidColorBrush(Colors.White); // 返回默认颜色或背景色
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return new SolidColorBrush(Colors.Green); // 返回默认颜色或背景色
}
private double ConvertToDouble(object value)
{
double d;
double.TryParse(value.ToString(), out d);
return d;
}
}
}