Projects » Dot Net » Util.Settings

Util.Settings

Version 1.0
Download: Util.Settings.zip

Util.Settings provides a simple way to store string, number, and boolean settings. It uses a simple XML format. It also provides methods for saving and restore the size and position of WinForms forms.

User Settings

API

new UserSettings(string path)
Loads the settings file at the given path, or creates a new one at the given path if one does not exist.
property bool AutoSave
If true, settings will be saved after every change. If false, settings are only saved back to disc when Save() is called. Defaults to true.
UserSetting.Save()
Saves the settings to disc.
string UserSettings.Get(string setting_name, string default_value)
   int UserSettings.Get(string setting_name, int default_value)
  bool UserSettings.Get(string setting_name, bool default_value)
These functions retreive a setting. If the setting doesn't exist, the given default_value is returned. The type of the default_value determines the type of the returned setting.
UserSettings[string setting_name] = (object)value
Sets the given named setting to the given value.
UserSettings.Remove(string setting_name)
Removes the given setting.
bool UserSettings.Has(string setting_name)
Returns true if the given setting exists.
SaveFormState(Form f)
Saves the size and position of the given form. If the form is maximized, that state will also be saved.
LoadFormState(Form f)
Restores the size and position of the given form. If the form was maximized, it will be re-maximized.
Notes:
  • Setting names are case-insensitive.
  • Settings related to form size and position are prefixed with the form's design name.

Examples

The included demo project shows how to use Util.Settings. It has two edit controls that are linked to settings. The size and position of the demo form is also saved between sessions.


Contact Information

  • Email: