using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Media.Imaging;
using XFEEDToolBox.Core.Rendering;
namespace XFEEDToolBox.Controls;
/// <summary>Displays the game's exported vector asset without tracing or replacing its geometry.</summary>
public sealed class GameIcon:UserControl
{
public static readonly DependencyProperty IconKeyProperty=DependencyProperty.Register(nameof(IconKey),typeof(GameUiIcon),typeof(GameIcon),new PropertyMetadata(GameUiIcon.POIGeneric,Changed));
public GameUiIcon IconKey{get=>(GameUiIcon)GetValue(IconKeyProperty);set=>SetValue(IconKeyProperty,value);}
private readonly Image image=new(){Stretch=Stretch.Uniform,IsHitTestVisible=false};
public GameIcon(){Width=26;Height=26;Content=image;Update();}
private static void Changed(DependencyObject sender,DependencyPropertyChangedEventArgs args)=>((GameIcon)sender).Update();
private void Update()=>image.Source=new SvgImageSource(new Uri(GameUiIcons.Asset(IconKey)));
}
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Media.Imaging;
using XFEEDToolBox.Core.Rendering;
namespace XFEEDToolBox.Controls;
/// <summary>Displays the game's exported vector asset without tracing or replacing its geometry.</summary>
public sealed class GameIcon:UserControl
{
public static readonly DependencyProperty IconKeyProperty=DependencyProperty.Register(nameof(IconKey),typeof(GameUiIcon),typeof(GameIcon),new PropertyMetadata(GameUiIcon.POIGeneric,Changed));
public GameUiIcon IconKey{get=>(GameUiIcon)GetValue(IconKeyProperty);set=>SetValue(IconKeyProperty,value);}
private readonly Image image=new(){Stretch=Stretch.Uniform,IsHitTestVisible=false};
public GameIcon(){Width=26;Height=26;Content=image;Update();}
private static void Changed(DependencyObject sender,DependencyPropertyChangedEventArgs args)=>((GameIcon)sender).Update();
private void Update()=>image.Source=new SvgImageSource(new Uri(GameUiIcons.Asset(IconKey)));
}