using Avalonia.Data.Converters; using Avalonia.Media; using System; using System.Globalization; namespace AuroraDesk.Converters; /// /// 标签页样式转换器 /// public class TabStyleConverter : IValueConverter { public static readonly TabStyleConverter Instance = new(); public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { if (value is bool isSelected && parameter is string styleType) { return styleType switch { "Background" => isSelected ? new SolidColorBrush(Color.FromRgb(227, 242, 253)) : new SolidColorBrush(Colors.White), "BorderBrush" => isSelected ? new SolidColorBrush(Color.FromRgb(33, 150, 243)) : new SolidColorBrush(Color.FromRgb(208, 208, 208)), "Foreground" => isSelected ? new SolidColorBrush(Color.FromRgb(33, 150, 243)) : new SolidColorBrush(Colors.Black), _ => new SolidColorBrush(Colors.White) }; } return new SolidColorBrush(Colors.White); } public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) { throw new NotImplementedException(); } }