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. R - MQ

    1. rabbit MQ 安装 Rabbit MQ 是建立在强大的Erlang OTP平台上,因此安装Rabbit MQ的前提是安装Erlang.通过下面两个连接下载安装3.2.3 版本: 下载并安装 ...

  2. grouping sets从属子句的运用

    grouping sets主要是用来合并多个分组的结果. 对于员工目标业绩表'businessTarget': employeeId targetDate idealDistAmount 如果需要分别 ...

  3. json的场景应用与实战

    首先 要感谢慕课网的老师 地址:http://www.imooc.com/learn/68 下面我来开始总结: 什么是json的这些我就不多说了  不懂百度 <?php function cre ...

  4. Fragment完全解析

    Android Fragment 的使用,一些你不可不知的注意事项 Fragment全解析系列(一):那些年踩过的坑 Fragment全解析系列(二):正确的使用姿势 Fragment之我的解决方案: ...

  5. 配置react native遇到的问题

    折腾了两天终于解决了问题,一开始用模拟器是报如下图的错 然后用真机的时候又报下图的错 这个错误网上有很多解决方法,说是要降级处理,将build.gradle中的1.3.1改成1.2.3,但是改完之后问 ...

  6. FastDFS 通过文件名获取文件信息

    /** * 获取文件信息 * * param string group_name 文件所在的组名 * param string file_id 文件id(如: M00/09/BE/rBBZolgj6O ...

  7. c# 本周时间查询

    var now = DateTime.Now();int weeknow = Convert.ToInt32(now.DayOfWeek); //因为是以星期一为第一天,所以要判断weeknow等于0 ...

  8. bzoj 3676 回文串 manachar+hash

    考虑每个回文串,它一定是它中心字母的最长回文串两侧去掉同样数量的字符后的一个子串. 所以我们可以用manachar求出每一位的回文半径,放到哈希表里并标记出它的下一个子串. 最后拓扑排序递推就行了.. ...

  9. django用户认证

    利用django自带认证功能实现用户登录认证. views.py # Create your views here. from django.shortcuts import render_to_re ...

  10. Sqlite使用

    安装命令行工具从http://www.sqlite.org/download.html下载Precompiled Binaries for Windows下的sqlite-tools-win32-x8 ...