views:

11

answers:

0

For more classes derived from a base class I decided to have a base UserControl and derived ones for each derived class (for visualisation; box on the right side of the image).

Now each of the derived UserControls have a specific settings (red rectangle on left) The settings UI is a separate UserControl (can be moved freely, put to separate dialog if too big...) and has a underlying data class which it changes (instance of this class is member of the main UserControl).

alt text

This brings me to creating a separate class holding (and possibly saving) the settings data, separate UserControl to set the values and connecting it manually all together.
This is not the first time I run into similar problem so I started to think about some class +interface allowing me to easily create the data holding classes and have the user controls generated. My idea is something like

class SettingsItem
{
    string name;
    TypeEnum type;
    double value;  //how about different types eg. bool? Inheritance?
}

The settings class would be a List of these items. For each type there would be a single value UserControl (checkbox/textbox/numericfield + description). A foreach loop would than create the final UserControl (one value UCs one under each other).

On one hand I like this idea as an intriguing challenge and potential relief of boring, repetitive and time consuming putting smaller squares into bigger ones and aligning them. On the other hand it seems to me a bit like killing a fly with a shotgun.

Is there some standard/ready solution to this? Any better way to do it? Or is it just too complex solution to minor problem? I'll be happy to see any answers, suggestions, remarks...