App.config中的FontStyle [英] FontStyle from App.config

查看:84
本文介绍了App.config中的FontStyle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要求在窗口应用程序中将Font相关属性配置为可配置。但是如何在App.config中设置FontStyle属性并在我的应用程序中使用它(问题是FontStyle是enumaration以及如何将字符串值转换为FontStyle)

提前感谢。

I have requirement to make Font related properties as configurable in my window application. But how to set FontStyle attribute in App.config & use it in my application (problem is that FontStyle is enumaration and how to convert string value to FontStyle)
Thanks in advance.

推荐答案

检查出来: C#使用app.config定义字体设置 [ ^ ]


如果你是真的需要app.config而没有别的(它可以是任何类型的配置文件,包含当前选项,可以在运行时随时保存和加载,与app.config相比),你需要阅读:

https://msdn.microsoft.com/en-us /library/2tw134k3%28v=vs.140%29.aspx [<一个href =https://msdn.microsoft.com/en-us/library/2tw134k3%28v=vs.140%29.aspxtarget =_ blanktitle =New Window> ^ ]。



我希望,应用字体和其他属性对你来说不是问题。



上面,我向您解释了使用非配置文件的好处,但其他内容。 app.config的另一个问题是:如果这个文件可以用于某些严重的应用程序调整,那么用许多自定义部分污染它会非常糟糕。这是将UI选项保存在单独文件中的另一个原因。大多数情况下,使用设置,但我认为它们已经过时,不够灵活,所以我从不使用此功能,而是使用我自己的文件。请参阅:

https:// msdn .microsoft.com / zh-CN / library / ms733127%28v = vs.110%29.aspx [ ^ ]。



-SA
If you are really required app.config and nothing else (it could be any kind of configuration file holding current options which could be saved and loaded during runtime any time, in contrast to app.config), you need to read this:
https://msdn.microsoft.com/en-us/library/2tw134k3%28v=vs.140%29.aspx[^].

I hope, application of fonts and other properties won't be a problem for you.

Above, I explained you the benefit of using not configuration file, but something else. Another problem with app.config is: if this file can be used for some "serious" application tune-up, so contaminating it with many custom sections would be pretty bad. This is another reason for saving the UI options in a separate file. Most usually, settings are used, but I think they are obsolete, not flexible enough, so I never use this feature, use my own file instead. Please see:
https://msdn.microsoft.com/en-us/library/ms733127%28v=vs.110%29.aspx[^].

—SA


感谢您的帮助。

我发现 http://stackoverflow.com/questions/8148622/get-enum-values-from-web-config-at-run-time [ ^ ]非常有用并解决了我的问题。
Thanks for your help.
I found http://stackoverflow.com/questions/8148622/get-enum-values-from-web-config-at-run-time[^] very useful and solve my issue.


这篇关于App.config中的FontStyle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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