Hi,
I have read the http://help.nevron.com/dotnetvision/UsersGuide_DockingPanels_Layout_Presistency.html documentation pretty thoroughly and I'm still having problems persisting my layout.
The specific problem I am having is that the ResolveClientEventHandler does not appear to call the specified method when I call Load on the NDockingFrameworkState object. I've put debug.print statements in the _layout_Restore_ResolveDocumentClient method to verify this. I must be doing something wrong, but I cannot figure it out. One interesting thing to note is that I see a quick flash of what appears to be a splitter which disappears very quickly.
Here is an example of how I create and add panels. I pay special attention to setting the text and key properties of the panels:
private void addControlToRootZone(string text, string key, Control control, DockStyle dockStyle, bool insertAtBeginningVsEnd)
{
NDockingPanelHost panelHost = _populatePanelHost(text, key, control, dockStyle);
if (insertAtBeginningVsEnd)
nDockManager1.RootContainer.RootZone.AddChild(panelHost, 0);
else
nDockManager1.RootContainer.RootZone.AddChild(panelHost, nDockManager1.RootContainer.RootZone.Children.Count);
}
private NDockingPanelHost _populatePanelHost(string text, string key, Control control, DockStyle dockStyle)
{
control.Tag = key;
control.Dock = DockStyle.Fill;
NDockingPanel panel = new NDockingPanel();
panel.Key = key;
panel.Text = text;
panel.Dock = dockStyle;
panel.Controls.Add(control);
NDockingPanelHost panelHost = new NDockingPanelHost();
panelHost.AddChild(panel);
return panelHost;
}
Here is an example of how I save the layout:
static public void Save_ApplicationLayout(string sFilename, NDockManager nDockManager)
{
NDockingFrameworkState state = new NDockingFrameworkState(nDockManager);
state.Format = Nevron.Serialization.PersistencyFormat.XML;
state.PersistStyles = true;
state.PersistDocuments = true;
state.Save(sFilename);
state.Dispose();
state = null;
}
Here is an example of how I attempt to restore the layout. The sFilename variable value is identical to one used in the Save_ApplicationLayout. However, the ResolveClientEventHandler is never called/activated/etc:
private void Restore_ApplicationLayout(string sFilename)
{
NDockingFrameworkState state = new NDockingFrameworkState(nDockManager1);
state.Format = Nevron.Serialization.PersistencyFormat.XML;
state.ResolveDocumentClient += new ResolveClientEventHandler(_layout_Restore_ResolveDocumentClient);
bool worked = state.Load(sFilename); // <<--== The _layout_Restore_ResolveDocumentClient method is never called.
state.Dispose();
state = null;
}
void _layout_Restore_ResolveDocumentClient(object sender, DocumentEventArgs e)
{
System.Diagnostics.Print("The _layout_Restore_ResolveDocumentClient method was called."); // <<--== This never occurs.
string type = e.Document.Text;
switch (type)
{
case ControlKeyNames.StatusControl:
Documents.statusDocument statusControl1 = getStatusControl();
e.Document.Client = statusControl1;
statusControl1.Start();
Application.DoEvents();
break;
}
e.Handled = true;
}