public virtual void MakeWorkspaceRequest(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 workspace tabbed
if (ContainsPage(uniqueName) && (FindPageLocation(uniqueName) != DockingLocation.Workspace))
{
// If we can find a workspace element appropriate for the named page
KryptonDockingWorkspace workspaceElement = FindDockingWorkspace(uniqueName);
if (workspaceElement != 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.DockingAllowWorkspace));
OnPageWorkspaceRequest(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 });
// Find the target cell, if there is one, that contains a store page
KryptonWorkspaceCell cell = workspaceElement.CellForPage(uniqueName);
if (cell != null)
{
// Insert the page at the same index as the restore page
int pageIndex = cell.Pages.IndexOf(cell.Pages[uniqueName]);
workspaceElement.CellInsert(cell, pageIndex, new KryptonPage[] { page });
workspaceElement.SelectPage(uniqueName);
workspaceElement.DockableWorkspaceControl.Select();
}
else
{
// No existing store page so just append to the worksapce
workspaceElement.Append(new KryptonPage[] { page });
workspaceElement.SelectPage(uniqueName);
workspaceElement.DockableWorkspaceControl.Select();
}
}
}
}
}
}