I have different sets of custom Winforms controls all deriving from Control such as:
CalculatorPanel, GraphPanel, DisplayPanel, etc : Control
I use a single Form to display one or more of these sets depending on what the user wants to see.
All of them has a member called:
Input
where the type is different such as:
CalculatorInput, GraphInput, DisplayInput, etc.
How do I store them in a list or some other collection where I can call the Input property without any problem?
Should I use a common interface for each? Then it has to be generic. How will I specify the type?
Right now I use something like this to add/remove controls:
Panels = Dictionary <Enum, Control> ...
Panels.Add (PanelType.Calculator, new CalculatorInput ().Controls);
...
so later I can say:
Form.Add/RemoveControls (Panels[PanelType.Calculator])
but how would I set their Input property when I need to at runtime. So if the user switches to the GraphPanel, I want to be able to set it's Input right after I added its controls to the Form.
Is there a design pattern or a technique to solve this?
EDIT: Properties of each input type (no methods) are as follows:
CalculatorInput:
.Result
.LastOperation
...
GraphInput:
.Result
.SelectedNode
...
DisplayInput:
.Result
.CurrentColor
...
Basically these inputs are just types to be bound to the appropriate UI. So if the UI has some properties, they are bound to these input, which is why when I assign a new input, the UI will update automatically.
EDIT2:
So all these inputs are separate no inheritance, etc.
But are defined in appropriate rollouts as follows:
class CalculatorPanel
{
CalculatorInput Input
}
class GraphPanel
{
GraphInput Input
}
class DisplayPanel
{
DisplayInput Input
}