This is a migrated thread and some comments may be shown as answers.

Get all child panels

1 Answer 112 Views
Dock
This is a migrated thread and some comments may be shown as answers.
stealthsid
Top achievements
Rank 1
stealthsid asked on 08 Jul 2008, 05:11 PM
I am trying to persist the layout of all panels to disk whenever they are closed. I'm running into a few issues (which may be moot if there is an easy way/pattern to persist to disk which I just overlooked).

I have a DockPanel which contains a user control with its own DockingManager and DockPanels. In an ealier thread (and based on my experience) I know that the Closed event does not get called on the subordinate DockPanels. That's ok, I can work around that.

The problem I have now is that *I'm* trying to call a method on all subordinate DockPanels and I cannot find them all. Here's what I'm doing:

//This part is called on the parent DockPanel,
//which is subclassed to support the "Save" method to persist to disk
  private void SubClassedDockPanel_Closed(object sender, EventArgs e)
  {
   this.Save();
   this.SaveAllChildren(this.Controls);

   if (AfterClosed != null)
   {
    AfterClosed(sender, e);
   }
  }

  private void SaveAllChildren(ControlCollection controls)
  {
   foreach (Control c in controls)
   {
    SaveAllChildren(c.Controls);

    if (c as IDockManager != null)
    {
     IDockManager dManager = c as IDockManager;
     foreach (IDockingSite site in dManager.DockingSites)
     {
      foreach (IDockable panel in site.ManagedDockables)
      {
       if (panel as SubClassedDockPanel != null)
       {
        (panel as SubClassedDockPanel).Save();
       }
      }
     }
     return;
    }
   }
  }

basically I look for any DockingManagers in the parent DockPanel's controls and then iterate over all of their ManagedDockables in all the DockingSites. This works with the exception of when I AutoHide a child DockPanel.

There are a few difficulties I've encountered regarding "AutoHide". First is that it causes the Closed event to fire on the child panel that is being unpinned. I'd like to understand why this is happening, and (leading into my second difficulty) where does it go? The algorithm above will not find the autohidden DockPanel.

Any assistance is greatly appreciated, I know I've posted a few questions today,
Sid

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 11 Jul 2008, 11:39 AM
Hi Sid,

The DockSite collection of ManagedDockables returns only its hosted IDockable windows. In your case you must use the DockingManager's GetManagedDockables() method to return all IDockable windows from its DockingSites and AutoHide container.

In your case, only enumeration of DockingManagers is needed.

I hope this was helpful. If you have additional questions, please contact us back.

 
All the best,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Dock
Asked by
stealthsid
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or