/// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (_page != null)
            {
                _page.Dispose();
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 2
0
        private void PageDragQuit()
        {
            if (DragPageNotify != null)
            {
                DragPageNotify.PageDragQuit(this);

                // Did not transfer the page to the target, so dispose it
                _dragPage.Dispose();
                _dragPage = null;

                // No longer dragging
                _dragging = false;
                Capture   = false;
            }
        }
Ejemplo n.º 3
0
        private void PageDragStart(Point pt)
        {
            if (DragPageNotify != null)
            {
                // Create a page that will be dragged
                _dragPage                 = new KryptonPage();
                _dragPage.Text            = _dragNode.Text;
                _dragPage.TextTitle       = _dragNode.Text + " Title";
                _dragPage.TextDescription = _dragNode.Text + " Description";
                _dragPage.ImageSmall      = ImageList.Images[int.Parse((string)_dragNode.Tag)];
                _dragPage.Tag             = _dragNode.Tag;

                // Create a rich text box with some sample text inside
                KryptonRichTextBox rtb = new KryptonRichTextBox();
                rtb.Text = "This page (" + _dragPage.Text + ") contains a rich text box control as example content.";
                rtb.Dock = DockStyle.Fill;
                rtb.StateCommon.Border.Draw = InheritBool.False;

                // Add rich text box as the contents of the page
                _dragPage.Padding = new Padding(5);
                _dragPage.Controls.Add(rtb);

                // Give the notify interface a chance to reject the attempt to drag
                PageDragCancelEventArgs de = new PageDragCancelEventArgs(PointToScreen(pt), Point.Empty, this, new KryptonPage[] { _dragPage });
                DragPageNotify.PageDragStart(this, null, de);

                if (de.Cancel)
                {
                    // No longer need the temporary drag page
                    _dragPage.Dispose();
                    _dragPage = null;
                }
                else
                {
                    _dragging = true;
                    Capture   = true;
                }
            }
        }
        private bool CloseMemoPage(KryptonPage page)
        {
            // We must have a page to actually close
            if (page != null)
            {
                // If the page is dirty then we need to ask if it should be saved
                if (page.Text.EndsWith("*"))
                {
                    switch (MessageBox.Show("Do you want to save changes to '" + page.Text.TrimEnd('*') + "' ?",
                                            "Memo Editor", MessageBoxButtons.YesNoCancel))
                    {
                    case DialogResult.Cancel:
                        // Returning true indicates the operation was cancelled
                        return(true);

                    case DialogResult.Yes:
                        SaveMemoPage(page);
                        break;

                    case DialogResult.No:
                        break;
                    }
                }

                // Remove the page from the containing cell
                KryptonWorkspaceCell cell = kryptonWorkspace.CellForPage(page);
                cell.Pages.Remove(page);
                page.Dispose();

                UpdateApplicationTitle();
                UpdateOptions();
            }

            // Returning false indicates the operation was not cancelled
            return(false);
        }
        /// <summary>
        /// Propagates 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.ShowPages:
                case DockingPropogateAction.HidePages:
                    {
                        bool newVisible = (action == DockingPropogateAction.ShowPages);
                        // Update visible state of pages that are not placeholders
                        foreach (KryptonPage page in uniqueNames
                            .Select(uniqueName => AutoHiddenGroupControl.Pages[uniqueName])
                            .Where(page => (page != null) && !(page is KryptonStorePage))
                        )
                        {
                            page.Visible = newVisible;
                        }
                    }
                    break;
                case DockingPropogateAction.ShowAllPages:
                    AutoHiddenGroupControl.ShowAllPages(typeof(KryptonStorePage));
                    break;
                case DockingPropogateAction.HideAllPages:
                    AutoHiddenGroupControl.HideAllPages(typeof(KryptonStorePage));
                    break;
                case DockingPropogateAction.RemovePages:
                case DockingPropogateAction.RemoveAndDisposePages:
                    // Only remove the actual page and not placeholders
                    foreach (KryptonPage page in uniqueNames
                        .Select(uniqueName => AutoHiddenGroupControl.Pages[uniqueName])
                        .Where(page => (page != null) && !(page is KryptonStorePage))
                    )
                    {
                        AutoHiddenGroupControl.Pages.Remove(page);

                        if (action == DockingPropogateAction.RemoveAndDisposePages)
                        {
                            page.Dispose();
                        }
                    }
                    break;
                case DockingPropogateAction.Loading:
                    // Remove all pages including store pages
                    AutoHiddenGroupControl.Pages.Clear();
                    break;
                case DockingPropogateAction.RemoveAllPages:
                case DockingPropogateAction.RemoveAndDisposeAllPages:
                    for (int i = AutoHiddenGroupControl.Pages.Count - 1; i >= 0; i--)
                    {
                        // Only remove the actual page and not placeholders
                        KryptonPage page = AutoHiddenGroupControl.Pages[i];
                        if ((page != null) && !(page is KryptonStorePage))
                        {
                            AutoHiddenGroupControl.Pages.RemoveAt(i);

                            if (action == DockingPropogateAction.RemoveAndDisposeAllPages)
                            {
                                page.Dispose();
                            }
                        }
                    }
                    break;
                case DockingPropogateAction.StorePages:
                    AutoHiddenGroupControl.StorePages(uniqueNames);
                    break;
                case DockingPropogateAction.StoreAllPages:
                    AutoHiddenGroupControl.StoreAllPages();
                    break;
                case DockingPropogateAction.ClearAutoHiddenStoredPages:
                case DockingPropogateAction.ClearStoredPages:
                    foreach (string uniqueName in uniqueNames)
                    {
                        // Only remove a matching placeholder page
                        KryptonPage page = AutoHiddenGroupControl.Pages[uniqueName];
                        if (page is KryptonStorePage)
                        {
                            AutoHiddenGroupControl.Pages.Remove(page);
                        }
                    }
                    break;
                case DockingPropogateAction.ClearAllStoredPages:
                    for (int i = AutoHiddenGroupControl.Pages.Count - 1; i >= 0; i--)
                    {
                        // Only remove a placeholder paged
                        KryptonPage page = AutoHiddenGroupControl.Pages[i];
                        if (page is KryptonStorePage)
                        {
                            AutoHiddenGroupControl.Pages.RemoveAt(i);
                        }
                    }
                    break;
            }

            // Let base class perform standard processing
            base.PropogateAction(action, uniqueNames);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            _page?.Dispose();

            base.Dispose(disposing);
        }