public virtual void MakeNavigatorRequest(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 navigator tabbed
if (ContainsPage(uniqueName) && (FindPageLocation(uniqueName) != DockingLocation.Navigator))
{
// If we can find a navigator element appropriate for the named page
KryptonDockingNavigator navigatorElement = FindDockingNavigator(uniqueName);
if (navigatorElement != 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.DockingAllowNavigator));
OnPageNavigatorRequest(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 });
// If we can find an existing page in the target navigator with the name we are inserting
KryptonDockableNavigator navigatorControl = navigatorElement.DockableNavigatorControl;
KryptonPage insertPage = navigatorControl.Pages[uniqueName];
if (insertPage != null)
{
int pageIndex = navigatorControl.Pages.IndexOf(insertPage);
if (pageIndex >= 0)
{
// Insert the page at the same index as the restore page
navigatorControl.Pages.Insert(pageIndex, page);
navigatorElement.SelectPage(uniqueName);
navigatorControl.Select();
}
else
{
// Append at end of current page collection
navigatorControl.Pages.Add(page);
navigatorElement.SelectPage(uniqueName);
navigatorControl.Select();
}
}
}
}
}
}
}