XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
UTF-8
using Microsoft.UI.Xaml.Media.Imaging;
using Microsoft.Windows.ApplicationModel.Resources;
using SpaceEngineersBlueprintEditor.Model;

namespace SpaceEngineersBlueprintEditor.Utilities.Helpers;

/// <summary>
/// 扩展类
/// </summary>
public static class Extensions
{
    private static readonly ResourceLoader _resourceLoader = new();
    /// <summary>
    /// 获取本地化文本
    /// </summary>
    /// <param name="resourceKey"></param>
    /// <returns></returns>
    public static string GetLocalized(this string resourceKey) => _resourceLoader.GetString(resourceKey);
    /// <summary>
    /// 转化为蓝图信息视图数据
    /// </summary>
    /// <param name="blueprintInfo">蓝图信息</param>
    /// <returns></returns>
    public static BlueprintInfoViewData ToBlueprintInfoViewData(this BlueprintInfo blueprintInfo) => new(new BitmapImage(blueprintInfo.HasImage ? new(blueprintInfo.ImagePath) : new Uri("ms-appx:///Assets/Images/BlueprintDrag.png", UriKind.RelativeOrAbsolute)), !blueprintInfo.HasBlueprint, blueprintInfo.Name, blueprintInfo.FileSize, blueprintInfo.BlueprintPath);
}