private void OnFloatspaceBeforePageDrag(object sender, PageDragCancelEventArgs e)
{
// Validate the list of names to those that are still present in the floatspace
List<KryptonPage> pages = new List<KryptonPage>();
foreach (KryptonPage page in e.Pages)
if (!(page is KryptonStorePage) && (FloatspaceControl.CellForPage(page) != null))
pages.Add(page);
// Only need to start docking dragging if we have some valid pages
if (pages.Count != 0)
{
KryptonDockingManager dockingManager = DockingManager;
if (dockingManager != null)
{
// If there is just a single visible cell
if (FloatspaceControl.CellVisibleCount == 1)
{
// And that visible cell has all the pages being dragged
KryptonWorkspaceCell cell = FloatspaceControl.FirstVisibleCell();
if (cell.Pages.VisibleCount == pages.Count)
{
// Get the owning floating window element
KryptonDockingFloatingWindow window = GetParentType(typeof(KryptonDockingFloatingWindow)) as KryptonDockingFloatingWindow;
if (window != null)
{
// Drag the entire floating window
dockingManager.DoDragDrop(e.ScreenPoint, e.ElementOffset, e.Control, window);
// Always take over docking
e.Cancel = true;
return;
}
}
}
// Add a placeholder for the cell that contains the dragged page, so the cell is not removed during dragging
KryptonWorkspaceCell firstCell = FloatspaceControl.CellForPage(e.Pages[0]);
if (firstCell != null)
firstCell.Pages.Add(new KryptonStorePage("TemporaryPage", "Floating"));
// Ask the docking manager for a IDragPageNotify implementation to handle the dragging operation
dockingManager.DoDragDrop(e.ScreenPoint, e.ElementOffset, e.Control, e.Pages);
}
}
// Always take over docking
e.Cancel = true;
}