using System; using System.Globalization; using Avalonia.Data.Converters; using Avalonia.Media; namespace Junction.App.Converters { /// /// Maps a token /// ("online"/"offline"/"unknown") to a status brush. Keeps view-models free of /// UI-framework types: the color decision lives entirely in the view layer. /// public sealed class StatusKindToBrushConverter : IValueConverter { public static readonly StatusKindToBrushConverter Instance = new StatusKindToBrushConverter(); private static readonly IBrush Online = new SolidColorBrush(Color.FromRgb(0x2E, 0x7D, 0x32)); // green private static readonly IBrush Offline = new SolidColorBrush(Color.FromRgb(0xC6, 0x28, 0x28)); // red private static readonly IBrush Unknown = new SolidColorBrush(Color.FromRgb(0x9E, 0x9E, 0x9E)); // grey public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { switch (value as string) { case "online": return Online; case "offline": return Offline; default: return Unknown; } } public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotSupportedException(); } }