123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Data;
- using System.Windows.Media;
- namespace Venus_Themes.Converters
- {
- public class StringToColorConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- if (value == null) return new SolidColorBrush(Colors.Red);
- switch (value.ToString())
- {
- case "Information":
- return new SolidColorBrush(Colors.Green);
- case "Warning":
- return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ffd400"));
- case "Alarm":
- return new SolidColorBrush(Colors.Red);
- default:
- return new SolidColorBrush(Colors.Silver);
- }
- }
- public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- if (value == null)return false;
- if (!(value is bool))
- return false;
- return !(bool)value;
- }
- }
- }
|