tags:

views:

36

answers:

1

Hi,

I have a Windows Forms application where I need to make all fonts of all UI elements configurable from a separate file. I.e. I want to be able to specify that a label has a font "TitleBarBoldFont" which would resolve to a real font, depending on the current locale. The configuration file may contain a corresponding section like this:

    <Font fontID="TitleBarBoldFont">
        <Display facename="Helvetica" pointSize="12">
            <Override lang="ja" facename="Meiryo Bold" pointSize="12"/>
            <Override lang="zh" facename="SimHei" pointSize="12"/>
            <Override lang="ru" facename="Arial Bold" pointSize="12"/>
        </Display>
    </Font>

My question is: is there a standard .NET/Windows Forms way to achieve this so that I could specify my custom fonts in the WinForms designer and wouldn't have to explicitly call a font resolution method for each GUI element in the code?

A: 

Simplest way is to bind the font property in the Properties Window to an application setting, which will end up in the app.config file for your application.

Russ
Sorry, but I can not figure out how to do this. How do I?
Corvin
Please see: http://msdn.microsoft.com/en-us/library/0yyxh69h(v=VS.85).aspx
Russ
It seems like the way to go, thanks!
Corvin
Russ, I researched - it seems that control properties can only be bound to static settings, defined in .settings file.Do you know if there is a way to bind the property to a setting, computed at runtime, so that I would use some string in the binding that would be resolved by my own class. I don't like the idea of having to duplicate all my font definitions in settings.settings file.
Corvin
You can bind all font settings to the same settings property.
Russ