XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEEDToolBox

【WinUI】XFE精英危险工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
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)));
}