Beispiel #1
0
        /// <summary>
        /// Propogates an action request down the hierarchy of docking elements.
        /// </summary>
        /// <param name="action">Action that is requested to be performed.</param>
        /// <param name="pages">Array of pages the action relates to.</param>
        public override void PropogateAction(DockingPropogateAction action, KryptonPage[] pages)
        {
            switch (action)
            {
            case DockingPropogateAction.RestorePages:
                foreach (KryptonPage page in pages)
                {
                    // Swap pages that are placeholders for the actual pages
                    KryptonPage storePage = SpaceControl.PageForUniqueName(page.UniqueName);
                    if (storePage is KryptonStorePage)
                    {
                        KryptonWorkspaceCell cell = SpaceControl.CellForPage(storePage);
                        cell.Pages.Insert(cell.Pages.IndexOf(storePage), page);
                    }
                }
                break;
            }

            // Let base class perform standard processing
            base.PropogateAction(action, pages);
        }
Beispiel #2
0
        /// <summary>
        /// Propogates an action request down the hierarchy of docking elements.
        /// </summary>
        /// <param name="action">Action that is requested to be performed.</param>
        /// <param name="uniqueNames">Array of unique names of the pages the action relates to.</param>
        public override void PropogateAction(DockingPropogateAction action, string[] uniqueNames)
        {
            switch (action)
            {
            case DockingPropogateAction.Loading:
                // Force layout so that the correct number of pages is recognized
                SpaceControl.PerformLayout();

                // Remove all the pages including store pages
                SpaceControl.ClearAllPages();

                // Force layout so that the control will kill itself
                SpaceControl.PerformLayout();
                break;

            case DockingPropogateAction.ShowPages:
            case DockingPropogateAction.HidePages:
            {
                bool newVisible = (action == DockingPropogateAction.ShowPages);
                foreach (string uniqueName in uniqueNames)
                {
                    // Update visible state of pages that are not placeholders
                    KryptonPage page = SpaceControl.PageForUniqueName(uniqueName);
                    if ((page != null) && !(page is KryptonStorePage))
                    {
                        page.Visible = newVisible;
                    }
                }
            }
            break;

            case DockingPropogateAction.ShowAllPages:
                SpaceControl.ShowAllPages(typeof(KryptonStorePage));
                break;

            case DockingPropogateAction.HideAllPages:
                SpaceControl.HideAllPages(typeof(KryptonStorePage));
                break;

            case DockingPropogateAction.RemovePages:
            case DockingPropogateAction.RemoveAndDisposePages:
                foreach (string uniqueName in uniqueNames)
                {
                    // If the named page exists and is not placeholder then remove it
                    KryptonPage removePage = SpaceControl.PageForUniqueName(uniqueName);
                    if ((removePage != null) && !(removePage is KryptonStorePage))
                    {
                        // Find the cell that contains the target so we can remove the page
                        KryptonWorkspaceCell cell = SpaceControl.CellForPage(removePage);
                        if (cell != null)
                        {
                            cell.Pages.Remove(removePage);

                            if (action == DockingPropogateAction.RemoveAndDisposePages)
                            {
                                removePage.Dispose();
                            }
                        }
                    }
                }
                break;

            case DockingPropogateAction.RemoveAllPages:
            case DockingPropogateAction.RemoveAndDisposeAllPages:
            {
                // Process each cell in turn
                KryptonWorkspaceCell cell = SpaceControl.FirstCell();
                while (cell != null)
                {
                    // Process each page inside the cell
                    for (int i = cell.Pages.Count - 1; i >= 0; i--)
                    {
                        // Only remove the actual page and not placeholders
                        KryptonPage page = cell.Pages[i];
                        if ((page != null) && !(page is KryptonStorePage))
                        {
                            cell.Pages.RemoveAt(i);

                            if (action == DockingPropogateAction.RemoveAndDisposeAllPages)
                            {
                                page.Dispose();
                            }
                        }
                    }

                    cell = SpaceControl.NextCell(cell);
                }

                // Force layout so that the control will kill itself
                SpaceControl.PerformLayout();
            }
            break;

            case DockingPropogateAction.StorePages:
                foreach (string uniqueName in uniqueNames)
                {
                    // Swap pages that are not placeholders to become placeholders
                    KryptonPage page = SpaceControl.PageForUniqueName(uniqueName);
                    if ((page != null) && !(page is KryptonStorePage))
                    {
                        // Replace the existing page with a placeholder that has the same unique name
                        KryptonWorkspaceCell cell        = SpaceControl.CellForPage(page);
                        KryptonStorePage     placeholder = new KryptonStorePage(uniqueName, _storeName);
                        cell.Pages.Insert(cell.Pages.IndexOf(page), placeholder);
                        cell.Pages.Remove(page);
                    }
                }
                break;

            case DockingPropogateAction.StoreAllPages:
            {
                // Process each cell in turn
                KryptonWorkspaceCell cell = SpaceControl.FirstCell();
                while (cell != null)
                {
                    // Process each page inside the cell
                    for (int i = cell.Pages.Count - 1; i >= 0; i--)
                    {
                        // Swap pages that are not placeholders to become placeholders
                        KryptonPage page = cell.Pages[i];
                        if ((page != null) && !(page is KryptonStorePage))
                        {
                            // Replace the existing page with a placeholder that has the same unique name
                            KryptonStorePage placeholder = new KryptonStorePage(page.UniqueName, _storeName);
                            cell.Pages.Insert(cell.Pages.IndexOf(page), placeholder);
                            cell.Pages.Remove(page);
                        }
                    }

                    cell = SpaceControl.NextCell(cell);
                }
            }
            break;

            case DockingPropogateAction.ClearFillerStoredPages:
            case DockingPropogateAction.ClearFloatingStoredPages:
            case DockingPropogateAction.ClearDockedStoredPages:
            case DockingPropogateAction.ClearStoredPages:
                // Only process an attempt to clear all pages or those related to this docking location
                if ((action == DockingPropogateAction.ClearStoredPages) || (action == ClearStoreAction))
                {
                    foreach (string uniqueName in uniqueNames)
                    {
                        // Only remove a matching unique name if it is a placeholder page
                        KryptonPage removePage = SpaceControl.PageForUniqueName(uniqueName);
                        if (removePage is KryptonStorePage)
                        {
                            // Check if the page is one marked to be ignored in this operation
                            if (removePage != IgnoreStorePage)
                            {
                                // Find the cell that contains the target so we can remove the page
                                KryptonWorkspaceCell cell = SpaceControl.CellForPage(removePage);
                                cell?.Pages.Remove(removePage);
                            }
                        }
                    }
                }
                break;

            case DockingPropogateAction.ClearAllStoredPages:
            {
                // Process each cell in turn
                KryptonWorkspaceCell cell = SpaceControl.FirstCell();
                while (cell != null)
                {
                    // Process each page inside the cell
                    for (int i = cell.Pages.Count - 1; i >= 0; i--)
                    {
                        // Remove all placeholders
                        KryptonPage page = cell.Pages[i];
                        if (page is KryptonStorePage)
                        {
                            cell.Pages.Remove(page);
                        }
                    }

                    cell = SpaceControl.NextCell(cell);
                }
            }
            break;

            case DockingPropogateAction.StringChanged:
                UpdateStrings();
                break;

            case DockingPropogateAction.DebugOutput:
                Console.WriteLine(SpaceControl.ToString());
                SpaceControl.DebugOutput();
                break;
            }

            // Let base class perform standard processing
            base.PropogateAction(action, uniqueNames);
        }