C# 应用程序广泛的色彩管理
我正在编写一个大型 C# 应用程序。 要点是控件的颜色应该由应用程序的用户进行调整。 如果有任何解决方案可以覆盖(仅适用于此应用程序的上下文)System.Drawing.SystemColors,那么我就不必手动设置每个控件的值,那就太好了。 有人知道我的问题的解决方案就这么简单吗? 谢谢
im on to write a large C# Application.
The point is that the colors of the controls should be adjustable by the user of the application.
It would be really nice if there are any solution to override(only for the context of this application) the System.Drawing.SystemColors, so that i do not have to set the value of every single control by hand.
Do anybody know an solution for my problem which is that simple?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
查看应用程序设置绑定。 不确定如何对所有控件执行此操作,但简单地通过控件树进行递归就足够了。
Look at Application Setting bindings. Not sure how you would do this for all controls, but simply recursing through the control tree should be sufficient.
我认为最好的方法是继承每个控件并设置其默认显示属性。 这将为您提供一个标准 WinForms 控件库,您可以轻松地自定义和重用它。 更多信息此处(在 VB 中,我找不到示例C#)。
I think your best approach would be to inherit each control and set its default display properties. This would give you a library of the standard WinForms controls that you could easily customize and re-use. More information here (in VB, I couldn't find examples in C#).
您不需要覆盖系统默认值,但您可以定义自己的颜色。
1 = 红色
2 = 绿色
3 = 蓝色
You shouldn't need to override the system defaults but you are able to define your own colours.
1 = Red
2 = Green
3 = Blue
遗憾的是,无法仅针对您的应用程序修改 Windows 配色方案。
Winforms 可以更改窗体上所有控件的背景颜色等内容,但对于许多区域(例如按钮上的斜角颜色或窗口标题栏),您可能需要自己绘制控件。
Unfortunately it's not possible to modify the Windows colour scheme just for your application.
Winforms makes it possible to change things like the background colour for all controls on a form, but for many areas (such as the bevel colours on buttons, or window title bars), you'll probably need to resort to painting the control yourself.
我编写了下面的代码来执行类似的操作。 我对它不是特别满意,因为它需要对任何不寻常的控件进行专门处理,但它完成了工作。 我保留了一个 Painter 实例,并在每次创建表单时调用 Apply,并将表单作为参数传递。 它递归所有子控件,改变它们的外观
I wrote the code below to do something like this. I'm not particularly happy with it as it needs specialized handling for any controls that are out of the ordinary, but it did the job. I keep an instance of Painter around, and call Apply every time I create a form, passing the form as the argument. It recurses through all the child controls, altering their appearance
花 1000 美元获取 DevExpress 的副本。 我们正在使用他们的框架编写一个大型应用程序,并且换肤能力非常好。
我知道这听起来不是最好的答案,但如果您正在寻找应用程序范围的换肤功能,第三方库可能是合适的。
Spend $1000 and get a copy of DevExpress. We're writing a large application using their framework, and the skinning ability is great.
I know this doesn't sound like the best answer, but if you're looking for application wide skinning ability, a third-party library may be appropriate.