WPF Windows上的夜视模式 [英] Night Vision Mode on WPF Windows

查看:66
本文介绍了WPF Windows上的夜视模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经制作了具有传统UI(常用的控件,如选项卡,按钮,标签,文本框等)的WPF应用程序.

We've made a WPF application with a traditional UI (common controls like tabs, buttons, labels, textboxes, and so on).

我们需要添加一个夜视"模式,使其看起来像Stellarium的夜视模式,以便可以在很少或根本没有光的地方舒适地使用它.

We need to add a "night vision" mode, which would make it look like Stellarium's night vision mode, so that it can be comfortably used in places with few or just no light at all.

据我所知,我们只有两个选择:

As far as I've seen, we only have two options:

  1. 一种称为阴影"的技术(我不知道该如何在WPF中实现).
  2. 蛮力方式:定义控件的样式模板.如您所知,这将意味着巨大的工作量,因为我们需要为正在使用的每个控件(边框,背景,笔刷等,等等)重新定义每个单独的属性.

问题是:

  1. 在WPF中实现此目标的最佳方法是什么?
  2. 如果我们使用MahApps Metro Style,会更复杂吗?我知道MahApps可以让您自定义样式,但是问题是会在不同的模板之间切换(分别用于白天和夜视).

非常感谢!

推荐答案

一个建议当然是 Mahapps Themes.您可以通过以下方法在明暗之间切换:

One suggestion is of course MahappsThemes. You could switch between Light and Dark by this :

// get the theme from the current application
var theme = ThemeManager.DetectAppStyle(Application.Current);

// now set the Green accent and dark theme
ThemeManager.ChangeAppStyle(Application.Current,
                            ThemeManager.GetAccent("Green"),
                            ThemeManager.GetAppTheme("BaseDark"));

( Mahapps.refs的样式)

或者您可以对每个笔刷使用DynamicResource并更改单个 ResourceDictionary 使其保持不变,从而在单击时更改所有内容:)

Or you could use DynamicResource for each Brushes and change the SINGLE ResourceDictionary holding them to change everything in a click :)

这篇关于WPF Windows上的夜视模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆