我怎样才能改变资源文件对于C#winform应用程序,而无需改变文化? [英] How can I change resource files for a c# winform app, without changing the culture?

查看:234
本文介绍了我怎样才能改变资源文件对于C#winform应用程序,而无需改变文化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个WinForm的应用程序,已经发展了一段时间。它有几个图像和创建品牌的经验控制颜色。我们有谁愿意同样的产品,但使用不同品牌的第二个客户

We have a winform app that has been in development for some time. It has several images and control colours that create a branded experience. We have a second customer who would like the same product, but with different branding.

因此,我们必须在控制的代码行designer.cs文件如:

So we have lines of code in the control designer.cs files like:

this.BackgroundImage = global::MyNameSpace.Properties.Resources.background;



这似乎是资源文件中去,因为我可以简单地改变文化,具有路用不同的图像单独的资源文件。

It seems like resource files are the way to go, as I could simply change the culture and have a separate resource file with different images.

但我不想改变文化(我不想日期,货币等的显示)是改变,它只是气味。

But I don't want to change the culture (I don't want the display of dates, currency, etc.) to be altered and it just smells.

我可以更改资源文件在运行时手动或编译时,无需改变文化?

Can I change the resource file manually at runtime or compile time without having to change the culture?

有没有更好的方式来实现这一结果?

Is there a better way to achieve this outcome?

此外,你怎么了/你能使用的资源文件来设置控件的颜色(如更改所有背景从黑到红)?

Also, how do you / can you use resource files to set controls colours (e.g. change all backgrounds from black to red)?

推荐答案

您可以从一个单独的文件,只是有资源的资源,读(但没有按' ŧ依赖于全球化的卫星组装机制)。您也可以编译默认资源与主程序集作为后备。

You can read in the resources from a separate file that just had the resources (but doesn't depend on the globalized satellite assembly mechanism). You could also compile default resources with your main assembly as a fall-back.

您可以使用的 Resgen.exe 来创建的的.resources 的文件从,例如,一个的。 RESX 的文件,然后使用的ResourceManager 来阅读:

You can use Resgen.exe to create a .resources file from, e.g., a .resx file and then use ResourceManager to read it:

//note that resourceFilename does NOT include the ".resources" extension
var rm = ResourceManager.CreateFileBasedResourceManager( resourceFilename
                                                        ,resourceDir
                                                        ,null);
this.BackgroundImage = (Image) rm.GetObject("background");

这篇关于我怎样才能改变资源文件对于C#winform应用程序,而无需改变文化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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