using System;
using System.Windows;
using Assergs.Windows; namespace XMLSpy.WPF.Util{
/// <summary>
/// ThemeSwitcher所使用的主题枚举
/// </summary>
[Flags]
public enum ThemeEnum{
CLASSIC = ,
ROYALE = ,
LUNA = ,
LUNA_HOMESTEAD = ,
LUNA_METALLIC = ,
/// <summary>
/// Vista默认主题
/// </summary>
AERO = ,
/// <summary>
/// Office2007主题
/// </summary>
OFFICE2007 =
} /// <summary>
/// Theme切换
/// </summary>
public class ThemeSwitcher{
/// <summary>
/// 切换Theme
/// </summary>
/// <param name="theme">Theme枚举</param>
/// <param name="element">FrameworkElement对象</param>
public static void SwitchTheme(ThemeEnum theme, FrameworkElement element){
element.Resources.MergedDictionaries.Add(GetThemeResourceDictionary(theme));
} //public static void UnloadTheme(ThemeEnum theme,FrameworkContentElement element) {
// element.Resources.MergedDictionaries.Remove(GetThemeResourceDictionary(theme));
//} public static ResourceDictionary GetThemeResourceDictionary(ThemeEnum theme){
Uri uri = null;
//==================== OFFICE2007 ======================================
//Assergs.Windows.dll
//office2007
if (theme == ThemeEnum.OFFICE2007){
return new OfficeStyle();
} switch (theme){
//==================== CLASSIC ======================================
//C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.Classic.dll
//classic
case ThemeEnum.CLASSIC:
uri =
new Uri(
"/PresentationFramework.Classic, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35;component/themes/classic.xaml",
UriKind.Relative); break;
//==================== ROYALE ======================================
//C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.Royale.dll
//royale.normalcolor
case ThemeEnum.ROYALE:
uri =
new Uri(
"/PresentationFramework.Royale, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35;component/themes/royale.normalcolor.xaml",
UriKind.Relative);
break;
//==================== LUNA ======================================
//C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.Luna.dll
//luna.normalcolor
case ThemeEnum.LUNA:
uri =
new Uri(
"/PresentationFramework.Luna, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35;component/themes/luna.normalcolor.xaml",
UriKind.Relative);
break;
//luna.homestead
case ThemeEnum.LUNA_HOMESTEAD:
uri =
new Uri(
"/PresentationFramework.Luna, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35;component/themes/luna.homestead.xaml",
UriKind.Relative);
break;
//luna.metallic
case ThemeEnum.LUNA_METALLIC:
uri =
new Uri(
"/PresentationFramework.Luna, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35;component/themes/luna.metallic.xaml",
UriKind.Relative);
break;
//==================== AERO ======================================
//C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.Aero.dll
//aero.normalcolor
case ThemeEnum.AERO:
uri =
new Uri(
"/PresentationFramework.Aero, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35;component/themes/aero.normalcolor.xaml",
UriKind.Relative);
break;
}
return Application.LoadComponent(uri) as ResourceDictionary;
}
}
}

WPF 主题切换(Z)的更多相关文章

  1. WPF 主题

    原文:WPF 主题 WPF 切换主题 string packUri = String.Format(@"/WpfControlLibrary1;component/Dictionary1.x ...

  2. CSS自定义属性与前端页面的主题切换

    基于级联变量的CSS自定义属性,已经出来很多年了. 虽然有less.sass等预处理器大行其道,但是自定义属性也有它的特点和用处,诸如在js中读写.作用域设置等等,在处理UI主题切换等功能上也发挥着很 ...

  3. Android 主题切换 小结

    前言 我们用手机的时候经常看到 设置里面有夜间模式和白天模式来更换APP的主题,以前以为很简单,但是实际做起来还是有各种不完美,那么我们也要去了解各种解决方案来丰富我们的知识,现在我们就来看看各种优劣 ...

  4. Xceed WPF 主题皮肤控件Xceed Professional Themes for WPF详细介绍

    Xceed Professional Themes for WPF是一款为你的整个应用程序提供完美WPF主题风格的控件,包含Office 2007和Windows 7,可以应用到任何微软官方的WPF控 ...

  5. windows phone主题切换(换肤)

    之前项目做了个主题切换的功能,最后客户没来得及出第二套界面给放弃了,默哀中... 为了不让它就这样流产了,就放博客共享吧. 首先说明下原理:这个切换是通过重写资源字典里指定的样式,在运行的过程中加载指 ...

  6. Android主题切换方案总结

    所谓的主题切换,就是能够根据不同的设定,呈现不同风格的界面给用户,也就是所谓的换肤. 1.将主题包(图片与配置)存到SD卡上(可通过下载或手动放入指定目录),在代码里强制从本地文件创建图片与配置文字大 ...

  7. extjs folder is lost解决方法 和 FineUI主题切换时 iframe内的内容主题不变的解决方法

    错误原因:extjs包和FineUI版本不一致 或者是 webconfig配置中 没有设置为任何人可访问  解放方法下载和FineUI版本相同的extjs包就ok了 解决方法:FineUI主题切换时 ...

  8. WPF页面切换及弹窗

    WPF页面切换及弹窗 结构如图: 效果如图: 代码如下: xaml <Window x:Class="PageChange.MainWindow" xmlns="h ...

  9. iOS开发之App主题切换完整解决方案(Swift版)

    本篇博客就来介绍一下iOS App中主题切换的常规做法,当然本篇博客中只是提到了一种主题切换的方法,当然还有其他方法,在此就不做过多赘述了.本篇博客中所涉及的Demo完全使用Swift3.0编写完成, ...

随机推荐

  1. Ext动态加载Toolbar

    在使用Ext的GridPanel时候,有时候需要面板不用重新加载而去更新Store或者Toolbar,Store的方法有很多,例如官方api给我们提供的Store.load(),Store.reLoa ...

  2. vector迭代器用法

    #include<iostream> #include<vector> using namespace std; int main() { vector<int> ...

  3. delphi 实现最小化系统托盘

    1.new -->application 2.在form1中加入一个tPopMenu 命名为pm1 3.uses ShellAPI; 4.定义一个常量在 const WM_TRAYMSG = W ...

  4. 小猪cms模块继承

    TextAction  继承 UserAction 继承 BaseAction 继承 Action TextAction 路径 PigCms\Lib\Action\User UserAction 路径 ...

  5. bash的管道符与重定向

    管道符"|"可以用来将前面的程序的标准输出stdout(=1)重定向到后一个程序的stdin(=0),但是忽略了stderr. 在bash中使用2>&1 可以表示将s ...

  6. Android Studio解决未识别Java文件(出现红J)问题

    1.问题:java文件出现了红J的问题,正常情况下应该是显示蓝色的C标识. 2.解决方案:切换到project视图下,找到app这个module里的build.gradle,在android结构里插入 ...

  7. centos 6.4 getmail 收取163 邮件

    #CentOS 6.6 64bit 默认yum 源没有getmail rpm包#首先安装EPEL yum 源EPEL(Extra Packages for Enterprise Linux):http ...

  8. C#客户端的异步操作

    上篇博客[用Asp.net写自己的服务框架] 我讲述了如何实现自己的服务框架,但我想很多人应该用过WebService这类服务框架,相比起来,似乎还缺少什么东西, 是的,我也感觉到了.比如:我可以很容 ...

  9. 12月15日smarty模板基本语法

    smarty基本语法: 1.注释:<{* this is a comment *}>,注意左右分隔符的写法,要和自己定义的一致. <{* I am a Smarty comment, ...

  10. 严重: Error starting static Resources java.lang.IllegalArgumentException:

    严重: Error starting static Resources java.lang.IllegalArgumentException: Document base E:\myworkspace ...