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. EncodingHelper

    /// <summary> /// Url解码 /// </summary> /// <param name="str">原始字符串</p ...

  2. .NET Mvc中ViewBag、ViewData、TempData如何使用

    ViewBag 获取动态视图数据字典 作用:给视图传递数据,不需要转换类型,由系统动态解析,比ViewData执行性能要差 ViewData   获取或设置视图数据的字典         给视图传递数 ...

  3. 【hihoCoder 1454】【hiho挑战赛25】【坑】Rikka with Tree II

    http://hihocoder.com/problemset/problem/1454 调了好长时间,谜之WA... 等我以后学好dp再来看为什么吧,先弃坑(╯‵□′)╯︵┻━┻ #include& ...

  4. 基于Swiper 2.7.6实现的带缩略图功能的轮播图

    非原创,只能适合PC端,如果是移动端,只需要修改界面的大小即可.界面如下: 链接:http://pan.baidu.com/s/1pK9XdUV 密码:jsyk

  5. Python JPype 在 Win7 下安装与使用

    JPype 是 Python调用 Java 代码的模块,需要Java SE Runtime Environment (JRE)的支持. 个人安装环境: Windows 7 64bit + Python ...

  6. zabbix安装

    在服务器10.128.17.136上安装 1.安装mysql \# yum -y install mysql mysql-server mysql-devel MySQL 配置文件/etc/my.cn ...

  7. 为什么不用rxjava?

    rxjava等系列产品.思想是很好的,但是被大多数人用成了一坨屎! 就拿rx最经典的那个例子来说: 假设有这样一个需求:界面上有一个自定义的视图 imageCollectorView ,它的作用是显示 ...

  8. 浅谈Android样式开发之shape

    引言 在Android开发中我们很多情况都是使用图片来展示相关效果,今天我就来详细介绍下Android下使用Shape来进行简单UI的开发.一方面这些是Android开发的基础,另一方面这方面的知识可 ...

  9. Fedora20-64bit cross-compiling arm-linux-gcc

    0按照友善之臂的手册建立交叉编译环境时,添加用户变量,最好是去更改 profile 文件 因为 profile 是所有用户都可以使用的,类似于 windows 中的系统变量 而 .bashrc 只有该 ...

  10. [asp.net core]定义Tag Helpers

    原文地址 https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/authoring Getting started wi ...