Problem Statement:
I do have a blank Form with a Syncfusion DockingManager on it in my MainProject of type WindowsApplication. It does have one menustrip which is having the 'Save Dock Layout' and 'Load Dock Layout' options. All other Controls are docked to this Form at run time which essentially belongs to different usercontrol libraries. I need to save and load these controls dock states.
Issues in Implementation:
As per my observation, the DockingManager works as follows:
• Any control which is docked using DockingManager is kept inside the DockingManager's ControlsArray.
• When we save the dock state using AppStateSerializer, it is saved successfully(say in a XML file).
• When we load the dock state, DockingManager applies the dock state to the controls in its ControlsArray.
This works fine as long as DockingManager's ControlsArray is holding the references to the controls whose state is being loaded.
However, as I describe in the problem statement, my Application Starts with a blank Form and I can dock the other controls from other libraries by clicking a button on the main Form.
So the scenario is :
I statrted my application then by pressing a button 'DockControl' on it , I loaded the controls from other libraries onto my Form. Now I chose the 'Save Dock Layout' menu item and it saved the dock state to an XML file.
Now I close my application. When I start again then my application comes up with a blank form and now I chose the ‘Load Dock Layout’ menu item. AppStateSerializer loads the file in which the dock states were saved but since DockingManager’s ControlsArray is having no control at this point , therefore, DockingManager.LoadDockState(appStateSerializer) doesn’t apply the dock states.
A workaround to this issue:
I tried to serialize the controls information separately (i.e. control's type and names) and when my application starts I deserialized the controls information.
Now I instantiated those controls using reflection and tried to populate the DockingManager's ControlsArray. But since ControlsArray is an Array and initially its size is zero so I can not populate this and it gives me the 'ArrayIndex out of bound exception' when I try to assign the reflected controls to DockingManager's ControlsArray.
So this also doesn’t help me and my problem remains unsolved.
Other serious issues:
• If I dock the controls on a blank panel and (remember panel was also docked at run time) so to say the panel is docked onto the main Form and all other controls onto the panel. This way it even doesn't save the docked states.
• If I docked multiple instances of the same type control (say UserControl1, and 4 instances are docked) and saved the dock state. When I load the dock state only one instance is shown with the loaded dock state. So I lost another (3) instances.
Here is the code snippets from my application:
private void saveLayoutsToolStripMenuItem_Click(object sender, EventArgs e)
{
AppStateSerializer serializer = new AppStateSerializer(SerializeMode.XMLFile, "StateTest");
this.dockingManager.SaveDockState(serializer);
serializer.PersistNow(); // XML file is created on the disk.
}
private void loadLayoutsToolStripMenuItem_Click(object sender, EventArgs e)
{
AppStateSerializer serializer = new AppStateSerializer(SerializeMode.XMLFile, "StateTest");
this.dockingManager.LoadDockState(serializer);
}
Going forward, I would also like to know how I can push this dock state to the Database.
Your quick response over these issues will be highly appreciable.
-Thanx,
Pankaj.
Problem Statement.zip