允许用户选择全球主题的winform应用程序 [英] Allowing user selected Global Theme for winform app

查看:253
本文介绍了允许用户选择全球主题的winform应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个内部使用的winform应用程序中使用DevExpress控件。我的应用程序总共有30个表单,我试图找出一种允许我的用户选择主题的方法。我已经看到这里多次提到这里的其他帖子的答案。



我知道StyleController如何工作,我相信,但是我想知道的是我如何使用整个应用程序的1 Style控制器。



现在我试图在Shell窗体中创建一个StlyeController,然后将对它的引用传递给每个子窗体。从那里我必须为每个控件编程设置StyleController属性。我不介意我只是想知道,特别是那些已经做到这一点的人,如果有一个更简单的方法?

解决方案

很简单这个例子假设你正在使用皮肤。



在主窗体调用的构造函数中:

  DevExpress.Skins.SkinManager.EnableFormSkins(); 

这将使您的表单使用当前的皮肤。您也可以从XtraForm 中获取每个表单。



之后,您需要为应用程序设置全局外观和对象:

  //设置使用皮肤技术的样式
DevExpress.LookAndFeel.UserLookAndFeel.Default.Style = DevExpress .LookAndFeel.LookAndFeelStyle.Skin;

//这里我们使用它的名称指定使用的皮肤
DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(Black);

如果要设置Office 2003的应用程序的外观,设置是不同的。你只需要调用以下函数:

  DevExpress.LookAndFeel.UserLookAndFeel.Default.SetOffice2003Style(); 

所以,devexpress的每个控件都将使用这些设置来绘制自己。可以为某些控件指定一个自定义LookAndFeel对象,但是我从未使用过它,因为我没有看到有一个控件或表单的自定义显示点。



异常:
Devexpress框架中有一个例外。 NavBarControl不会自动从全局LookAndFeel对象中使用皮肤技术,您需要指定一个设置来启用:

  / /使用当前的皮肤
youNavBarControl.PaintStyleName =SkinNavigationPane;

//要使用当前的外观,没有皮肤
youNavBarControl.PaintStyleName =NavigationPane;


I am using DevExpress controls in a winform app I am building for internal use. My app has about 30 forms in total and I am trying to figure out a way to allow my user's to select a theme. I have seen this mentioned here at SO multiple times in answers to other posts.

I understand how the StyleController works, I believe, but what I am wondering is how I can use 1 Style controller for the whole app.

Right now I am trying to create 1 StlyeController at the Shell form and then pass a reference to it to each child form. From there I then have to programatically set the StyleController property for each control. I don't mind I just wonder, especially from those who have done this, if there is a simpler way?

解决方案

It is very simple. This example is assuming that you are using skins.

In the constructor of your main form calls:

DevExpress.Skins.SkinManager.EnableFormSkins();

This will enable your form to use the current skin. It is also important that each of your forms derived from XtraForm.

After that you need to setup the global look and feel object for your application:

//This set the style to use skin technology
DevExpress.LookAndFeel.UserLookAndFeel.Default.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin;

//Here we specify the skin to use by its name           
DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Black");

If you want to set the look and feel of your application like Office 2003, the setup is different. You just have to call the following function:

DevExpress.LookAndFeel.UserLookAndFeel.Default.SetOffice2003Style();

So, every control of devexpress will use these settings to paint themselves. It is possible to specify a custom LookAndFeel object for some controls but I never used it because I dont see the point to have a custom display for a control or a form.

Exception: There is one exception in Devexpress framework. The NavBarControl does not use the skin technology automatically from your global LookAndFeel object, you need to specify a setting to enable that:

//To use the current skin
youNavBarControl.PaintStyleName = "SkinNavigationPane";

//To use the current look and feel without the skin
youNavBarControl.PaintStyleName = "NavigationPane";

这篇关于允许用户选择全球主题的winform应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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