The Default Manager Class was created to provide a uniform method of storing and retrieving default settings. There are four levels of default storage; Registry, User Global, Window Global and User Global.
It really is as simple as all that. Two method, GetDefault and SaveDefault. We use it for everything! Storing database setting in the registry? Handled! Company wide preference for print preview? Handled! Default the last parameters settings for report so that the next time a user runs the report it remembers the settings, even if they run it from a different computer? Handled! Its deceptively simple, and nothing that can not be done in procedural code, but it sure is nice and gets used a lot more when all the developer has to do is say GetDefault and SaveDefault with 3 little parameters and let the magic happen.
Enough of a sales job. I hope you enjoy it. If you have any questions, suggestions, complaints (well not complaints) then please use the comments below so we can all benefit from each others additions. This article will be updated with each new release of the class.
Note there are references in the class to the SystemLogClass, which is a class I use to record all user error messages for later support. That class is not fully ready for the world but since WX doesn’t provide a way for me to set optional compile directives so that you don’t get compile errors for the references to the other class, I have included it in the zip for now. As long as it is in your project you are fine, if you don’t instantiate it it will not be used. If you want to use it you are more than welcome to but there is no documentation and it has not be fully fleshed out just yet. Your other option would be to remove or comment out the lines of code related to the System Log class, there would be no adverse effect on the Default Manager class.
A Note about code bricks. There isn’t a method of using multiple code bricks files or sharing just partial code bricks. What I will be doing is sharing my collection of code bricks, there are three files that make up the code bricks. Simply put them in a directory on your system and then from WX you can edit the environment settings and point to that code brick directory. And then copy those code bricks into your normal code bricks files. What I find works best is to have two copies of WD open, each pointing to a different code brick directory.
If you have any questions about the NextAge Open Source initiative be sure to check out this post.
The Download Links
1.0 – December 25, 2012
1.01 – January 16, 2013
- Rename Local Instance of SystemLogClass to TheSystemLogClass to avoid intellisense issues.
- Ability to store Binary Data – Thanks to suggestions from Pragma Tix.
- Corrected issue with the Assignment of Window Name not being correct if called from within a control’s code process.
- Fix for initial creation of Registry Key
1.02 – June 5, 2015
- Added New Constant SystemGlobal to allow store data that is global for the entire application regardless of user or window
- Added Support for a .config file