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. StarUML license key

    参考博客:http://blog.csdn.net/Excing/article/details/48998891 方法 将StarUML/www/license/node/LicenseManage ...

  2. swfit-学习笔记(表UITableView的简单使用)

    /*使用与Object-C基本类似,只做简单地使用,创建表及其设置数据源和代理*/ import UIKit class ViewController: UIViewController,UITabl ...

  3. Dockerfile初探

    git上的asp.net samples工程已经写好了docker file,内容是如下   //任何dockersfile都要以FORM开头,约定是用大写. FROM microsoft/aspne ...

  4. IDEA快捷键

    [常规] Ctrl+Shift + Enter,语句完成 "!",否定完成,输入表达式时按 "!"键 Ctrl+E,最近的文件 Ctrl+Shift+E,最近更 ...

  5. ViewStateMode vs EnableViewState

    What's the difference between: ViewStateMode: Disabled / Enabled / Inherit EnableViewState: True / F ...

  6. bash的管道符与重定向

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

  7. synergy 使用记录

    synergy 是一个多台电脑之间,共享鼠标.键盘的开源工具,做的很赞.目前,这个工具对 Windows.Linux.MacOS 都有很好的支持. 手上 arm 板安装的是 debian 系统,所以, ...

  8. Using Celery with Djang

    This document describes the current stable version of Celery (4.0). For development docs, go here. F ...

  9. R 单变量重命名与删除

    单变量重命名 b = rename(b,c(target="flag")) 单变量删除    b = b[,names(b)!='age'] 或者 b[,"age&quo ...

  10. Jquery实现特效滑动菜单栏

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...