Profile Picture

Problems persisting layout.

Posted By lars knox 14 Years Ago
Author
Message
lars knox
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)

Group: Forum Members
Last Active: 13 Years Ago
Posts: 22, Visits: 1
Do you have a code example of how, upon the NDockingFrameworkState.StateRestored event, you would find a panel by key?

When I add panels, I'm careful to set the Key and Text properties. However, when I look at the XML representation of the persisted layout, I see that panels do not have their Text property values. They only have their Key property populated. However, inside the NDockingFrameworkState.StateRestored I cannot locate the panel by its Key. I've looked in the NDockManager.Containers, NDockManager.Containers.DockAreaProviders, and NDockManager.Panels collections but I am not able to locate the panel that should have loaded from the persisted XML.

Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi Lars,

There is no event that fires when a panel is restored.

However, you can attach to NDockingFrameworkState.StateRestored even to add your controls to the restored panels.



Best Regards,
Nevron Support Team



lars knox
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)

Group: Forum Members
Last Active: 13 Years Ago
Posts: 22, Visits: 1
I have added a document to the layout. Now when I hook up ResolveClientDocument and call Load on the state object:

NDockingFrameworkState state = new NDockingFrameworkState(nDockManager1);
state.Format = Nevron.Serialization.PersistencyFormat.XML;
state.PersistDocuments = true;
state.PersistStyles = true;
state.ResolveDocumentClient += new ResolveClientEventHandler(_layout_Restore_ResolveDocumentClient);
bool worked = state.Load(sFilename);

I DO get an event fired for the document. But I do NOT get an event fired for the panel that would give me the chance to resolve the client for the panel. I see the panel data is persisted in the layout XML (below).

I see that Documents do not have their Key attribute persisted but they do have their Text attribute persisted.

I see that Panels are the opposite. They persist their Key but not their Text.

How can I get the _layout_Restore_ResolveDocumentClient event to fire for the panel too?

Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi Lars,

This event will fire only if you have NUIDocuments in your docking framework.

It just notifies that a document has been deserialized and its Client needs to be resolved.

Attaching to this event will not persist the Client which is set to the document. You have to this separately.

The same applies to the controls that are in the panels.

The persisting of the docking framework persist only the state of the panels and documents. You should persists all other controls that are hosted in them separately.



Best Regards,
Nevron Support Team



lars knox
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)

Group: Forum Members
Last Active: 13 Years Ago
Posts: 22, Visits: 1
A follow up question would be if the Save/Load commands do not persist data about panels, is there a solution for persisting panel layout and their controls similar to how NUIDocuments are persisted and their controls are restored?

lars knox
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)

Group: Forum Members
Last Active: 13 Years Ago
Posts: 22, Visits: 1

Are you saying that if I add controls to a panel, and dock the panel to the root zone and then make sure I have an NUIDocument added in also somewhere that the Load(...) method will activate ResolveDocumentClient for the NUIDocuments only? Or will it also be called to populate the panels as well?

Or will ResolveDocumentClient never be called for panels at all even if I have documents added to the NDockManager?

 

 



Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi Lars,

This event fires if you have any NUIDocuments saved in you framework state.

It does not apply for panels.

Try to add some NUIDocuments in NDockManager.DocumentManager and when you load the state this event should fire.



Best Regards,
Nevron Support Team



lars knox
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)

Group: Forum Members
Last Active: 13 Years Ago
Posts: 22, Visits: 1

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;
}

 

 





Similar Topics


Reading This Topic