using System.Numerics; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Data; using Microsoft.UI.Xaml.Hosting; using Microsoft.UI.Xaml.Media; namespace XFEWarframe.Player.Utilities.Converters; public sealed class AccountAvatarIconConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { if (value is not ImageSource avatar) return new FontIcon { Glyph = "\uE77B" }; // ImageIconSource inside IconSourceElement silently renders no image in WinUI. // Share the card's bitmap; create only the navigation-specific visual here. var icon = new ImageIcon { Source = avatar, Width = 24, Height = 24 }; var visual = ElementCompositionPreview.GetElementVisual(icon); var circle = visual.Compositor.CreateEllipseGeometry(); circle.Center = circle.Radius = new Vector2(12); visual.Clip = visual.Compositor.CreateGeometricClip(circle); return icon; } public object ConvertBack(object value, Type targetType, object parameter, string language) => throw new NotSupportedException("Account icons use a one-way binding."); }