首页 > 其他分享 >WPF 获取资源文件帮助类

WPF 获取资源文件帮助类

时间:2023-09-08 19:45:03浏览次数:26  
标签:文件 imageIcon1 return ResourceDictionary Controls 获取 static WPF public

using System;
using System.Reflection;
using System.Windows;

namespace K.Controls.Controls.Helper
{
    public class ResourceHelper
    {
        private static ResourceDictionary _theme;
        internal static T GetResourceInternal<T>(string key)
        {
            if (GetTheme()[key] is T resource)
            {
                return resource;
            }

            return default;
        }
        
        public static ResourceDictionary GetTheme() => _theme == null ? GetStandaloneTheme() : _theme;

        public static ResourceDictionary GetStandaloneTheme()
        {
            return new ResourceDictionary() {Source = new Uri("pack://application:,,,/K.Controls;component/Styles/UserStyle.xaml") };
        }

        public static string GetImageIconByType()
        {
                var imageIcon1 = string.Empty;
                imageIcon1 = Application.Current.Resources[$"{name}" + "LoginIcon"].ToString();
                
                //imageIcon1 = "/K.Controls;component/Images/Black/1.png";
         return imageIcon1; }
}
}




  

标签:文件,imageIcon1,return,ResourceDictionary,Controls,获取,static,WPF,public
From: https://www.cnblogs.com/jnyyq/p/17688416.html

相关文章

  • C# 写入类型到文件Helper类
    usingSystem;usingSystem.IO;usingSystem.Text;namespaceControls.Helper{publicclassLoggerHelper{privatestaticobjecto=newobject();privatestaticstringGetLogFilePath(){stringfilePath=AppD......
  • 关于 Product Pipeline 的 galectin.json 文件
    ProductPipeline概述:"ProductPipeline"是一个广泛用于企业中的术语,指的是一个产品从概念到最终交付的整个过程。它代表了产品的生命周期,从概念、规划、设计、开发、测试、部署,一直到最终发布和维护。在软件开发领域,"ProductPipeline"通常包括多个阶段和环节,每个环节都有特定的......
  • WPF 使用Image实现动画旋转Loading
    首先需要有一个Loading的图片,(白色背景,白色小圆圈,所以显示看不到): 创建一个用户控件,实现动画的功能:<UserControlx:Class="K.Controls.Controls.LoadingImage"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http:/......
  • 记PE文件结构实验,模拟文件内存加载过程。
    记录文件结构试验前言:使用的模拟程序是notepad.exe,主要记录其中的思路和遇到其中的困难。实验目的:模拟内存加载PE文件的过程,将每个区段模拟加载到内存之中。根据文件结构中头表中的信息,读取并sekk指针到Segment头。然后循环遍历Segment头将内容加载到VirtualAddress中,主要目的......
  • 设置电脑文件的打开方式
    设置电脑文件的打开方式不知道怎么搞的,有几个markdown文件的默认打开方式了变成了calibre图书馆了1.设置==>应用==>默认应用==>按文件类型指定默认应用......
  • 大文件 MD5 SHA 校验时间优化之路
    最近研发apk校验服务,很多游戏安装包两三个G,如果整个拿去校验,耗时基本二十多秒,这还仅仅是校验的时间,如果加上下载的时间,等待时间太长了网上很多方案尝试了一下,不太行1、fastmd5一个第三方库,csdn有人用过说可以提升40%的速度,然后我去试了一下,本来9秒可以完成的校验,变成了2分多钟......
  • C# 多语言环境下获取时区列表
    如果不需要在A语言下获取B语言的时区列表,可以使用C#自带的varsystemZones=TimeZoneInfo.GetSystemTimeZones();如果需要在A语言下获取B语言的时区列表,尝试过设置当前进程,线程的Culture是没办法实现的varcultureInfo=newCultureInfo("en_US");CultureInfo.CurrentCul......
  • mupdf实用操作demo,C++操作PDF文件
    前文:最近有个项目,需要读写PDF,本来想着挺简单的,读写PDF有那么多的库可以使用,唰唰的就完成了。忘记了我写C++的,还是在国产系统上开发的。所以一般的东西还不好使,因为项目需要在多个架构的电脑上使用,所以必须要开源,还要支持读写才行。 找了很多个PDF库(libharu、mupdf、pdfium、......
  • WPF绑定(Binding)(4)
    数据绑定组件之间的绑定<StackPanel><Sliderx:Name="sd"Width="200"/><TextBoxText="{BindingElementName=sd,Path=Value}"/></StackPanel> 绑定数据源<Window.Resources>......
  • 获取在电脑上的apk的appPackage和appActivity
    如果开发有给apk,那么可以在电脑上通过以下方法获得appPackage和appActivitycmd进入appt路径  然后输入指令(apk路径不要含有中文)aaptdumpbadgingapk路径(D:\**\**\**.apk)以上输出结果过多,我们可以按以下指令获取我们需要的数据获取appPackageaaptdumpbadgin......