Application Options

Soldato
Joined
5 Mar 2003
Posts
10,771
Location
Nottingham
Hi,
I have an application and wondering how to do the "options"; you know, things like font size, colour etc - options that will affect how the application behaves and looks.

Basically I'm wondering the best way to do such a thing. My main idea is to have a class which will encompass all of the options and their values and control the reading and writing to the xml hard copy when the options are changes / application loaded and unloaded. Just unsure of whether or not this is the correct approach. Other problem is how to make the options visible to all forms that are contained within the application.

Any ideas?

Thanks :)
 
Thats how I would do it also. To get the settings on all forms I would overload each forms constructor with one that takes the settings object as a parameter, and then enforces the settings.
 
You should use the configuration classes to read from the appsettings section of the appconfig file at startup. Note in .NET 1.0-1.1 changes to these settings at run time will require an exe restart before they are effected. In 2.0 the configuration system has been overhauled and there is better support. Google configuration management for all you need. If you want to be really smart then make use of the configuration management application block which I think now is part of the MS enterprise library.
 
ok so thats how i store and get data back - but how do i store the data in memory - have it as a class that all forms have reference too, or just read from the file each time a form is loaded?
 
Goksly said:
ok so thats how i store and get data back - but how do i store the data in memory - have it as a class that all forms have reference too, or just read from the file each time a form is loaded?

You can create a global(static I assume in C#) class instance to represent the deserialized config settings. If .Net 1.1 google for IconfigurationSectionHandler create a class that inherits from that puppy and you'll be good.
 
Back
Top Bottom