示例#1
0
        /// <summary>
        /// Add set of pages docked against a specified edge of the specified control.
        /// </summary>
        /// <param name="path">Path for finding the target KryptonDockingControl.</param>
        /// <param name="edge">Target edge within the KryptonDockingControl.</param>
        /// <param name="pages">Array of pages to be added as docked.</param>
        /// <param name="stackPages">Extra arrays of pages to be added in a stacked manner.</param>
        /// <returns>KryptonDockingDockspace reference.</returns>
        public virtual KryptonDockingDockspace AddDockspace(string path, 
            DockingEdge edge,
            KryptonPage[] pages,
            params KryptonPage[][] stackPages)
        {
            // Cannot add a null array
            if (pages == null)
                throw new ArgumentNullException("pages");

            // Array must contain some values
            if (pages.Length == 0)
                throw new ArgumentException("pages cannot be zero length");

            // Cannot action a null page reference
            foreach (KryptonPage page in pages)
                if (page == null)
                    throw new ArgumentNullException("pages array contains a null page reference");

            // Resolve the given path to the expected docking control element
            KryptonDockingControl control = ResolvePath(path) as KryptonDockingControl;
            if (control == null)
                throw new ArgumentException("Path does not resolve to a KryptonDockingControl");

            // Find the requested target edge
            KryptonDockingEdge edgeElement = control[edge.ToString()] as KryptonDockingEdge;
            if (edgeElement == null)
                throw new ArgumentException("KryptonDockingControl does not have the requested edge.");

            // Find the docked edge
            KryptonDockingEdgeDocked edgeDocked = edgeElement["Docked"] as KryptonDockingEdgeDocked;
            if (edgeDocked == null)
                throw new ArgumentException("KryptonDockingControl edge does not have a docked element.");

            KryptonDockingDockspace dockspace = null;
            using (DockingMultiUpdate update = new DockingMultiUpdate(this))
            {
                // Create a new dockspace and add the provided array of pages
                dockspace = edgeDocked.AppendDockspace();
                dockspace.Append(pages);

                // If we have extra pages then we need to add a stack of tabbed cells
                if ((stackPages != null) && (stackPages.Length > 0))
                {
                    // For each array of pages...
                    foreach (KryptonPage[] pageArray in stackPages)
                        if ((pageArray != null) && (pageArray.Length > 0))
                        {
                            // We need a new cell with all the pages from the array
                            KryptonWorkspaceCell cell = new KryptonWorkspaceCell();
                            cell.Pages.AddRange(pageArray);

                            // Add into the root collection so the cells appear in a stack
                            dockspace.DockspaceControl.Root.Children.Add(cell);
                        }

                    // Set the correct direction for the stacking of cells at the root
                    switch (edge)
                    {
                        case DockingEdge.Left:
                        case DockingEdge.Right:
                            dockspace.DockspaceControl.Root.Orientation = Orientation.Vertical;
                            break;
                        case DockingEdge.Top:
                        case DockingEdge.Bottom:
                            dockspace.DockspaceControl.Root.Orientation = Orientation.Horizontal;
                            break;
                    }
                }
            }

            return dockspace;
        }
示例#2
0
        /// <summary>
        /// Add set of pages as a new auto hidden group to the specified edge of the specified control.
        /// </summary>
        /// <param name="path">Path for finding the target KryptonDockingControl.</param>
        /// <param name="edge">Target edge within the KryptonDockingControl.</param>
        /// <param name="pages">Array of pages to be added as an auto hidden group.</param>
        /// <param name="extraPages">Extra arrays of pages to be added as extra groups.</param>
        /// <returns>KryptonDockingAutoHiddenGroup reference.</returns>
        public virtual KryptonDockingAutoHiddenGroup AddAutoHiddenGroup(string path, 
            DockingEdge edge,
            KryptonPage[] pages,
            params KryptonPage[][] extraPages)
        {
            // Cannot add a null array
            if (pages == null)
                throw new ArgumentNullException("pages");

            // Array must contain some values
            if (pages.Length == 0)
                throw new ArgumentException("pages cannot be zero length");

            // Cannot action a null page reference
            foreach (KryptonPage page in pages)
                if (page == null)
                    throw new ArgumentNullException("pages array contains a null page reference");

            // Resolve the given path to the expected docking control element
            KryptonDockingControl control = ResolvePath(path) as KryptonDockingControl;
            if (control == null)
                throw new ArgumentException("Path does not resolve to a KryptonDockingControl");

            // Find the requested target edge
            KryptonDockingEdge edgeElement = control[edge.ToString()] as KryptonDockingEdge;
            if (edgeElement == null)
                throw new ArgumentException("KryptonDockingControl does not have the requested edge.");

            // Find the auto hidden edge
            KryptonDockingEdgeAutoHidden edgeAutoHidden = edgeElement["AutoHidden"] as KryptonDockingEdgeAutoHidden;
            if (edgeAutoHidden == null)
                throw new ArgumentException("KryptonDockingControl edge does not have an auto hidden element.");

            KryptonDockingAutoHiddenGroup autoHiddenGroup = null;
            using (DockingMultiUpdate update = new DockingMultiUpdate(this))
            {
                // Create a new auto hidden group and add the provided array of pages
                autoHiddenGroup = edgeAutoHidden.AppendAutoHiddenGroup();
                autoHiddenGroup.Append(pages);

                // If we have extra pages then we need to add extra auto hidden groups
                if ((extraPages != null) && (extraPages.Length > 0))
                {
                    // For each array of pages...
                    foreach (KryptonPage[] pageArray in extraPages)
                        if ((pageArray != null) && (pageArray.Length > 0))
                        {
                            // Create a new auto hidden group and add the provided array of pages
                            KryptonDockingAutoHiddenGroup extraAutoHiddenGroup = edgeAutoHidden.AppendAutoHiddenGroup();
                            extraAutoHiddenGroup.Append(pageArray);
                        }
                }
            }

            return autoHiddenGroup;
        }