ComponentFactory.Krypton.Docking.KryptonDockingManager.SwitchDockedCellToAutoHiddenGroupRequest C# (CSharp) Method

SwitchDockedCellToAutoHiddenGroupRequest() public method

Perform a switch from docked cell to auto hidden group for the visible pages inside the cell.
public SwitchDockedCellToAutoHiddenGroupRequest ( string uniqueName ) : KryptonDockingAutoHiddenGroup
uniqueName string Unique name of page inside docked cell that needs switching.
return KryptonDockingAutoHiddenGroup
        public virtual KryptonDockingAutoHiddenGroup SwitchDockedCellToAutoHiddenGroupRequest(string uniqueName)
        {
            // Cannot switch a null reference
            if (uniqueName == null)
                throw new ArgumentNullException("uniqueName");

            // Unique names cannot be zero length
            if (uniqueName.Length == 0)
                throw new ArgumentException("uniqueName cannot be zero length");

            // Does the provided unique name exist and is in the required 'docked' state
            if (FindPageLocation(uniqueName) == DockingLocation.Docked)
            {
                // Grab the dockspace element that we expect to contain the target unique name
                KryptonDockingDockspace dockspace = (KryptonDockingDockspace)ExpectPageElement(uniqueName, typeof(KryptonDockingDockspace));
                if (dockspace != null)
                {
                    // Does the dockspace currently have the focus?
                    bool hadFocus = dockspace.DockspaceControl.ContainsFocus;

                    // Find the sibling auto hidden edge so we can add a new auto hidden group to it later on
                    KryptonDockingEdgeAutoHidden edgeAutoHidden = dockspace.EdgeAutoHiddenElement;
                    if (edgeAutoHidden != null)
                    {
                        // Grab the set of visible pages in the same cell as the target unique name
                        KryptonPage[] visiblePages = dockspace.CellVisiblePages(uniqueName);
                        if (visiblePages.Length > 0)
                        {
                            // Use events to determine which pages in the cell should be switched
                            List<string> switchUniqueNames = new List<string>();
                            List<KryptonPage> switchPages = new List<KryptonPage>();
                            foreach (KryptonPage page in visiblePages)
                            {
                                CancelUniqueNameEventArgs args = new CancelUniqueNameEventArgs(page.UniqueName, !page.AreFlagsSet(KryptonPageFlags.DockingAllowAutoHidden));
                                OnPageAutoHiddenRequest(args);

                                if (!args.Cancel)
                                {
                                    switchUniqueNames.Add(page.UniqueName);
                                    switchPages.Add(page);
                                }
                            }

                            // Any pages that actually need to be switched?
                            if (switchPages.Count > 0)
                            {
                                using (DockingMultiUpdate update = new DockingMultiUpdate(this))
                                {
                                    // Convert the pages to placeholders so they can be returned to the same location
                                    string[] uniqueNames = switchUniqueNames.ToArray();
                                    dockspace.PropogateAction(DockingPropogateAction.StorePages, uniqueNames);

                                    // Create a new auto hidden group and add the switch pages into it
                                    KryptonDockingAutoHiddenGroup group = edgeAutoHidden.AppendAutoHiddenGroup();
                                    group.Append(switchPages.ToArray());

                                    // If we had the focus at the start of the process and the dockspace no longer has it...
                                    if (hadFocus && !dockspace.DockspaceControl.ContainsFocus)
                                    {
                                        // ...and focus has not moved to another part of the form...
                                        Form topForm = dockspace.DockspaceControl.FindForm();
                                        if ((topForm != null) && !topForm.ContainsFocus)
                                        {
                                            // ...then shift focus to the auto hidden group placeholder, to ensure the form still has the
                                            // focus and so hovering the mouse over the auto hidden tabs will correctly get them to slide out
                                            KryptonDockingEdgeAutoHidden edge = group.GetParentType(typeof(KryptonDockingEdgeAutoHidden)) as KryptonDockingEdgeAutoHidden;
                                            if (edge != null)
                                                topForm.Focus();
                                        }
                                    }

                                    return group;
                                }
                            }
                        }
                    }
                }
            }

            return null;
        }
KryptonDockingManager