using System.Globalization; using Avalonia; using Avalonia.Data.Converters; using Avalonia.Media; namespace ClaudeDo.Ui.Converters; /// /// Converts an icon key string (e.g. "Sun") to the matching StreamGeometry resource "Icon.Sun". /// public class IconKeyConverter : IValueConverter { public static IconKeyConverter Instance { get; } = new(); public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { if (value is not string key || string.IsNullOrEmpty(key)) return null; var resourceKey = $"Icon.{key}"; if (Application.Current?.TryGetResource(resourceKey, null, out var res) == true) return res as StreamGeometry; return null; } public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotSupportedException(); }