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

SwitchFloatingToFloatingWindowRequest() public method

Perform a switch from floating to new floating window for the named pages.
public SwitchFloatingToFloatingWindowRequest ( string uniqueNames ) : KryptonDockingFloatingWindow
uniqueNames string Unique name of floating pages that need switching.
return KryptonDockingFloatingWindow
        public virtual KryptonDockingFloatingWindow SwitchFloatingToFloatingWindowRequest(string[] uniqueNames)
        {
            // Cannot action a null reference
            if (uniqueNames == null)
                throw new ArgumentNullException("uniqueNames");

            // Cannot action an empty array
            if (uniqueNames.Length == 0)
                throw new ArgumentOutOfRangeException("uniqueNames", "array cannot be empry");

            // Cannot action a null or zero length unique name
            foreach (string uniqueName in uniqueNames)
            {
                if (uniqueName == null)
                    throw new ArgumentNullException("uniqueNames array contains a null string reference");

                if (uniqueName.Length == 0)
                    throw new ArgumentException("uniqueNames array contains a zero length string");
            }

            // Use events to determine which pages should be switched
            List<string> switchUniqueNames = new List<string>();
            List<KryptonPage> switchPages = new List<KryptonPage>();
            string selectedPage = null;
            foreach (string uniqueName in uniqueNames)
            {
                // Does the provided unique name exist and is in the required 'floating' state
                if (FindPageLocation(uniqueName) == DockingLocation.Floating)
                {
                    KryptonPage page = PageForUniqueName(uniqueName);
                    if (page != null)
                    {
                        switchUniqueNames.Add(uniqueName);
                        switchPages.Add(page);

                        // Navigate to the cell that holds the page
                        KryptonDockingFloatspace floatspace = FindPageElement(page) as KryptonDockingFloatspace;
                        if (floatspace != null)
                        {
                            KryptonWorkspaceCell cell = floatspace.CellForPage(uniqueName);
                            if (cell != null)
                            {
                                // Remember the page that is active
                                if (cell.SelectedPage == page)
                                    selectedPage = page.UniqueName;
                            }
                        }
                    }
                }
            }

            // Still any pages to be switched?
            if (switchUniqueNames.Count > 0)
            {
                // Find a floating element that is the target for the switching
                KryptonDockingFloating floating = FindDockingFloating(selectedPage != null ? selectedPage : switchUniqueNames[0]);
                if (floating != null)
                {
                    using (DockingMultiUpdate update = new DockingMultiUpdate(this))
                    {
                        // Grab the current element that contains one of the pages being moved
                        KryptonDockingFloatspace currentElement = FindPageElement(switchPages[0]) as KryptonDockingFloatspace;

                        // Remove the pages from the existing floating window
                        PropogateAction(DockingPropogateAction.RemovePages, switchUniqueNames.ToArray());

                        // Create a new floating window and add the specified set of pages
                        KryptonDockingFloatingWindow floatingElement = floating.AddFloatingWindow();
                        floatingElement.FloatspaceElement.Append(switchPages.ToArray());

                        // Make sure any seleted page is selected in the new floating window
                        if (selectedPage != null)
                            floatingElement.SelectPage(selectedPage);

                        // Position the new floating window close to the existing one
                        floatingElement.FloatingWindow.Location = currentElement.FloatspaceControl.PointToScreen(Point.Empty);
                        floatingElement.FloatingWindow.Show();

                        return floatingElement;
                    }
                }
            }

            return null;
        }
KryptonDockingManager