public virtual KryptonDockingDockspace AddDockspace(string path,
DockingEdge edge,
KryptonPage[] pages,
params KryptonPage[][] stackPages)
{
// Cannot add a null array
if (pages == null)
throw new ArgumentNullException("pages");
// Array must contain some values
if (pages.Length == 0)
throw new ArgumentException("pages cannot be zero length");
// Cannot action a null page reference
foreach (KryptonPage page in pages)
if (page == null)
throw new ArgumentNullException("pages array contains a null page reference");
// Resolve the given path to the expected docking control element
KryptonDockingControl control = ResolvePath(path) as KryptonDockingControl;
if (control == null)
throw new ArgumentException("Path does not resolve to a KryptonDockingControl");
// Find the requested target edge
KryptonDockingEdge edgeElement = control[edge.ToString()] as KryptonDockingEdge;
if (edgeElement == null)
throw new ArgumentException("KryptonDockingControl does not have the requested edge.");
// Find the docked edge
KryptonDockingEdgeDocked edgeDocked = edgeElement["Docked"] as KryptonDockingEdgeDocked;
if (edgeDocked == null)
throw new ArgumentException("KryptonDockingControl edge does not have a docked element.");
KryptonDockingDockspace dockspace = null;
using (DockingMultiUpdate update = new DockingMultiUpdate(this))
{
// Create a new dockspace and add the provided array of pages
dockspace = edgeDocked.AppendDockspace();
dockspace.Append(pages);
// If we have extra pages then we need to add a stack of tabbed cells
if ((stackPages != null) && (stackPages.Length > 0))
{
// For each array of pages...
foreach (KryptonPage[] pageArray in stackPages)
if ((pageArray != null) && (pageArray.Length > 0))
{
// We need a new cell with all the pages from the array
KryptonWorkspaceCell cell = new KryptonWorkspaceCell();
cell.Pages.AddRange(pageArray);
// Add into the root collection so the cells appear in a stack
dockspace.DockspaceControl.Root.Children.Add(cell);
}
// Set the correct direction for the stacking of cells at the root
switch (edge)
{
case DockingEdge.Left:
case DockingEdge.Right:
dockspace.DockspaceControl.Root.Orientation = Orientation.Vertical;
break;
case DockingEdge.Top:
case DockingEdge.Bottom:
dockspace.DockspaceControl.Root.Orientation = Orientation.Horizontal;
break;
}
}
}
return dockspace;
}