using System; using System.Globalization; using System.Windows.Data; using System.Windows.Media; namespace TeamAAS.Logging.Controls { /// /// 日志类别 → 前景色画刷转换器(颜色与流程节点状态色保持一致)。 /// Info=蓝、Warning=橙、Error=红。 /// public class LogLevelBrushConverter : IValueConverter { private static readonly Brush InfoBrush = Freeze("#2D6CDF"); private static readonly Brush WarningBrush = Freeze("#FF9800"); private static readonly Brush ErrorBrush = Freeze("#F44336"); private static Brush Freeze(string hex) { var brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(hex)); brush.Freeze(); return brush; } public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is LogLevel category) { switch (category) { case LogLevel.Warning: return WarningBrush; case LogLevel.Error: return ErrorBrush; default: return InfoBrush; } } return InfoBrush; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotSupportedException(); } }