private void OnDockableNavigatorBeforePageDrag(object sender, PageDragCancelEventArgs e) { // Validate the list of names to those that are still present in the navigator List <KryptonPage> pages = new List <KryptonPage>(); foreach (KryptonPage page in e.Pages) { if (!(page is KryptonStorePage) && DockableNavigatorControl.Pages.Contains(page)) { pages.Add(page); } } // Only need to start docking dragging if we have some valid pages if (pages.Count != 0) { // Ask the docking manager for a IDragPageNotify implementation to handle the dragging operation KryptonDockingManager dockingManager = DockingManager; if (dockingManager != null) { dockingManager.DoDragDrop(e.ScreenPoint, e.ElementOffset, e.Control, e.Pages); } } // Always take over docking e.Cancel = true; }
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; }
private void PageDragStart(Point pt) { if (DragPageNotify != null) { // Create a page that will be dragged _dragPage = new KryptonPage(); _dragPage.Text = _dragNode.Text; _dragPage.TextTitle = _dragNode.Text + " Title"; _dragPage.TextDescription = _dragNode.Text + " Description"; _dragPage.ImageSmall = ImageList.Images[int.Parse((string)_dragNode.Tag)]; _dragPage.Tag = _dragNode.Tag; // Create a rich text box with some sample text inside KryptonRichTextBox rtb = new KryptonRichTextBox(); rtb.Text = "This page (" + _dragPage.Text + ") contains a rich text box control as example content."; rtb.Dock = DockStyle.Fill; rtb.StateCommon.Border.Draw = InheritBool.False; // Add rich text box as the contents of the page _dragPage.Padding = new Padding(5); _dragPage.Controls.Add(rtb); // Give the notify interface a chance to reject the attempt to drag PageDragCancelEventArgs de = new PageDragCancelEventArgs(PointToScreen(pt), Point.Empty, this, new KryptonPage[] { _dragPage }); DragPageNotify.PageDragStart(this, null, de); if (de.Cancel) { // No longer need the temporary drag page _dragPage.Dispose(); _dragPage = null; } else { _dragging = true; Capture = true; } } }
private void OnDockableWorkspaceBeforePageDrag(object sender, PageDragCancelEventArgs e) { // Validate the list of names to those that are still present in the dockspace var pages = new List <KryptonPage>(); foreach (KryptonPage page in e.Pages) { if (page is not KryptonStorePage && (DockableWorkspaceControl.CellForPage(page) != null)) { pages.Add(page); } } // Only need to start docking dragging if we have some valid pages if (pages.Count != 0) { // Ask the docking manager for a IDragPageNotify implementation to handle the dragging operation KryptonDockingManager dockingManager = DockingManager; dockingManager?.DoDragDrop(e.ScreenPoint, e.ElementOffset, e.Control, e.Pages); } // Always take over docking e.Cancel = true; }
/// <summary> /// Initialize a new instance of the CellDragCancelEventArgs class. /// </summary> /// <param name="e">Event to upgrade to this event.</param> /// <param name="cell">Workspace cell associated with pages.</param> public CellDragCancelEventArgs(PageDragCancelEventArgs e, KryptonWorkspaceCell cell) : base(e.ScreenPoint, e.ElementOffset, e.Control, e.Pages) { Cell = cell; }
/// <summary> /// Occurs when a page drag is about to begin and allows it to be cancelled. /// </summary> /// <param name="sender">Source of the page drag; should never be null.</param> /// <param name="navigator">Navigator instance associated with source; can be null.</param> /// <param name="e">Event arguments indicating list of pages being dragged.</param> public void PageDragStart(object sender, KryptonNavigator navigator, PageDragCancelEventArgs e) { _workspace.InternalPageDragStart(sender, navigator, e); }