Exemple #1
0
        /// <summary>
        /// Select the previous page to the one provided.
        /// </summary>
        /// <param name="page">Starting page for search.</param>
        /// <param name="wrap">Wrap around end of collection to the start.</param>
        /// <param name="ctrlTab">Associated with a Ctrl+Tab action.</param>
        /// <returns>True if new page selected; otherwise false.</returns>
        public virtual bool SelectPreviousPage(KryptonPage page,
                                               bool wrap,
                                               bool ctrlTab)
        {
            // There must be at least one page and allowed to select a page
            if ((Navigator.Pages.Count > 0) && Navigator.AllowTabSelect)
            {
                KryptonPage first;

                // If given a starting page, it must be in the pages collection,
                // otherwise we start by searching from the last page backwards
                if ((page != null) && Navigator.Pages.Contains(page))
                {
                    first = Navigator.PreviousActionPage(page);

                    // If at start of collection and wrapping is enabled then get the last page
                    if ((first == null) && wrap)
                    {
                        // Are we allowed to wrap around?
                        CtrlTabCancelEventArgs ce = new CtrlTabCancelEventArgs(false);
                        Navigator.OnCtrlTabWrap(ce);

                        if (ce.Cancel)
                        {
                            return(false);
                        }

                        first = Navigator.LastActionPage();
                    }
                }
                else
                {
                    first = Navigator.LastActionPage();
                }

                // Page to test is the first one
                KryptonPage previous = first;

                // Keep testing previous pages until no more are left
                while (previous != null)
                {
                    // Attempt to select the previous page
                    Navigator.SelectedPage = previous;

                    // If previous page was selected, then all finished
                    if (Navigator.SelectedPage == previous)
                    {
                        return(true);
                    }
                    else
                    {
                        // Otherwise keep looking for another visible previous page
                        previous = Navigator.PreviousActionPage(previous);

                        // If we reached the start of the collection and we should wrap
                        if ((previous == null) && wrap)
                        {
                            // Are we allowed to wrap around?
                            CtrlTabCancelEventArgs ce = new CtrlTabCancelEventArgs(false);
                            Navigator.OnCtrlTabWrap(ce);

                            if (ce.Cancel)
                            {
                                return(false);
                            }

                            // Wrap around to the last page
                            previous = Navigator.Pages[Navigator.Pages.Count - 1];
                        }

                        // If we are back at the first page we examined then we must have
                        // wrapped around collection and still found nothing, time to exit
                        if (previous == first)
                        {
                            return(false);
                        }
                    }
                }
            }

            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.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);
                // Update visible state of pages that are not placeholders
                foreach (KryptonPage page in uniqueNames
                         .Select(uniqueName => SpaceControl.PageForUniqueName(uniqueName))
                         .Where(page => (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();
                            }
                        }
                    }
                }
                SpaceControl.PerformLayout();
                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);
        }
Exemple #3
0
 /// <summary>
 /// Initialize a new instance of the AutoHiddenShowingStateEventArgs class.
 /// </summary>
 /// <param name="page">Page for which state has changed.</param>
 /// <param name="state">New state of the auto hidden page.</param>
 public AutoHiddenShowingStateEventArgs(KryptonPage page, DockingAutoHiddenShowState state)
 {
     Page     = page;
     NewState = state;
 }
 /// <summary>
 /// Initialize a new instance of the KryptonCancelPageEventArgs class.
 /// </summary>
 /// <param name="page">Page effected by event.</param>
 /// <param name="index">Index of page in the owning collection.</param>
 public KryptonPageCancelEventArgs(KryptonPage page, int index)
     : base(page, index)
 {
 }
 /// <summary>
 /// Add a KryptonPage into an existing cell.
 /// </summary>
 /// <param name="cell">Reference to existing workspace cell.</param>
 /// <param name="page">KryptonPage instance to be added.</param>
 public void CellAppend(KryptonWorkspaceCell cell, KryptonPage page)
 {
     // Use existing array adding method to prevent duplication of code
     CellAppend(cell, new KryptonPage[] { page });
 }
Exemple #6
0
 /// <summary>
 /// Process a change in the visible state for a page.
 /// </summary>
 /// <param name="page">Page that has changed visible state.</param>
 public override void PageVisibleStateChanged(KryptonPage page)
 {
     UpdateButtons();
     base.PageVisibleStateChanged(page);
 }
 /// <summary>
 /// Initialize a new instance of the PageButtonSpecCollection class.
 /// </summary>
 /// <param name="owner">Reference to owning object.</param>
 public PageButtonSpecCollection(KryptonPage owner)
     : base(owner)
 {
 }
        /// <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)
        {
            KryptonPageCollection pageCollection = DockableNavigatorControl.Pages;

            switch (action)
            {
            case DockingPropogateAction.Loading:
                // Remove all pages including store pages
                pageCollection.Clear();
                return;

            case DockingPropogateAction.ShowAllPages:
            case DockingPropogateAction.HideAllPages:
            case DockingPropogateAction.RemoveAllPages:
            case DockingPropogateAction.RemoveAndDisposeAllPages:
                // Ignore some global actions
                return;

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

            case DockingPropogateAction.StoreAllPages:
                // Process each page inside the cell
                for (int i = pageCollection.Count - 1; i >= 0; i--)
                {
                    // Swap pages that are not placeholders to become placeholders
                    KryptonPage page = pageCollection[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);
                        pageCollection.Insert(pageCollection.IndexOf(page), placeholder);
                        pageCollection.Remove(page);
                    }
                }

                break;

            case DockingPropogateAction.ClearFillerStoredPages:
            case DockingPropogateAction.ClearStoredPages:
                foreach (string uniqueName in uniqueNames)
                {
                    // Only remove a matching unique name if it is a placeholder page
                    KryptonPage removePage = pageCollection[uniqueName];
                    if (removePage is KryptonStorePage)
                    {
                        pageCollection.Remove(removePage);
                    }
                }
                break;

            case DockingPropogateAction.ClearAllStoredPages:
            {
                // Process each page inside the cell
                for (int i = pageCollection.Count - 1; i >= 0; i--)
                {
                    // Remove all placeholders
                    KryptonPage page = pageCollection[i];
                    if (page is KryptonStorePage)
                    {
                        pageCollection.Remove(page);
                    }
                }
            }
            break;

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

            // Let base class perform standard processing
            base.PropogateAction(action, uniqueNames);
        }
 /// <summary>
 /// Slide the specified page into view and optionally select.
 /// </summary>
 /// <param name="page">Page to slide into view.</param>
 /// <param name="select">True to select the page; otherwise false.</param>
 public void SlidePageOut(KryptonPage page, bool select)
 {
     SlidePageOut(page.UniqueName, select);
 }
        private void OnCheckButtonDragOffset(object sender, ButtonDragOffsetEventArgs e)
        {
            // Cast incoming reference to the actual check button view
            ViewDrawNavCheckButtonStack reorderView = (ViewDrawNavCheckButtonStack)sender;

            // Scan the collection of children
            bool        foundReorderView = false;
            Orientation stackOrient      = Navigator.Stack.StackOrientation;

            foreach (KryptonPage page in Navigator.Pages)
            {
                // If the mouse is over this button
                ViewDrawNavCheckButtonStack childView = (ViewDrawNavCheckButtonStack)_pageLookup[page];
                if (childView.ClientRectangle.Contains(e.PointOffset))
                {
                    // Only interested if mouse over a different check button
                    if (childView != reorderView)
                    {
                        Rectangle childRect = childView.ClientRectangle;

                        if (foundReorderView)
                        {
                            if (stackOrient == Orientation.Vertical)
                            {
                                int shrink = childRect.Height - Math.Min(childRect.Height, reorderView.ClientHeight);
                                childRect.Y      += shrink;
                                childRect.Height -= shrink;
                            }
                            else
                            {
                                int shrink = childRect.Width - Math.Min(childRect.Width, reorderView.ClientWidth);
                                childRect.X     += shrink;
                                childRect.Width -= shrink;
                            }

                            // Ensure that when we are placed in the 'after' position the mouse is still over
                            // ourself as the moved button. Otherwise we just end up toggling back and forth.
                            if (childRect.Contains(e.PointOffset))
                            {
                                KryptonPage          movePage   = PageFromView(reorderView);
                                KryptonPage          targetPage = PageFromView(childView);
                                PageReorderEventArgs reorder    = new PageReorderEventArgs(movePage, targetPage, false);

                                // Give event handlers a chance to cancel this reorder
                                Navigator.OnBeforePageReorder(reorder);
                                if (!reorder.Cancel)
                                {
                                    Navigator.Pages.MoveAfter(movePage, PageFromView(childView));
                                    RecreateView();
                                    Navigator.PerformLayout();
                                    Navigator.Refresh();
                                    Navigator.OnTabMoved(new TabMovedEventArgs(movePage, Navigator.Pages.IndexOf(movePage)));
                                }
                            }
                        }
                        else
                        {
                            if (stackOrient == Orientation.Vertical)
                            {
                                childRect.Height = Math.Min(childRect.Height, reorderView.ClientHeight);
                            }
                            else
                            {
                                childRect.Width = Math.Min(childRect.Width, reorderView.ClientWidth);
                            }

                            // Ensure that when we are placed in the 'before' position the mouse is still over
                            // ourself as the moved button. Otherwise we just end up toggling back and forth.
                            if (childRect.Contains(e.PointOffset))
                            {
                                KryptonPage          movePage   = PageFromView(reorderView);
                                KryptonPage          targetPage = PageFromView(childView);
                                PageReorderEventArgs reorder    = new PageReorderEventArgs(movePage, targetPage, true);

                                // Give event handlers a chance to cancel this reorder
                                Navigator.OnBeforePageReorder(reorder);
                                if (!reorder.Cancel)
                                {
                                    Navigator.Pages.MoveBefore(movePage, PageFromView(childView));
                                    RecreateView();
                                    Navigator.PerformLayout();
                                    Navigator.Refresh();
                                    Navigator.OnTabMoved(new TabMovedEventArgs(movePage, Navigator.Pages.IndexOf(movePage)));
                                }
                            }
                        }

                        break;
                    }
                }

                foundReorderView = (childView == reorderView);
            }
        }
        /// <summary>
        /// Request this cell load and update state.
        /// </summary>
        /// <param name="workspace">Reference to owning workspace instance.</param>
        /// <param name="xmlReader">Xml reader for loading information.</param>
        /// <param name="existingPages">Dictionary on existing pages before load.</param>
        public void LoadFromXml(KryptonWorkspace workspace,
                                XmlReader xmlReader,
                                UniqueNameToPage existingPages)
        {
            // Load the cell details and return the unique name of the selected page for the cell
            string      selectedPageUniqueName = workspace.ReadCellElement(xmlReader, this);
            KryptonPage selectedPage           = null;

            // If the cell contains nothing then exit immediately
            if (!xmlReader.IsEmptyElement)
            {
                do
                {
                    // Read the next Element
                    if (!xmlReader.Read())
                    {
                        throw new ArgumentException("An element was expected but could not be read in.");
                    }

                    // Is this the end of the cell
                    if (xmlReader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }

                    if (xmlReader.Name == "KP")
                    {
                        // Load the page details and optionally recreate the page
                        string      uniqueName = CommonHelper.XmlAttributeToText(xmlReader, "UN");
                        KryptonPage page       = workspace.ReadPageElement(xmlReader, uniqueName, existingPages);

                        if (xmlReader.Name != "CPD")
                        {
                            throw new ArgumentException("Expected 'CPD' element was not found");
                        }

                        bool finished = xmlReader.IsEmptyElement;

                        // Generate event so custom data can be loaded and/or the page to be added can be modified
                        PageLoadingEventArgs plea = new PageLoadingEventArgs(workspace, page, xmlReader);
                        workspace.OnPageLoading(plea);
                        page = plea.Page;

                        // Read everything until we get the end of custom data marker
                        while (!finished)
                        {
                            // Check it has the expected name
                            if (xmlReader.NodeType == XmlNodeType.EndElement)
                            {
                                finished = (xmlReader.Name == "CPD");
                            }

                            if (!finished)
                            {
                                if (!xmlReader.Read())
                                {
                                    throw new ArgumentException("An element was expected but could not be read in.");
                                }
                            }
                        }

                        // Read past the end of page element
                        if (!xmlReader.Read())
                        {
                            throw new ArgumentException("An element was expected but could not be read in.");
                        }

                        // Check it has the expected name
                        if (xmlReader.NodeType != XmlNodeType.EndElement)
                        {
                            throw new ArgumentException("End of 'KP' element expected but missing.");
                        }

                        // PageLoading event might have nulled the page value to prevent it being added
                        if (page != null)
                        {
                            // Remember the page that should become selected
                            if (!string.IsNullOrEmpty(page.UniqueName) && (page.UniqueName == selectedPageUniqueName))
                            {
                                // Can only selected a visible page
                                if (page.LastVisibleSet)
                                {
                                    selectedPage = page;
                                }
                            }

                            Pages.Add(page);
                        }
                    }
                    else
                    {
                        throw new ArgumentException("Unknown element was encountered.");
                    }
                }while (true);
            }

            // Did we find a matching page that should become selected?
            // (and we are allowed to have selected tabs)
            if ((selectedPage != null) && AllowTabSelect)
            {
                SelectedPage = selectedPage;
            }
        }
        /// <summary>
        /// Perform the drop action associated with the target.
        /// </summary>
        /// <param name="screenPt">Position in screen coordinates.</param>
        /// <param name="data">Data to pass to the target to process drop.</param>
        /// <returns>Drop was performed and the source can perform any removal of pages as required.</returns>
        public override bool PerformDrop(Point screenPt, PageDragEndData data)
        {
            // Transfer the dragged pages into a new cell
            KryptonWorkspaceCell cell = new KryptonWorkspaceCell();
            KryptonPage          page = ProcessDragEndData(Workspace, cell, data);

            // If no pages are transferred then we do nothing and no longer need cell instance
            if (page == null)
            {
                cell.Dispose();
            }
            else
            {
                // If the root is not the same direction as that needed for the drop then...
                bool dropHorizontal = (Edge == VisualOrientation.Left) || (Edge == VisualOrientation.Right);
                if ((dropHorizontal && (Workspace.Root.Orientation == Orientation.Vertical)) ||
                    (!dropHorizontal && (Workspace.Root.Orientation == Orientation.Horizontal)))
                {
                    // Create a new sequence and place all existing root items into it
                    KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence(Workspace.Root.Orientation);
                    for (int i = Workspace.Root.Children.Count - 1; i >= 0; i--)
                    {
                        Component child = Workspace.Root.Children[i];
                        Workspace.Root.Children.RemoveAt(i);
                        sequence.Children.Insert(0, child);
                    }

                    // Put the new sequence in the root so all items are now grouped together
                    Workspace.Root.Children.Add(sequence);

                    // Switch the direction of the root
                    if (Workspace.Root.Orientation == Orientation.Horizontal)
                    {
                        Workspace.Root.Orientation = Orientation.Vertical;
                    }
                    else
                    {
                        Workspace.Root.Orientation = Orientation.Horizontal;
                    }
                }

                // Add to the start or the end of the root sequence?
                if ((Edge == VisualOrientation.Left) || (Edge == VisualOrientation.Top))
                {
                    Workspace.Root.Children.Insert(0, cell);
                }
                else
                {
                    Workspace.Root.Children.Add(cell);
                }

                // Make the last page transfer the newly selected page of the cell
                if (page != null)
                {
                    // Does the cell allow the selection of tabs?
                    if (cell.AllowTabSelect)
                    {
                        cell.SelectedPage = page;
                    }

                    // Need to layout so the new cell has been added as a child control and
                    // therefore can receive the focus we want to give it immediately afterwards
                    Workspace.PerformLayout();

                    if (!cell.IsDisposed)
                    {
                        // Without this DoEvents() call the dropping of multiple pages in a complex arrangement causes an exception for
                        // a complex reason that is hard to work out (i.e. I'm not entirely sure). Something to do with using select to
                        // change activation is causing the source workspace control to dispose to earlier.
                        Application.DoEvents();
                        cell.Select();
                    }
                }
            }

            return(true);
        }
Exemple #13
0
 /// <summary>
 /// Initialize a new instance of the ViewDrawNavCheckButtonOutlook class.
 /// </summary>
 /// <param name="navigator">Owning navigator instance.</param>
 /// <param name="page">Page this check button represents.</param>
 /// <param name="orientation">Orientation for the check button.</param>
 public ViewDrawNavOutlookOverflow(KryptonNavigator navigator,
                                   KryptonPage page,
                                   VisualOrientation orientation)
     : base(navigator, page, orientation, true)
 {
 }
Exemple #14
0
 /// <summary>
 /// Initialize a new instance of the ShowContextMenuArgs class.
 /// </summary>
 /// <param name="page">Page effected by event.</param>
 /// <param name="index">Index of page in the owning collection.</param>
 public ShowContextMenuArgs(KryptonPage page, int index)
     : base(page, index)
 {
     ContextMenuStrip   = page.ContextMenuStrip;
     KryptonContextMenu = page.KryptonContextMenu;
 }
Exemple #15
0
 /// <summary>
 /// Initialize a new instance of the KryptonPageFormEditFlags class.
 /// </summary>
 /// <param name="page">Reference to page to display flags for.</param>
 public KryptonPageFormEditFlags(KryptonPage page)
 {
     _page = page;
     InitializeComponent();
 }
        /// <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);
        }
Exemple #17
0
 /// <summary>
 /// Initialize a new instance of the ViewDrawNavCheckButtonBar class.
 /// </summary>
 /// <param name="navigator">Owning navigator instance.</param>
 /// <param name="page">Page this check button represents.</param>
 /// <param name="orientation">Orientation for the check button.</param>
 public ViewDrawNavCheckButtonBar(KryptonNavigator navigator,
                                  KryptonPage page,
                                  VisualOrientation orientation)
     : base(navigator, page, orientation)
 {
 }
        /// <summary>
        /// Requests the panel slide into view and display the provided page.
        /// </summary>
        /// <param name="page">Reference to page for display.</param>
        /// <param name="group">Reference to auto hidden group that displays the page.</param>
        /// <param name="select">Should the sliding out page become selected.</param>
        public void SlideOut(KryptonPage page, KryptonAutoHiddenGroup group, bool select)
        {
            // Check to see if we allowed to perform operations
            if (Disposing || IsDisposed)
            {
                return;
            }

            // Move to the hidden state
            switch (_state)
            {
            case DockingAutoHiddenShowState.Hidden:
                // Nothing to do, already in state we require
                break;

            case DockingAutoHiddenShowState.SlidingIn:
                // If already showing indicated page (although currently sliding inwards)
                if (page == _page)
                {
                    // Switch to sliding out again
                    _state = DockingAutoHiddenShowState.SlidingOut;

                    // Are we requested to set focus to the sliding in dockspace?
                    if (select)
                    {
                        DockspaceControl.Select();
                        DockspaceControl.CellLosesFocus += new EventHandler <WorkspaceCellEventArgs>(OnDockspaceCellLosesFocus);
                    }
                    return;
                }
                else
                {
                    // Different page, so move straight to hidden state
                    MakeHidden();
                }
                break;

            case DockingAutoHiddenShowState.SlidingOut:
            case DockingAutoHiddenShowState.Showing:
                // If already showing indicated page (or in the process of showing) then do nothing
                if (page == _page)
                {
                    // Are we requested to set focus to the sliding in dockspace?
                    if (select)
                    {
                        DockspaceControl.Select();
                        DockspaceControl.CellLosesFocus += new EventHandler <WorkspaceCellEventArgs>(OnDockspaceCellLosesFocus);
                    }
                    return;
                }
                else
                {
                    // Different page, so move straight to hidden state
                    MakeHidden();
                }
                break;
            }

            // Cache information about the page being displayed
            _page  = page;
            _group = group;

            // Make sure we have a visible cell to update
            KryptonWorkspaceCell cell = DockspaceControl.FirstVisibleCell();

            if (cell == null)
            {
                cell = new KryptonWorkspaceCell();
                DockspaceControl.Root.Children.Add(cell);
            }

            // Replace any existing page with the new one
            DockspaceControl.ClearAllPages();
            cell.Pages.Add(page);
            DockspaceControl.PerformLayout();

            // Find the starting and ending rectangles for the slide operation
            CalculateStartAndEnd();

            // Set initial positions of ourself and the contained inner panel
            _inner.SetBounds(0, 0, _endRect.Width, _endRect.Height);
            SetBounds(_startRect.X, _startRect.Y, _startRect.Width, _startRect.Height);

            // Make sure we are at the top of the z-order and visible
            _control.Controls.SetChildIndex(this, 0);
            Visible = true;

            // Switch to new state and start animation timer
            _state = DockingAutoHiddenShowState.SlidingOut;
            AutoHiddenShowingStateEventArgs args = new AutoHiddenShowingStateEventArgs(_page, _state);

            _slideTimer.Start();

            // Are we requested to set focus to the sliding in dockspace?
            if (select)
            {
                DockspaceControl.Select();
                DockspaceControl.CellLosesFocus += new EventHandler <WorkspaceCellEventArgs>(OnDockspaceCellLosesFocus);
            }

            // Raises event to indicate change in auto hidden showing state
            OnAutoHiddenShowingStateChanged(args);
        }
Exemple #19
0
 /// <summary>
 /// Initialize a new instance of the TabMovedEventArgs class.
 /// </summary>
 /// <param name="page">Reference to page that has been moved.</param>
 /// <param name="index">New index of the page within the page collection.</param>
 public TabMovedEventArgs(KryptonPage page, int index)
 {
     Page  = page;
     Index = index;
 }
Exemple #20
0
 /// <summary>
 /// Initialize a new instance of the ActivePageChangedEventArgs class.
 /// </summary>
 /// <param name="oldPage">Previous active page value.</param>
 /// <param name="newPage">New active page value.</param>
 public ActivePageChangedEventArgs(KryptonPage oldPage,
                                   KryptonPage newPage)
 {
     OldPage = oldPage;
     NewPage = newPage;
 }
Exemple #21
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawNavCheckButtonBase class.
        /// </summary>
        /// <param name="navigator">Owning navigator instance.</param>
        /// <param name="page">Page this check button represents.</param>
        /// <param name="orientation">Orientation for the check button.</param>
        /// <param name="stateDisabled">Source for disabled state values.</param>
        /// <param name="stateNormal">Source for normal state values.</param>
        /// <param name="stateTracking">Source for tracking state values.</param>
        /// <param name="statePressed">Source for pressed state values.</param>
        /// <param name="stateSelected">Source for selected state values.</param>
        /// <param name="stateFocused">Source for focused state values.</param>
        public ViewDrawNavCheckButtonBase(KryptonNavigator navigator,
                                          KryptonPage page,
                                          VisualOrientation orientation,
                                          IPaletteTriple stateDisabled,
                                          IPaletteTriple stateNormal,
                                          IPaletteTriple stateTracking,
                                          IPaletteTriple statePressed,
                                          IPaletteTriple stateSelected,
                                          IPaletteTriple stateFocused)
            : base(stateDisabled, stateNormal, stateTracking,
                   statePressed, null, null, orientation, true)
        {
            Debug.Assert(navigator != null);

            Navigator  = navigator;
            _page      = page;
            _lastClick = DateTime.Now.AddDays(-1);

            // Associate the page component with this view element
            Component = page;

            // Prevent user from unchecking the selected check button
            AllowUncheck = false;

            // Set the source for values to ourself
            ButtonValues = this;

            // Create a controller for managing button behavior
            IMouseController controller = CreateMouseController();

            MouseController = controller;

            // Create overrides for getting the focus values
            _overrideDisabled = new PaletteTripleOverride(stateFocused, stateDisabled, PaletteState.FocusOverride);
            _overrideNormal   = new PaletteTripleOverride(stateFocused, stateNormal, PaletteState.FocusOverride);
            _overrideTracking = new PaletteTripleOverride(stateFocused, stateTracking, PaletteState.FocusOverride);
            _overridePressed  = new PaletteTripleOverride(stateFocused, statePressed, PaletteState.FocusOverride);
            _overrideSelected = new PaletteTripleOverride(stateFocused, stateSelected, PaletteState.FocusOverride);

            // Push values into the base class
            SetPalettes(_overrideDisabled, _overrideNormal, _overrideTracking, _overridePressed);
            SetCheckedPalettes(_overrideSelected, _overrideSelected, _overrideSelected);

            // Are we allowed to add button specs to the button?
            if (AllowButtonSpecs)
            {
                // Create button specification collection manager
                ButtonSpecManager = new ButtonSpecNavManagerLayoutBar(Navigator, Navigator.InternalRedirector, Page.ButtonSpecs, null,
                                                                      new ViewLayoutDocker[] { LayoutDocker },
                                                                      new IPaletteMetric[] { Navigator.StateCommon },
                                                                      new PaletteMetricInt[] { PaletteMetricInt.PageButtonInset },
                                                                      new PaletteMetricInt[] { PaletteMetricInt.PageButtonInset },
                                                                      new PaletteMetricPadding[] { PaletteMetricPadding.PageButtonPadding },
                                                                      Navigator.CreateToolStripRenderer,
                                                                      null)
                {
                    // Hook up the tooltip manager so that tooltips can be generated
                    ToolTipManager = Navigator.ToolTipManager
                };

                // Allow derived classes to update the remapping with different values
                UpdateButtonSpecMapping();
            }
        }
        /// <summary>
        /// Perform the drop action associated with the target.
        /// </summary>
        /// <param name="screenPt">Position in screen coordinates.</param>
        /// <param name="data">Data to pass to the target to process drop.</param>
        /// <returns>Drop was performed and the source can perform any removal of pages as required.</returns>
        public override bool PerformDrop(Point screenPt, PageDragEndData data)
        {
            // We need a parent sequence in order to perform drop
            if (Cell.WorkspaceParent is KryptonWorkspaceSequence parent)
            {
                // Transfer the dragged pages into a new cell
                KryptonWorkspaceCell cell = new KryptonWorkspaceCell();
                KryptonPage          page = ProcessDragEndData(Workspace, cell, data);

                // If no pages are transferred then we do nothing and no longer need cell instance
                if (page == null)
                {
                    cell.Dispose();
                }
                else
                {
                    // If the parent sequence is not the same direction as that needed for the drop then...
                    bool dropHorizontal = (Edge == VisualOrientation.Left) || (Edge == VisualOrientation.Right);
                    if ((dropHorizontal && (parent.Orientation == Orientation.Vertical)) ||
                        (!dropHorizontal && (parent.Orientation == Orientation.Horizontal)))
                    {
                        // Find opposite direction to the parent sequence
                        Orientation sequenceOrientation = parent.Orientation == Orientation.Horizontal
                            ? Orientation.Vertical
                            : Orientation.Horizontal;

                        // Create a new sequence and transfer the target cell into it
                        KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence(sequenceOrientation);
                        int index = parent.Children.IndexOf(Cell);
                        parent.Children.RemoveAt(index);
                        sequence.Children.Add(Cell);

                        // Put the sequence into the place where the target cell used to be
                        parent.Children.Insert(index, sequence);

                        // Add new cell to the start or the end of the new sequence?
                        if ((Edge == VisualOrientation.Left) || (Edge == VisualOrientation.Top))
                        {
                            sequence.Children.Insert(0, cell);
                        }
                        else
                        {
                            sequence.Children.Add(cell);
                        }
                    }
                    else
                    {
                        // Find position of the target cell
                        int index = parent.Children.IndexOf(Cell);

                        // Add new cell before or after the target cell?
                        if ((Edge == VisualOrientation.Left) || (Edge == VisualOrientation.Top))
                        {
                            parent.Children.Insert(index, cell);
                        }
                        else
                        {
                            parent.Children.Insert(index + 1, cell);
                        }
                    }

                    // Make the last page transferred the newly selected page of the cell
                    if (page != null)
                    {
                        // Does the cell allow the selection of tabs?
                        if (cell.AllowTabSelect)
                        {
                            cell.SelectedPage = page;
                        }

                        // Need to layout so the new cell has been added as a child control and
                        // therefore can receive the focus we want to give it immediately afterwards
                        Workspace.PerformLayout();

                        if (!cell.IsDisposed)
                        {
                            // Without this DoEvents() call the dropping of multiple pages in a complex arrangement causes an exception for
                            // a complex reason that is hard to work out (i.e. I'm not entirely sure). Something to do with using select to
                            // change activation is causing the source workspace control to dispose to earlier.
                            Application.DoEvents();
                            cell.Select();
                        }
                    }
                }
            }

            return(true);
        }
 /// <summary>
 /// Initialize a new instance of the PageDropEventArgs class.
 /// </summary>
 /// <param name="page">Page that is being dropped.</param>
 public PageDropEventArgs(KryptonPage page)
 {
     _page = page;
 }
Exemple #24
0
 /// <summary>
 /// Initialize a new instance of the CancelDropDownEventArgs class.
 /// </summary>
 /// <param name="contextMenu">Reference to associated context menu.</param>
 /// <param name="page">Reference to the associated page.</param>
 public CancelDropDownEventArgs(KryptonContextMenu contextMenu, KryptonPage page)
     : base(false)
 {
     KryptonContextMenu = contextMenu;
     Page = page;
 }
 /// <summary>
 /// Add a KryptonPage array into an existing cell starting at the provided index.
 /// </summary>
 /// <param name="cell">Reference to existing workspace cell.</param>
 /// <param name="index">Index for inserting new pages.</param>
 /// <param name="page">KryptonPage instance to be added.</param>
 public void CellInsert(KryptonWorkspaceCell cell, int index, KryptonPage page)
 {
     // Use existing array adding method to prevent duplication of code
     CellInsert(cell, index, new KryptonPage[] { page });
 }
Exemple #26
0
 /// <summary>
 /// Add the check buttons for pages that should be on the overflow area.
 /// </summary>
 /// <param name="page">Reference to owning page.</param>
 /// <param name="checkOverflowOrient">Docking edge to dock against.</param>
 /// <param name="overflowInsertIndex">Index for inserting the new entry.</param>
 protected override void ReorderCheckButtonsOverflow(KryptonPage page,
                                                     VisualOrientation checkOverflowOrient,
                                                     ref int overflowInsertIndex)
 {
     // Do nothing, we never add the overflow buttons to the display
 }
 /// <summary>
 /// Add a KryptonPage to the currently active cell or create a new cell is no cell is currently active.
 /// </summary>
 /// <param name="page">KryptonPage to be added.</param>
 public void Append(KryptonPage page)
 {
     // Use existing array adding method to prevent duplication of code
     Append(new KryptonPage[] { page });
 }
 public ContentFlags(KryptonPage page)
 {
     _page = page;
     InitializeComponent();
 }
Exemple #29
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawNavRibbonTab class.
        /// </summary>
        /// <param name="navigator">Owning navigator instance.</param>
        /// <param name="page">Page this ribbon tab represents.</param>
        public ViewDrawNavRibbonTab(KryptonNavigator navigator,
                                    KryptonPage page)
        {
            Debug.Assert(navigator != null);
            Debug.Assert(page != null);

            Navigator  = navigator;
            Page       = page;
            _lastClick = DateTime.Now.AddDays(-1);

            // Associate the page component with this view element
            Component = page;

            // Create a controller for managing button behavior
            _buttonController = new PageButtonController(this, OnNeedPaint)
            {
                ClickOnDown = true
            };
            _buttonController.Click      += OnClick;
            _buttonController.RightClick += OnRightClick;

            // Allow the page to be dragged and hook into drag events
            _buttonController.AllowDragging        = true;
            _buttonController.DragStart           += OnDragStart;
            _buttonController.DragMove            += OnDragMove;
            _buttonController.DragEnd             += OnDragEnd;
            _buttonController.DragQuit            += OnDragQuit;
            _buttonController.ButtonDragRectangle += OnButtonDragRectangle;
            _buttonController.ButtonDragOffset    += OnButtonDragOffset;

            // A tab is selected on being pressed and not on the mouse up
            _buttonController.ClickOnDown = true;

            // We need to be notified of got/lost focus and keyboard events
            SourceController = _buttonController;
            KeyController    = _buttonController;

            // Create a decorator to interface with the tooltip manager
            ToolTipController toolTipController = new ToolTipController(Navigator.ToolTipManager, this, _buttonController);
            ToolTipController hoverController   = new ToolTipController(Navigator.HoverManager, this, toolTipController);

            // Assign controller for handing mouse input
            MouseController = hoverController;

            // Create overrides for handling a focus state
            _paletteGeneral        = Navigator.StateCommon.RibbonGeneral;
            _overrideStateNormal   = new PaletteRibbonTabContentInheritOverride(Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.Content, Page.StateNormal.RibbonTab.TabDraw, Page.StateNormal.RibbonTab.TabDraw, Page.StateNormal.RibbonTab.Content, PaletteState.FocusOverride);
            _overrideStateTracking = new PaletteRibbonTabContentInheritOverride(Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.Content, Page.StateTracking.RibbonTab.TabDraw, Page.StateTracking.RibbonTab.TabDraw, Page.StateTracking.RibbonTab.Content, PaletteState.FocusOverride);
            _overrideStatePressed  = new PaletteRibbonTabContentInheritOverride(Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.Content, Page.StatePressed.RibbonTab.TabDraw, Page.StatePressed.RibbonTab.TabDraw, Page.StatePressed.RibbonTab.Content, PaletteState.FocusOverride);
            _overrideStateSelected = new PaletteRibbonTabContentInheritOverride(Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.Content, Page.StateSelected.RibbonTab.TabDraw, Page.StateSelected.RibbonTab.TabDraw, Page.StateSelected.RibbonTab.Content, PaletteState.FocusOverride);

            // Use a class to convert from ribbon tab to content interface
            _contentProvider = new RibbonTabToContent(_paletteGeneral, _overrideStateNormal, _overrideStateNormal);

            // Create the content view element and use the content provider as a way to
            // convert from the ribbon palette entries to the content palette entries
            _viewContent = new ViewDrawContent(_contentProvider, this, VisualOrientation.Top);

            // Add content to the view
            _layoutDocker = new ViewLayoutDocker
            {
                { _viewContent, ViewDockStyle.Fill }
            };
            Add(_layoutDocker);

            // Create button specification collection manager
            ButtonSpecManager = new ButtonSpecNavManagerLayoutBar(Navigator, Navigator.InternalRedirector, Page.ButtonSpecs, null,
                                                                  new ViewLayoutDocker[] { _layoutDocker },
                                                                  new IPaletteMetric[] { Navigator.StateCommon },
                                                                  new PaletteMetricInt[] { PaletteMetricInt.PageButtonInset },
                                                                  new PaletteMetricInt[] { PaletteMetricInt.PageButtonInset },
                                                                  new PaletteMetricPadding[] { PaletteMetricPadding.PageButtonPadding },
                                                                  Navigator.CreateToolStripRenderer,
                                                                  OnNeedPaint)
            {
                // Hook up the tooltip manager so that tooltips can be generated
                ToolTipManager = Navigator.ToolTipManager,
                RemapTarget    = ButtonSpecNavRemap.ButtonSpecRemapTarget.ButtonStandalone
            };

            // Ensure current button specs are created
            ButtonSpecManager.RecreateButtons();

            // Create the state specific memento array
            _mementos = new IDisposable[Enum.GetValues(typeof(PaletteState)).Length];

            // Cache the last shape encountered
            _lastRibbonShape = PaletteRibbonShape.Office2010;
        }
Exemple #30
0
        /// <summary>
        /// Processes a mnemonic character.
        /// </summary>
        /// <param name="charCode">The mnemonic character entered.</param>
        /// <returns>true if the mnemonic was processsed; otherwise, false.</returns>
        public virtual bool ProcessMnemonic(char charCode)
        {
            // There must be at least one page and allowed to select a page
            if ((Navigator.Pages.Count > 0) && Navigator.AllowTabSelect)
            {
                KryptonPage first;

                // Start searching from after the selected page onwards
                if (Navigator.SelectedPage != null)
                {
                    first = Navigator.NextActionPage(Navigator.SelectedPage);

                    // If at end of collection then get the first page
                    if (first == null)
                    {
                        first = Navigator.FirstActionPage();
                    }
                }
                else
                {
                    first = Navigator.FirstActionPage();
                }

                // Next page to test is the first one
                KryptonPage next = first;

                // Keep testing next pages until no more are left
                while (next != null)
                {
                    // Does the mnemonic for the page match the keys
                    if (Control.IsMnemonic(charCode, next.Text))
                    {
                        // Attempt to select the next page
                        Navigator.SelectedPage = next;

                        // If next page was selected, then all finished
                        if (Navigator.SelectedPage == next)
                        {
                            // If we do not have the focus, then take it now
                            Navigator.Focus();

                            // Select the first control inside the page
                            Navigator.SelectNextPageControl(true, true);

                            return(true);
                        }
                    }

                    // Otherwise keep looking for another visible next page
                    next = Navigator.NextActionPage(next);

                    // If we reached the end of the collection then wrap
                    if (next == null)
                    {
                        // Wrap around to the first page
                        next = Navigator.FirstActionPage();
                    }

                    // If we are back at the first page we examined then we must have
                    // wrapped around collection and still found nothing, time to exit
                    if (next == first)
                    {
                        break;
                    }
                }
            }

            return(false);
        }