I have a class that is used to create a "settings" GUI for any other class.
I use attributes to decorate the individual items. For example, you can specify ToolTipText:
[Attributes.Display(ToolTipText = "IP Address of target computer")]
public string IPAddress;
Now, the actual question: I'd like to add functionality to the display to create a group box around several items. My problem is that there isn't a "GroupBox" field or member already there for me to decorate.
I've had a few ideas on how to approach this:
Force the class to contain a
privateGroupBoxthat can be decorated. fields would be decorated to assign themselves to theGroupBox. I like that there is real something to decorate. I don't like that it really doesn't belong there. Another problem: If I wanted to create yet anotherGroupBoxas a child of this one it would be hard to order items within the firstGroupBox(currently ordering is controlled by the order of the class code itself)A. Same as (1), but modification of the
GroupBoxcould be done in the constructor of the settings class.B. Same as (1), but the settings class could subscribe to a "Draw" event and customize the ordering of controls there.
Ignore that there's no "physical" object to decorate and add an attribute called
GroupBoxNamethat fields could have. Any field containing the sameGroupBoxNamewould be grouped together.GroupBoxNamecould contain a "path" to create "subGroupBoxes" (e.g."ParentBox/ChildBox"). The problem with this approach is how do I modify the box itself? What if I want the box to haveBackColor = Color.Green? I could subscribe to an event with the settings class and specify there.
So, basically I'm looking for ideas on how to approach this. I would like the work from the settings class to be as intuitive as possible while still allowing for some flexibility. I'd also like to design this such that it doesn't have the "code smell" feel.
