ComponentFactory.Krypton.Docking.KryptonDockingControl.PropogateDragTargets C# (CSharp) Method

PropogateDragTargets() public method

Propogates a request for drag targets down the hierarchy of docking elements.
public PropogateDragTargets ( KryptonFloatingWindow floatingWindow, PageDragEndData dragData, DragTargetList targets ) : void
floatingWindow KryptonFloatingWindow Reference to window being dragged.
dragData ComponentFactory.Krypton.Navigator.PageDragEndData Set of pages being dragged.
targets DragTargetList Collection of drag targets.
return void
        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);
            }
        }