public virtual void MakeDockedRequest(string uniqueName)
{
// Cannot process a null reference
if (uniqueName == null)
throw new ArgumentNullException("uniqueName");
// Unique names cannot be zero length
if (uniqueName.Length == 0)
throw new ArgumentException("uniqueName cannot be zero length");
// If the named page exists and is not already docked
if (ContainsPage(uniqueName) && (FindPageLocation(uniqueName) != DockingLocation.Docked))
{
// If we can find a docking edge element appropriate for the named page
KryptonDockingEdgeDocked docked = FindDockingEdgeDocked(uniqueName);
if (docked != null)
{
KryptonPage page = PageForUniqueName(uniqueName);
if (page != null)
{
// Ensure all docking controls have been layed out before the change is processed
Application.DoEvents();
CancelUniqueNameEventArgs args = new CancelUniqueNameEventArgs(uniqueName, !page.AreFlagsSet(KryptonPageFlags.DockingAllowDocked));
OnPageDockedRequest(args);
if (args.Cancel)
return;
using (DockingMultiUpdate update = new DockingMultiUpdate(this))
{
// Convert the page to a placeholder so it can be returned to the same location
PropogateAction(DockingPropogateAction.StorePages, new string[] { uniqueName });
// Is there a dockspace with a restore page for the named page?
KryptonDockingDockspace restoreElement = docked.FindStorePageElement(DockingLocation.Docked, uniqueName) as KryptonDockingDockspace;
if (restoreElement != null)
{
// Find the target cell and the index of the restore page
KryptonWorkspaceCell cell = restoreElement.CellForPage(uniqueName);
int pageIndex = cell.Pages.IndexOf(cell.Pages[uniqueName]);
// Insert the page at the same index as the restore page
restoreElement.CellInsert(cell, pageIndex, new KryptonPage[] { page });
restoreElement.SelectPage(uniqueName);
restoreElement.DockspaceControl.Select();
}
else
{
// No existing store page so add as a new dockspace
KryptonDockingDockspace dockspaceElement = docked.AppendDockspace();
dockspaceElement.Append(new KryptonPage[] { page });
dockspaceElement.SelectPage(page.UniqueName);
dockspaceElement.DockspaceControl.Select();
}
}
}
}
}
}