/// <summary>
        /// Initialize a new instance of the KryptonDockingControl class.
        /// </summary>
        /// <param name="name">Initial name of the element.</param>
        /// <param name="control">Reference to control derived instance.</param>
        /// <param name="navigator">Inner space occupied by a KryptonDockingNavigator.</param>
        public KryptonDockingControl(string name, Control control, KryptonDockingNavigator navigator)
            : base(name)
        {
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }

            if (navigator == null)
            {
                throw new ArgumentNullException("navigator");
            }

            Construct(control, navigator);
        }
Beispiel #2
0
        /// <summary>
        /// Find a navigator element by searching the hierarchy.
        /// </summary>
        /// <param name="uniqueName">Named page for which a suitable navigator element is required.</param>
        /// <returns>KryptonDockingNavigator reference if found; otherwise false.</returns>
        public virtual KryptonDockingNavigator FindDockingNavigator(string uniqueName)
        {
            // Default to not finding the element
            KryptonDockingNavigator navigatorElement = null;

            // Search all child docking elements
            for (int i = 0; i < Count; i++)
            {
                navigatorElement = this[i].FindDockingNavigator(uniqueName);
                if (navigatorElement != null)
                {
                    break;
                }
            }

            return(navigatorElement);
        }
 /// <summary>
 /// Initialize a new instance of the DockableNavigatorEventArgs class.
 /// </summary>
 /// <param name="navigator">Reference to dockable navigator control instance.</param>
 /// <param name="element">Reference to docking navigator element that is managing the dockable workspace control.</param>
 public DockableNavigatorEventArgs(KryptonDockableNavigator navigator,
                                   KryptonDockingNavigator element)
 {
     DockableNavigatorControl = navigator;
     DockingNavigatorElement  = element;
 }
Beispiel #4
0
        /// <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);
            }
        }
Beispiel #5
0
 /// <summary>
 /// Initialize a new instance of the DockableNavigatorEventArgs class.
 /// </summary>
 /// <param name="navigator">Reference to dockable navigator control instance.</param>
 /// <param name="element">Reference to docking navigator element that is managing the dockable workspace control.</param>
 public DockableNavigatorEventArgs(KryptonDockableNavigator navigator,
                                   KryptonDockingNavigator element)
 {
     _navigator = navigator;
     _element   = element;
 }