/// <summary> /// Propagates a request for drag targets down the hierarchy of docking elements. /// </summary> /// <param name="floatingWindow">Reference to window being dragged.</param> /// <param name="dragData">Set of pages being dragged.</param> /// <param name="targets">Collection of drag targets.</param> public override void PropogateDragTargets(KryptonFloatingWindow floatingWindow, PageDragEndData dragData, DragTargetList targets) { // Create list of the pages that are allowed to be dropped into this navigator KryptonPageCollection pages = new(); foreach (KryptonPage page in dragData.Pages.Where(static page => page.AreFlagsSet(KryptonPageFlags.DockingAllowNavigator)))
/// <summary> /// Initialize a new instance of the DragManager class. /// </summary> public DragManager() { _redirector = new PaletteRedirect(); StateCommon = new PaletteDragDrop(null, null); _paletteMode = PaletteMode.Global; DragTargetProviders = new DragTargetProviderCollection(); _dragTargets = new DragTargetList(); _documentCursor = false; }
/// <summary> /// Add a list of drag targets from the provided interface. /// </summary> /// <param name="provider">Interface reference.</param> /// <param name="dragEndData">Pages data being dragged.</param> public void AddRange(IDragTargetProvider provider, PageDragEndData dragEndData) { DragTargetList targets = provider?.GenerateDragTargets(dragEndData); if ((targets != null) && (targets.Count > 0)) { AddRange(targets); } }
/// <summary> /// Generate a list of drag targets that are relevant to the provided end data. /// </summary> /// <param name="dragEndData">Pages data being dragged.</param> /// <returns>List of drag targets.</returns> public DragTargetList GenerateDragTargets(PageDragEndData dragEndData) { DragTargetList targets = new DragTargetList(); // Generate target for the entire navigator client area targets.Add(new DragTargetTreeViewTransfer(RectangleToScreen(ClientRectangle), this)); return(targets); }
/// <summary> /// Propogates a request for drag targets down the hierarchy of docking elements. /// </summary> /// <param name="floatingWindow">Reference to window being dragged.</param> /// <param name="dragData">Set of pages being dragged.</param> /// <param name="targets">Collection of drag targets.</param> public virtual void PropogateDragTargets(KryptonFloatingWindow floatingWindow, PageDragEndData dragData, DragTargetList targets) { // Propogate the request to all child elements foreach (IDockingElement child in this) { child.PropogateDragTargets(floatingWindow, dragData, targets); } }
/// <summary> /// Propogates a request for drag targets down the hierarchy of docking elements. /// </summary> /// <param name="floatingWindow">Reference to window being dragged.</param> /// <param name="dragData">Set of pages being dragged.</param> /// <param name="targets">Collection of drag targets.</param> public override void PropogateDragTargets(KryptonFloatingWindow floatingWindow, PageDragEndData dragData, DragTargetList targets) { // Can only generate targets for a floating window that is actually visible and not the one being dragged if (FloatingWindow.Visible && (floatingWindow != FloatingWindow)) { base.PropogateDragTargets(floatingWindow, dragData, targets); } }
/// <summary> /// Generate a list of drag targets that are relevant to the provided end data. /// </summary> /// <param name="dragEndData">Pages data being dragged.</param> /// <returns>List of drag targets.</returns> public DragTargetList GenerateDragTargets(PageDragEndData dragEndData) { DragTargetList targets = new DragTargetList(); // Generate the set of targets from the element hierarchy _manager.PropogateDragTargets(_floatingWindow, dragEndData, targets); // Must have at least one target if (targets.Count == 0) targets.Add(new DragTargetNull()); return targets; }
/// <summary> /// Generate a list of drag targets that are relevant to the provided end data. /// </summary> /// <param name="dragEndData">Pages data being dragged.</param> /// <returns>List of drag targets.</returns> public DragTargetList GenerateDragTargets(PageDragEndData dragEndData) { DragTargetList targets = new DragTargetList(); // Generate the set of targets from the element hierarchy _manager.PropogateDragTargets(_floatingWindow, dragEndData, targets); // Must have at least one target if (targets.Count == 0) { targets.Add(new DragTargetNull()); } return(targets); }
/// <summary> /// Called to initialize the implementation when dragging starts. /// </summary> /// <param name="paletteDragDrop">Drawing palette.</param> /// <param name="renderer">Drawing renderer.</param> /// <param name="pageDragEndData">Drag data associated with drag operation.</param> /// <param name="dragTargets">List of all drag targets.</param> public virtual void Start(IPaletteDragDrop paletteDragDrop, IRenderer renderer, PageDragEndData pageDragEndData, DragTargetList dragTargets) { Debug.Assert(paletteDragDrop != null); Debug.Assert(renderer != null); Debug.Assert(pageDragEndData != null); Debug.Assert(dragTargets != null); PaletteDragDrop = paletteDragDrop; Renderer = renderer; PageDragEndData = pageDragEndData; DragTargets = dragTargets; }
/// <summary> /// Called to initialize the implementation when dragging starts. /// </summary> /// <param name="paletteDragDrop">Drawing palette.</param> /// <param name="renderer">Drawing renderer.</param> /// <param name="pageDragEndData">Drag data associated with drag operation.</param> /// <param name="dragTargets">List of all drag targets.</param> public override void Start(IPaletteDragDrop paletteDragDrop, IRenderer renderer, PageDragEndData pageDragEndData, DragTargetList dragTargets) { base.Start(paletteDragDrop, renderer, pageDragEndData, dragTargets); if (_solid == null) { // Create and show a window without it taking focus _solid = new DropSolidWindow(PaletteDragDrop, Renderer); _solid.SetBounds(0, 0, 1, 1, BoundsSpecified.All); _solid.ShowWithoutActivate(); _solid.Refresh(); } }
/// <summary> /// Propagates a request for drag targets down the hierarchy of docking elements. /// </summary> /// <param name="floatingWindow">Reference to window being dragged.</param> /// <param name="dragData">Set of pages being dragged.</param> /// <param name="targets">Collection of drag targets.</param> public override void PropogateDragTargets(KryptonFloatingWindow floatingWindow, PageDragEndData dragData, DragTargetList targets) { // Create list of the pages that are allowed to be dropped into this workspace KryptonPageCollection pages = new KryptonPageCollection(); foreach (KryptonPage page in dragData.Pages) { if (page.AreFlagsSet(KryptonPageFlags.DockingAllowWorkspace)) { pages.Add(page); } } // Do we have any pages left for dragging? if (pages.Count > 0) { DragTargetList workspaceTargets = DockableWorkspaceControl.GenerateDragTargets(new PageDragEndData(this, pages), KryptonPageFlags.DockingAllowWorkspace); targets.AddRange(workspaceTargets.ToArray()); } }
/// <summary> /// Release unmanaged and optionally managed resources. /// </summary> /// <param name="disposing">Called from Dispose method.</param> protected virtual void Dispose(bool disposing) { // If called from explicit call to Dispose if (disposing) { // No need to call destructor once dispose has occured GC.SuppressFinalize(this); _pageDragEndData = null; _dragTargets = null; } // Mark as disposed _disposed = true; }
/// <summary> /// Generate a list of drag targets that are relevant to the provided end data. /// </summary> /// <param name="dragEndData">Pages data being dragged.</param> /// <param name="allowFlags">Only drop pages that have one of these flags set.</param> /// <returns>List of drag targets.</returns> public virtual DragTargetList GenerateDragTargets(PageDragEndData dragEndData, KryptonPageFlags allowFlags) { DragTargetList targets = new DragTargetList(); // Generate target for the entire navigator client area targets.Add(new DragTargetNavigatorTransfer(RectangleToScreen(ClientRectangle), this, allowFlags)); return targets; }
/// <summary> /// Propogates a request for drag targets down the hierarchy of docking elements. /// </summary> /// <param name="floatingWindow">Reference to window being dragged.</param> /// <param name="dragData">Set of pages being dragged.</param> /// <param name="targets">Collection of drag targets.</param> public override void PropogateDragTargets(KryptonFloatingWindow floatingWindow, PageDragEndData dragData, DragTargetList targets) { // Create a list of pages that are allowed to be transferred into a dockspace List <KryptonPage> transferPages = new List <KryptonPage>(); foreach (KryptonPage page in dragData.Pages) { if (page.AreFlagsSet(KryptonPageFlags.DockingAllowDocked)) { transferPages.Add(page); } } // Only generate targets if we have some valid pages to transfer if (transferPages.Count > 0) { // Generate targets for the four control edges Rectangle screenRect = Control.RectangleToScreen(Control.ClientRectangle); Rectangle[] rectsDraw = SubdivideRectangle(screenRect, 3, int.MaxValue); Rectangle[] rectsHot = SubdivideRectangle(screenRect, 10, 20); // Must insert at start of target list as they are higher priority than cell targets targets.Add(new DragTargetControlEdge(screenRect, rectsHot[0], rectsDraw[0], DragTargetHint.EdgeLeft | DragTargetHint.ExcludeCluster, this, KryptonPageFlags.DockingAllowDocked, true)); targets.Add(new DragTargetControlEdge(screenRect, rectsHot[1], rectsDraw[1], DragTargetHint.EdgeRight | DragTargetHint.ExcludeCluster, this, KryptonPageFlags.DockingAllowDocked, true)); targets.Add(new DragTargetControlEdge(screenRect, rectsHot[2], rectsDraw[2], DragTargetHint.EdgeTop | DragTargetHint.ExcludeCluster, this, KryptonPageFlags.DockingAllowDocked, true)); targets.Add(new DragTargetControlEdge(screenRect, rectsHot[3], rectsDraw[3], DragTargetHint.EdgeBottom | DragTargetHint.ExcludeCluster, this, KryptonPageFlags.DockingAllowDocked, true)); // If we have no designated inner element when we have to decide if we can place edge drag drop targets based on the // available space at the center of the control after taking into account any edge docked controls already in place. if (_innerElement == null) { // Find the inner rectangle after taking docked controls into account Size tl = Size.Empty; Size br = Control.ClientSize; foreach (Control c in Control.Controls) { if (c.Visible) { switch (c.Dock) { case DockStyle.Left: tl.Width = Math.Max(tl.Width, c.Right); break; case DockStyle.Right: br.Width = Math.Min(br.Width, c.Left); break; case DockStyle.Top: tl.Height = Math.Max(tl.Height, c.Bottom); break; case DockStyle.Bottom: br.Height = Math.Min(br.Height, c.Top); break; } } } // If there is inner space available Rectangle innerRect = new Rectangle(tl.Width, tl.Height, br.Width - tl.Width, br.Height - tl.Height); if ((innerRect.Width > 0) && (innerRect.Height > 0)) { Rectangle innerScreenRect = Control.RectangleToScreen(innerRect); Rectangle[] innerRectsDraw = SubdivideRectangle(innerScreenRect, 3, int.MaxValue); Rectangle[] innerRectsHot = SubdivideRectangle(innerScreenRect, 10, 20); targets.Add(new DragTargetControlEdge(innerScreenRect, innerRectsHot[0], innerRectsDraw[0], DragTargetHint.EdgeLeft, this, KryptonPageFlags.DockingAllowDocked, false)); targets.Add(new DragTargetControlEdge(innerScreenRect, innerRectsHot[1], innerRectsDraw[1], DragTargetHint.EdgeRight, this, KryptonPageFlags.DockingAllowDocked, false)); targets.Add(new DragTargetControlEdge(innerScreenRect, innerRectsHot[2], innerRectsDraw[2], DragTargetHint.EdgeTop, this, KryptonPageFlags.DockingAllowDocked, false)); targets.Add(new DragTargetControlEdge(innerScreenRect, innerRectsHot[3], innerRectsDraw[3], DragTargetHint.EdgeBottom, this, KryptonPageFlags.DockingAllowDocked, false)); } } else if (_innerElement is KryptonDockingNavigator) { KryptonDockingNavigator dockingNavigator = (KryptonDockingNavigator)_innerElement; // If there is inner space available Rectangle innerScreenRect = dockingNavigator.DockableNavigatorControl.RectangleToScreen(dockingNavigator.DockableNavigatorControl.ClientRectangle); if ((innerScreenRect.Width > 0) && (innerScreenRect.Height > 0)) { Rectangle[] innerRectsDraw = SubdivideRectangle(innerScreenRect, 3, int.MaxValue); Rectangle[] innerRectsHot = SubdivideRectangle(innerScreenRect, 10, 20); targets.Add(new DragTargetControlEdge(innerScreenRect, innerRectsHot[0], innerRectsDraw[0], DragTargetHint.EdgeLeft, this, KryptonPageFlags.DockingAllowDocked, false)); targets.Add(new DragTargetControlEdge(innerScreenRect, innerRectsHot[1], innerRectsDraw[1], DragTargetHint.EdgeRight, this, KryptonPageFlags.DockingAllowDocked, false)); targets.Add(new DragTargetControlEdge(innerScreenRect, innerRectsHot[2], innerRectsDraw[2], DragTargetHint.EdgeTop, this, KryptonPageFlags.DockingAllowDocked, false)); targets.Add(new DragTargetControlEdge(innerScreenRect, innerRectsHot[3], innerRectsDraw[3], DragTargetHint.EdgeBottom, this, KryptonPageFlags.DockingAllowDocked, false)); } } // Let base class generate targets for contained elements base.PropogateDragTargets(floatingWindow, dragData, targets); } }
/// <summary> /// Propogates a request for drag targets down the hierarchy of docking elements. /// </summary> /// <param name="floatingWindow">Reference to window being dragged.</param> /// <param name="dragData">Set of pages being dragged.</param> /// <param name="targets">Collection of drag targets.</param> public override void PropogateDragTargets(KryptonFloatingWindow floatingWindow, PageDragEndData dragData, DragTargetList targets) { if (DockspaceControl.CellVisibleCount > 0) { // Create list of the pages that are allowed to be dropped into this dockspace KryptonPageCollection pages = new KryptonPageCollection(); foreach (KryptonPage page in dragData.Pages) if (page.AreFlagsSet(KryptonPageFlags.DockingAllowDocked)) pages.Add(page); // Do we have any pages left for dragging? if (pages.Count > 0) { DragTargetList dockspaceTargets = DockspaceControl.GenerateDragTargets(new PageDragEndData(this, pages), KryptonPageFlags.DockingAllowDocked); targets.AddRange(dockspaceTargets.ToArray()); } } }
/// <summary> /// Propogates a request for drag targets down the hierarchy of docking elements. /// </summary> /// <param name="floatingWindow">Reference to window being dragged.</param> /// <param name="dragData">Set of pages being dragged.</param> /// <param name="targets">Collection of drag targets.</param> public override void PropogateDragTargets(KryptonFloatingWindow floatingWindow, PageDragEndData dragData, DragTargetList targets) { // Can only generate targets for a floating window that is actually visible and not the one being dragged if (FloatingWindow.Visible && (floatingWindow != FloatingWindow)) base.PropogateDragTargets(floatingWindow, dragData, targets); }
/// <summary> /// Called to cleanup when dragging has finished. /// </summary> public virtual void Quit() { _pageDragEndData = null; _dragTargets = null; }
/// <summary> /// Propogates a request for drag targets down the hierarchy of docking elements. /// </summary> /// <param name="floatingWindow">Reference to window being dragged.</param> /// <param name="dragData">Set of pages being dragged.</param> /// <param name="targets">Collection of drag targets.</param> public virtual void PropogateDragTargets(KryptonFloatingWindow floatingWindow, PageDragEndData dragData, DragTargetList targets) { // Propogate the request to all child elements foreach (IDockingElement child in this) child.PropogateDragTargets(floatingWindow, dragData, targets); }
/// <summary> /// Called to initialize the implementation when dragging starts. /// </summary> /// <param name="paletteDragDrop">Drawing palette.</param> /// <param name="renderer">Drawing renderer.</param> /// <param name="pageDragEndData">Drag data associated with drag operation.</param> /// <param name="dragTargets">List of all drag targets.</param> public virtual void Start(IPaletteDragDrop paletteDragDrop, IRenderer renderer, PageDragEndData pageDragEndData, DragTargetList dragTargets) { Debug.Assert(paletteDragDrop != null); Debug.Assert(renderer != null); Debug.Assert(pageDragEndData != null); Debug.Assert(dragTargets != null); _paletteDragDrop = paletteDragDrop; _renderer = renderer; _pageDragEndData = pageDragEndData; _dragTargets = dragTargets; }
/// <summary> /// Generate a list of drag targets that are relevant to the provided end data. /// </summary> /// <param name="dragEndData">Pages data being dragged.</param> /// <returns>List of drag targets.</returns> public DragTargetList GenerateDragTargets(PageDragEndData dragEndData) { DragTargetList targets = new DragTargetList(); // Generate target for the entire navigator client area targets.Add(new DragTargetTreeViewTransfer(RectangleToScreen(ClientRectangle), this)); return targets; }
/// <summary> /// Propogates a request for drag targets down the hierarchy of docking elements. /// </summary> /// <param name="floatingWindow">Reference to window being dragged.</param> /// <param name="dragData">Set of pages being dragged.</param> /// <param name="targets">Collection of drag targets.</param> public override void PropogateDragTargets(KryptonFloatingWindow floatingWindow, PageDragEndData dragData, DragTargetList targets) { // Create a list of pages that are allowed to be transferred into a dockspace List<KryptonPage> transferPages = new List<KryptonPage>(); foreach (KryptonPage page in dragData.Pages) if (page.AreFlagsSet(KryptonPageFlags.DockingAllowDocked)) transferPages.Add(page); // Only generate targets if we have some valid pages to transfer if (transferPages.Count > 0) { // Generate targets for the four control edges Rectangle screenRect = Control.RectangleToScreen(Control.ClientRectangle); Rectangle[] rectsDraw = SubdivideRectangle(screenRect, 3, int.MaxValue); Rectangle[] rectsHot = SubdivideRectangle(screenRect, 10, 20); // Must insert at start of target list as they are higher priority than cell targets targets.Add(new DragTargetControlEdge(screenRect, rectsHot[0], rectsDraw[0], DragTargetHint.EdgeLeft | DragTargetHint.ExcludeCluster, this, KryptonPageFlags.DockingAllowDocked, true)); targets.Add(new DragTargetControlEdge(screenRect, rectsHot[1], rectsDraw[1], DragTargetHint.EdgeRight | DragTargetHint.ExcludeCluster, this, KryptonPageFlags.DockingAllowDocked, true)); targets.Add(new DragTargetControlEdge(screenRect, rectsHot[2], rectsDraw[2], DragTargetHint.EdgeTop | DragTargetHint.ExcludeCluster, this, KryptonPageFlags.DockingAllowDocked, true)); targets.Add(new DragTargetControlEdge(screenRect, rectsHot[3], rectsDraw[3], DragTargetHint.EdgeBottom | DragTargetHint.ExcludeCluster, this, KryptonPageFlags.DockingAllowDocked, true)); // If we have no designated inner element when we have to decide if we can place edge drag drop targets based on the // available space at the center of the control after taking into account any edge docked controls already in place. if (_innerElement == null) { // Find the inner rectangle after taking docked controls into account Size tl = Size.Empty; Size br = Control.ClientSize; foreach (Control c in Control.Controls) if (c.Visible) { switch (c.Dock) { case DockStyle.Left: tl.Width = Math.Max(tl.Width, c.Right); break; case DockStyle.Right: br.Width = Math.Min(br.Width, c.Left); break; case DockStyle.Top: tl.Height = Math.Max(tl.Height, c.Bottom); break; case DockStyle.Bottom: br.Height = Math.Min(br.Height, c.Top); break; } } // If there is inner space available Rectangle innerRect = new Rectangle(tl.Width, tl.Height, br.Width - tl.Width, br.Height - tl.Height); if ((innerRect.Width > 0) && (innerRect.Height > 0)) { Rectangle innerScreenRect = Control.RectangleToScreen(innerRect); Rectangle[] innerRectsDraw = SubdivideRectangle(innerScreenRect, 3, int.MaxValue); Rectangle[] innerRectsHot = SubdivideRectangle(innerScreenRect, 10, 20); targets.Add(new DragTargetControlEdge(innerScreenRect, innerRectsHot[0], innerRectsDraw[0], DragTargetHint.EdgeLeft, this, KryptonPageFlags.DockingAllowDocked, false)); targets.Add(new DragTargetControlEdge(innerScreenRect, innerRectsHot[1], innerRectsDraw[1], DragTargetHint.EdgeRight, this, KryptonPageFlags.DockingAllowDocked, false)); targets.Add(new DragTargetControlEdge(innerScreenRect, innerRectsHot[2], innerRectsDraw[2], DragTargetHint.EdgeTop, this, KryptonPageFlags.DockingAllowDocked, false)); targets.Add(new DragTargetControlEdge(innerScreenRect, innerRectsHot[3], innerRectsDraw[3], DragTargetHint.EdgeBottom, this, KryptonPageFlags.DockingAllowDocked, false)); } } else if (_innerElement is KryptonDockingNavigator) { KryptonDockingNavigator dockingNavigator = (KryptonDockingNavigator)_innerElement; // If there is inner space available Rectangle innerScreenRect = dockingNavigator.DockableNavigatorControl.RectangleToScreen(dockingNavigator.DockableNavigatorControl.ClientRectangle); if ((innerScreenRect.Width > 0) && (innerScreenRect.Height > 0)) { Rectangle[] innerRectsDraw = SubdivideRectangle(innerScreenRect, 3, int.MaxValue); Rectangle[] innerRectsHot = SubdivideRectangle(innerScreenRect, 10, 20); targets.Add(new DragTargetControlEdge(innerScreenRect, innerRectsHot[0], innerRectsDraw[0], DragTargetHint.EdgeLeft, this, KryptonPageFlags.DockingAllowDocked, false)); targets.Add(new DragTargetControlEdge(innerScreenRect, innerRectsHot[1], innerRectsDraw[1], DragTargetHint.EdgeRight, this, KryptonPageFlags.DockingAllowDocked, false)); targets.Add(new DragTargetControlEdge(innerScreenRect, innerRectsHot[2], innerRectsDraw[2], DragTargetHint.EdgeTop, this, KryptonPageFlags.DockingAllowDocked, false)); targets.Add(new DragTargetControlEdge(innerScreenRect, innerRectsHot[3], innerRectsDraw[3], DragTargetHint.EdgeBottom, this, KryptonPageFlags.DockingAllowDocked, false)); } } // Let base class generate targets for contained elements base.PropogateDragTargets(floatingWindow, dragData, targets); } }