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 _20230724_MBJC_upperpc.Common { public class AlarmConverter: IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Brush TxtForeground = null; if (System.Convert.ToSingle(value) < 0.75) { TxtForeground = new SolidColorBrush(Colors.Green); } else if(System.Convert.ToSingle(value) >= 0.75 && System.Convert.ToSingle(value) < 1) { TxtForeground = new SolidColorBrush(Colors.Yellow); } else if (System.Convert.ToSingle(value) >= 1) { TxtForeground = new SolidColorBrush(Colors.Red); } return TxtForeground; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } }