Well, if I get it right, you want to call forms and put them as children of MDIParent FormCaller. I did something similar, but before, let's put some points ...
The way you're suggesting: caller.CallForm(anotherForm)
, requires the FormCaller class to "know" all of the forms that will be invoked. See if I can help you get some idea with the implementation below ...
To solve the problem, I had created a class / enumeration just to describe the child forms of MDI, but the maintenance was very constant. I then decided to change strategy and create a pattern that could be reused by any other MDIParent.
I have created an interface that forces all MDIParent know how to invoke their children (in my case, by index);
Implemented the interface in an abstract class that would execute the desired patterns (in this case, invoking forms);
Inherit the abstract class in any target MDIParent.
Something like:
public interface IMdiContainer
{
Form GetCurrentForm(int currentStep);
}
public abstract class MdiContainerBase
{
private IMdiContainer _container;
protected int index;
public MdiContainerBase(IMdiContainer container)
{
_container = container;
}
protected override void OnShow(EventArgs e)
{
base.OnShow(e);
// Call mdiChild from mdiContainer
ShowMdiChild(_container.GetCurrentForm(index));
}
protected override void NextForm()
{
ShowMdiChild(_container.GetCurrentForm(++index));
}
protected override void PrevForm()
{
ShowMdiChild(_container.GetCurrentForm(--index));
}
private void ShowMdiChild(Form form)
{
form.MdiParent = this;
form.Show();
}
// and so on...
}
public class MyCustomMdiContainer : MdiContainerBase, IMdiContainer
{
public MyCustomMdiContainer() : base(this)
{
}
// implementation forced by interface
public Form GetForm(int index)
{
switch(index)
{
case 1:
return new Form1();
case 2:
return new Form2();
default:
return null;
}
}
}
So you can create everything you need in the interface ... You just need to create the switch ... I hope I have helped in some way:)