public virtual void MakeFloatingRequest(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 floating
if (ContainsPage(uniqueName) && (FindPageLocation(uniqueName) != DockingLocation.Floating))
{
// If we can find a floating element appropriate for the named page
KryptonDockingFloating floating = FindDockingFloating(uniqueName);
if (floating != 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.DockingAllowFloating));
OnPageFloatingRequest(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 floating window with a restore page for the named page?
KryptonDockingFloatingWindow restoreElement = floating.FloatingWindowForStorePage(uniqueName);
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.FloatspaceElement.CellInsert(cell, pageIndex, new KryptonPage[] { page });
restoreElement.SelectPage(uniqueName);
restoreElement.FloatingWindow.Select();
}
else
{
// No floating window found to restore into, so create a new window
KryptonDockingFloatingWindow floatingElement = floating.AddFloatingWindow();
floatingElement.FloatspaceElement.Append(new KryptonPage[] { page });
floatingElement.SelectPage(uniqueName);
floatingElement.FloatingWindow.Show();
}
}
}
}
}
}