public virtual void MakeAutoHiddenRequest(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 auto hidden
if (ContainsPage(uniqueName) && (FindPageLocation(uniqueName) != DockingLocation.AutoHidden))
{
// If we can find an auto hidden edge element appropriate for the named page
KryptonDockingEdgeAutoHidden autoHidden = FindDockingEdgeAutoHidden(uniqueName);
if (autoHidden != 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.DockingAllowAutoHidden));
OnPageAutoHiddenRequest(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 auto hidden group with a restore page for the named page?
KryptonDockingAutoHiddenGroup restoreElement = autoHidden.FindStorePageElement(DockingLocation.AutoHidden, uniqueName) as KryptonDockingAutoHiddenGroup;
if (restoreElement != null)
{
// Find the target index of the restore page
KryptonAutoHiddenGroup control = restoreElement.AutoHiddenGroupControl;
int pageIndex = control.Pages.IndexOf(control.Pages[uniqueName]);
// Insert the page at the same index as the restore page
control.Pages.Insert(pageIndex, new KryptonAutoHiddenProxyPage(page));
}
else
{
// No existing store page so add as a new group
restoreElement = autoHidden.AppendAutoHiddenGroup();
restoreElement.Append(new KryptonPage[] { page });
}
}
}
}
}
}