/// <summary>
 /// Initialize a new instance of the FloatspaceCellEventArgs class.
 /// </summary>
 /// <param name="floatspace">Reference to existing floatspace control instance.</param>
 /// <param name="element">Reference to docking floatspace element that is managing the floatspace control.</param>
 /// <param name="cell">Reference tofloatspace control cell instance.</param>
 public FloatspaceCellEventArgs(KryptonFloatspace floatspace,
                                KryptonDockingFloatspace element,
                                KryptonWorkspaceCell cell)
 {
     _floatspace = floatspace;
     _element = element;
     _cell = cell;
 }
 /// <summary>
 /// Initialize a new instance of the DockableWorkspaceCellEventArgs class.
 /// </summary>
 /// <param name="workspace">Reference to existing dockable workspace control instance.</param>
 /// <param name="element">Reference to docking workspace element that is managing the dockable workspace control.</param>
 /// <param name="cell">Reference to workspace control cell instance.</param>
 public DockableWorkspaceCellEventArgs(KryptonDockableWorkspace workspace,
                                       KryptonDockingWorkspace element,
                                       KryptonWorkspaceCell cell)
 {
     _workspace = workspace;
     _element = element;
     _cell = cell;
 }
 /// <summary>
 /// Initialize a new instance of the DockspaceCellEventArgs class.
 /// </summary>
 /// <param name="dockspace">Reference to existing dockspace control instance.</param>
 /// <param name="element">Reference to docking dockspace element that is managing the dockspace control.</param>
 /// <param name="cell">Reference to dockspace control cell instance.</param>
 public DockspaceCellEventArgs(KryptonDockspace dockspace,
                               KryptonDockingDockspace element,
                               KryptonWorkspaceCell cell)
 {
     _dockspace = dockspace;
     _element = element;
     _cell = cell;
 }
        /// <summary>
        /// Initialize a new cell.
        /// </summary>
        /// <param name="cell">Cell being added to the control.</param>
        protected override void NewCellInitialize(KryptonWorkspaceCell cell)
        {
            // Let base class perform event hooking and customizations
            base.NewCellInitialize(cell);

            // We only ever show a single page in the dockspace, so remove default
            // tabbed appearance and instead use a header group mode instead
            cell.NavigatorMode = NavigatorMode.HeaderGroup;
        }
 /// <summary>
 /// Initialize a new instance of the CellDragCancelEventArgs class.
 /// </summary>
 /// <param name="screenPoint">Screen point of the mouse.</param>
 /// <param name="screenOffset">Screen offset of the mouse to the source element.</param>
 /// <param name="c">Control that started the drag operation.</param>
 /// <param name="pages">Array of event associated pages.</param>
 /// <param name="cell">Workspace cell associated with pages.</param>
 public CellDragCancelEventArgs(Point screenPoint,
                                Point screenOffset,
                                Control c,
                                KryptonPage[] pages,
                                KryptonWorkspaceCell cell)
     : base(screenPoint, screenOffset, c, pages)
 {
     _cell = cell;
 }
 /// <summary>
 /// Initialize a new instance of the DragTargetWorkspaceCellTransfer class.
 /// </summary>
 /// <param name="screenRect">Rectangle for screen area.</param>
 /// <param name="hotRect">Rectangle for hot area.</param>
 /// <param name="drawRect">Rectangle for draw area.</param>
 /// <param name="workspace">Control instance for drop.</param>
 /// <param name="cell">Workspace cell as target for drop.</param>
 /// <param name="allowFlags">Only drop pages that have one of these flags defined.</param>
 public DragTargetWorkspaceCellTransfer(Rectangle screenRect,
                                        Rectangle hotRect,
                                        Rectangle drawRect,
                                        KryptonWorkspace workspace,
                                        KryptonWorkspaceCell cell,
                                        KryptonPageFlags allowFlags)
     : base(screenRect, hotRect, drawRect, DragTargetHint.Transfer, workspace, allowFlags)
 {
     _cell = cell;
     _notDraggedPagesFromCell = -1;
 }
 /// <summary>
 /// Initialize a new instance of the DragTargetWorkspaceCellEdge class.
 /// </summary>
 /// <param name="screenRect">Rectangle for screen area.</param>
 /// <param name="hotRect">Rectangle for hot area.</param>
 /// <param name="drawRect">Rectangle for draw area.</param>
 /// <param name="hint">Target hint which should be one of the edges.</param>
 /// <param name="workspace">Workspace instance that contains cell.</param>
 /// <param name="cell">Workspace cell as target for drop.</param>
 /// <param name="allowFlags">Only drop pages that have one of these flags defined.</param>
 public DragTargetWorkspaceCellEdge(Rectangle screenRect,
     Rectangle hotRect,
     Rectangle drawRect,
     DragTargetHint hint,
     KryptonWorkspace workspace,
     KryptonWorkspaceCell cell,
     KryptonPageFlags allowFlags)
     : base(screenRect, hotRect, drawRect, hint, workspace, allowFlags)
 {
     _cell = cell;
     _visibleNotDraggedPages = -1;
 }
示例#8
0
        private KryptonWorkspaceCell CreateCell(int numPages, string starSize)
        {
            // Create new cell instance
            KryptonWorkspaceCell cell = new KryptonWorkspaceCell();

            // Do we need to set the star sizing value?
            if (!string.IsNullOrEmpty(starSize))
                cell.StarSize = starSize;

            // Add requested number of pages
            for (int i = 0; i < numPages; i++)
                cell.Pages.Add(CreatePage());

            return cell;
        }
示例#9
0
        private void kryptonWorkspace_ActiveCellChanged(object sender, ActiveCellChangedEventArgs e)
        {
            // Ensure all but the newly selected cell have a lower profile appearance
            KryptonWorkspaceCell cell = kryptonWorkspace.FirstCell();

            while (cell != null)
            {
                if (e.NewCell != cell)
                {
                    cell.Bar.TabStyle = TabStyle.StandardProfile;
                }
                cell = kryptonWorkspace.NextCell(cell);
            }

            // Ensure the newly selected cell has a higher profile appearance
            if (e.NewCell != null)
            {
                e.NewCell.Bar.TabStyle = TabStyle.HighProfile;
            }
        }
示例#10
0
        /// <summary>
        /// Add a KryptonPage array to the currently active cell or create a new cell is no cell is currently active.
        /// </summary>
        /// <param name="pages">Array of KryptonPage instances to be added.</param>
        public void Append(KryptonPage[] pages)
        {
            // Demand that pages are not already present
            DemandPagesNotBePresent(pages);

            if (pages != null)
            {
                // If there is no active cell...
                KryptonWorkspaceCell cell = SpaceControl.ActiveCell;
                if (cell == null)
                {
                    // ...create a new cell and place at the end of the root collection
                    cell = new KryptonWorkspaceCell();
                    SpaceControl.Root.Children.Add(cell);
                }

                // Add all provided pages into the cell
                cell.Pages.AddRange(pages);
            }
        }
示例#11
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);
        }
示例#12
0
        /// <summary>
        /// Return an array of the visible pages that are inside the cell that contains the provided unique name.
        /// </summary>
        /// <param name="uniqueName">Unique name of page that is inside the target cell.</param>
        /// <returns>Array of page references.</returns>
        public KryptonPage[] CellVisiblePages(string uniqueName)
        {
            List <KryptonPage> pages = new List <KryptonPage>();

            // Grab the cell that contains the provided unique name
            KryptonWorkspaceCell cell = SpaceControl.CellForUniqueName(uniqueName);

            if (cell != null)
            {
                // Only interested in visible pages that are not placeholders
                foreach (KryptonPage page in cell.Pages)
                {
                    if (!(page is KryptonStorePage) && page.LastVisibleSet)
                    {
                        pages.Add(page);
                    }
                }
            }

            return(pages.ToArray());
        }
示例#13
0
        private string[] VisibleCloseableUniqueNames()
        {
            List <string>        uniqueNames = new List <string>();
            KryptonWorkspaceCell cell        = FloatspaceControl.FirstVisibleCell();

            while (cell != null)
            {
                // Create a list of all the visible page names in the floatspace that are allowed to be closed
                foreach (KryptonPage page in cell.Pages)
                {
                    if (page.LastVisibleSet && page.AreFlagsSet(KryptonPageFlags.DockingAllowClose))
                    {
                        uniqueNames.Add(page.UniqueName);
                    }
                }

                cell = FloatspaceControl.NextVisibleCell(cell);
            }

            return(uniqueNames.ToArray());
        }
示例#14
0
文件: Form1.cs 项目: zqh2945/Krypton
        private void Form1_Load(object sender, EventArgs e)
        {
            // Create three cells that each contain two pages
            KryptonWorkspaceCell cell1 = new KryptonWorkspaceCell();
            KryptonWorkspaceCell cell2 = new KryptonWorkspaceCell();
            KryptonWorkspaceCell cell3 = new KryptonWorkspaceCell();

            cell1.Pages.AddRange(new KryptonPage[] { CreatePage(), CreatePage() });
            cell2.Pages.AddRange(new KryptonPage[] { CreatePage(), CreatePage() });
            cell3.Pages.AddRange(new KryptonPage[] { CreatePage(), CreatePage() });

            // Create a vertical sequence that contains two of the pages
            KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence(Orientation.Vertical);

            sequence.Children.AddRange(new KryptonWorkspaceCell[] { cell2, cell3 });

            // Remove starting contents and add a cell with a sequence
            kryptonWorkspace.Root.Children.Clear();
            kryptonWorkspace.Root.Children.Add(cell1);
            kryptonWorkspace.Root.Children.Add(sequence);
        }
示例#15
0
        /// <summary>
        /// Propogates a page list request down the hierarchy of docking elements.
        /// </summary>
        /// <param name="state">Request that should result in pages collection being modified.</param>
        /// <param name="pages">Pages collection for modification by the docking elements.</param>
        public override void PropogatePageList(DockingPropogatePageList state, KryptonPageCollection pages)
        {
            switch (state)
            {
            case DockingPropogatePageList.All:
            case DockingPropogatePageList.Docked:
            case DockingPropogatePageList.Floating:
            case DockingPropogatePageList.Filler:
            {
                // If the request relevant to this space control?
                if ((state == DockingPropogatePageList.All) ||
                    ((state == DockingPropogatePageList.Docked) && (ClearStoreAction == DockingPropogateAction.ClearDockedStoredPages)) ||
                    ((state == DockingPropogatePageList.Floating) && (ClearStoreAction == DockingPropogateAction.ClearFloatingStoredPages)) ||
                    ((state == DockingPropogatePageList.Filler) && (ClearStoreAction == DockingPropogateAction.ClearFillerStoredPages)))
                {
                    // 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 add real pages and not placeholders
                            KryptonPage page = cell.Pages[i];
                            if ((page != null) && !(page is KryptonStorePage))
                            {
                                pages.Add(page);
                            }
                        }

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

            // Let base class perform standard processing
            base.PropogatePageList(state, pages);
        }
        private KryptonPage GetPageForFilename(string filename)
        {
            // Scan all cells
            KryptonWorkspaceCell cell = kryptonWorkspace.FirstCell();

            while (cell != null)
            {
                // Scan all pages in the cell
                foreach (KryptonPage page in cell.Pages)
                {
                    // Look for the matching filename
                    if (page.TextDescription.TrimEnd('*').Equals(filename))
                    {
                        return(page);
                    }
                }

                cell = kryptonWorkspace.NextCell(cell);
            }

            return(null);
        }
        /// <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="pages">Array of KryptonPage instances to be added.</param>
        public void CellInsert(KryptonWorkspaceCell cell, int index, KryptonPage[] pages)
        {
            // Demand that pages are not already present
            DemandPagesNotBePresent(pages);

            // Cannot insert to a null cell
            if (cell == null)
            {
                throw new ArgumentNullException(nameof(cell));
            }

            // Check that we actually contain the provided workspace cell
            KryptonWorkspaceCell checkCell = SpaceControl.FirstCell();

            while (checkCell != null)
            {
                if (checkCell == cell)
                {
                    break;
                }

                checkCell = SpaceControl.NextCell(checkCell);
            }

            if (cell != checkCell)
            {
                throw new ArgumentException("KryptonWorkspaceCell reference is not inside this workspace");
            }

            if (pages != null)
            {
                ObserveAutoHiddenSlideSize(pages);
                // Insert all the pages in sequence starting at the provided index
                foreach (KryptonPage page in pages)
                {
                    cell.Pages.Insert(index++, page);
                }
            }
        }
示例#18
0
        /// <summary>
        /// Raises the ActiveCellChanged event.
        /// </summary>
        /// <param name="e">An ActiveCellChangedEventArgs containing the event data.</param>
        protected override void OnActiveCellChanged(ActiveCellChangedEventArgs e)
        {
            // Ensure all but the newly selected cell have a lower profile appearance
            KryptonWorkspaceCell cell = FirstCell();

            while (cell != null)
            {
                if (e.NewCell != cell)
                {
                    cell.Bar.TabStyle = TabStyle.StandardProfile;
                }
                cell = NextCell(cell);
            }

            // Ensure the newly selected cell has a higher profile appearance
            if (e.NewCell != null)
            {
                e.NewCell.Bar.TabStyle = TabStyle.HighProfile;
            }

            base.OnActiveCellChanged(e);
        }
示例#19
0
        private void OnFocusUpdate(object sender, EventArgs e)
        {
            // Should we apply docking specific appearance changes to reflect changes in focus?
            if (ApplyDockingAppearance)
            {
                CheckPerformLayout(false);
                KryptonWorkspaceCell cell = FirstCell();
                while (cell != null)
                {
                    // Use focus dependant header style
                    if (cell.ContainsFocus)
                    {
                        // Change in cell focus state?
                        if (!_lookupCellState[cell].FocusState)
                        {
                            _lookupCellState[cell].FocusState = true;
                            cell.Header.HeaderStylePrimary    = HeaderStyle.DockActive;
                            OnCellGainsFocus(new WorkspaceCellEventArgs(cell));
                        }
                    }
                    else
                    {
                        // Change in cell focus state?
                        if (_lookupCellState[cell].FocusState)
                        {
                            _lookupCellState[cell].FocusState = false;
                            cell.Header.HeaderStylePrimary    = HeaderStyle.DockInactive;
                            OnCellLosesFocus(new WorkspaceCellEventArgs(cell));
                        }
                    }

                    cell = NextCell(cell);
                }
            }

            // Allow another focus update to occur
            _awaitingFocusUpdate = false;
        }
示例#20
0
        private void OnCellPrimaryHeaderDoubleClicked(object sender, EventArgs e)
        {
            // Should we apply docking specific change of focus when the primary header is clicked?
            if (ApplyDockingAppearance)
            {
                List <string> uniqueNames = new List <string>();

                // Create list of visible pages that are not placeholders
                KryptonWorkspaceCell cell = (KryptonWorkspaceCell)sender;
                foreach (KryptonPage page in cell.Pages)
                {
                    if (page.LastVisibleSet && !(page is KryptonStorePage))
                    {
                        uniqueNames.Add(page.UniqueName);
                    }
                }

                if (uniqueNames.Count > 0)
                {
                    OnPagesDoubleClicked(new UniqueNamesEventArgs(uniqueNames.ToArray()));
                }
            }
        }
        private void buttonRecentFile_Clicked(object sender, EventArgs e)
        {
            // Always remove the selected entry, we only put it back if we find it is valid
            KryptonRibbonRecentDoc recentDoc = (KryptonRibbonRecentDoc)sender;

            kryptonRibbon.RibbonAppButton.AppButtonRecentDocs.Remove(recentDoc);

            // Get the existing page that contains the selected filename
            KryptonPage page = GetPageForFilename(recentDoc.Text);

            if (page != null)
            {
                // Make this the top most 'recent doc' entry
                kryptonRibbon.RibbonAppButton.AppButtonRecentDocs.Insert(0, recentDoc);

                // Select the page and we are done
                KryptonWorkspaceCell cell = kryptonWorkspace.CellForPage(page);
                cell.SelectedPage           = page;
                kryptonWorkspace.ActiveCell = cell;
                return;
            }

            // If we get here then we need to try and load the document
            FileInfo fileInfo = new FileInfo(recentDoc.Text);

            if (fileInfo.Exists)
            {
                using (StreamReader reader = new StreamReader(fileInfo.FullName))
                {
                    // Make this the top most 'recent doc' entry
                    kryptonRibbon.RibbonAppButton.AppButtonRecentDocs.Insert(0, recentDoc);

                    // Add contents of the file as a new page associated with the file
                    AddNewMemo(fileInfo.Name, fileInfo.FullName, reader.ReadToEnd());
                }
            }
        }
        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);
        }
        private List <string> GetOpenFilenames()
        {
            List <String> filenames = new List <string>();

            // Scan all cells
            KryptonWorkspaceCell cell = kryptonWorkspace.FirstCell();

            while (cell != null)
            {
                // Scan all pages in the cell
                foreach (KryptonPage page in cell.Pages)
                {
                    // If the contents come from a file
                    if ((bool)page.Tag)
                    {
                        filenames.Add(page.TextDescription.TrimEnd('*'));
                    }
                }

                cell = kryptonWorkspace.NextCell(cell);
            }

            return(filenames);
        }
        private void buttonCloseAllMemo_Click(object sender, EventArgs e)
        {
            kryptonWorkspace.SuspendLayout();

            // Search each cell in turn
            KryptonWorkspaceCell cell = kryptonWorkspace.FirstCell();

            while (cell != null)
            {
                // Close each page within the cell (unless it returns the operation has been cancelled)
                for (int i = cell.Pages.Count - 1; i >= 0; i--)
                {
                    if (CloseMemoPage(cell.Pages[i]))
                    {
                        kryptonWorkspace.ResumeLayout();
                        return;
                    }
                }

                cell = kryptonWorkspace.NextCell(cell);
            }

            kryptonWorkspace.ResumeLayout();
        }
        protected override void OnActiveCellChanged(ActiveCellChangedEventArgs e)
        {
            base.OnActiveCellChanged(e);

            // Ensure all but the newly selected cell have a lower profile appearance
            KryptonWorkspaceCell cell = FirstCell();

            while (cell != null)
            {
                if (e.NewCell != cell)
                {
                    cell.Bar.TabStyle       = CellBarTabStyle;
                    cell.Bar.TabBorderStyle = CellBarTabBorderStyle;
                }
                cell = NextCell(cell);
            }

            // Ensure the newly selected cell has a lower profile appearance
            if (e.NewCell != null)
            {
                e.NewCell.Bar.TabStyle       = CellBarTabStyle;
                e.NewCell.Bar.TabBorderStyle = CellBarTabBorderStyle;
            }
        }
示例#26
0
        /// <summary>
        /// Detach an existing cell.
        /// </summary>
        /// <param name="cell">Cell being removed from the control.</param>
        protected override void ExistingCellDetach(KryptonWorkspaceCell cell)
        {
            // Grab the per-cell cached state
            CachedCellState cellState = _lookupCellState[cell];

            // Remove all those event hooks used to monitor focus changes
            FocusMonitorControl(cell, false);

            // Unhook from events so the cell can be garbage colleced
            cell.ShowContextMenu            -= new EventHandler <ShowContextMenuArgs>(OnCellShowContextMenu);
            cell.SelectedPageChanged        -= new EventHandler(OnCellSelectedPageChanged);
            cell.PrimaryHeaderLeftClicked   -= new EventHandler(OnCellPrimaryHeaderLeftClicked);
            cell.PrimaryHeaderRightClicked  -= new EventHandler(OnCellPrimaryHeaderRightClicked);
            cell.PrimaryHeaderDoubleClicked -= new EventHandler(OnCellPrimaryHeaderDoubleClicked);
            cell.TabDoubleClicked           -= new EventHandler <KryptonPageEventArgs>(OnCellTabDoubleClicked);
            cell.TabVisibleCountChanged     -= new EventHandler(OnCellTabVisibleCountChanged);
            cell.Pages.Inserting            -= new TypedHandler <KryptonPage>(OnCellPagesInserting);

            // Remove the per-cell cached state
            _lookupCellState.Remove(cell);

            // Let base class unhook from events and reverse other operations
            base.ExistingCellDetach(cell);
        }
示例#27
0
        private void OnCellPrimaryHeaderRightClicked(object sender, EventArgs e)
        {
            // Should we apply docking specific change of focus when the primary header is clicked?
            if (ApplyDockingAppearance)
            {
                KryptonWorkspaceCell cell = (KryptonWorkspaceCell)sender;
                if (cell.SelectedPage != null)
                {
                    // Set the focus into the active page
                    cell.SelectedPage.SelectNextControl(cell.SelectedPage, true, true, true, false);

                    // Create and populate a context menu with the drop down set of options
                    KryptonContextMenu      kcm  = new KryptonContextMenu();
                    CancelDropDownEventArgs args = new CancelDropDownEventArgs(kcm, cell.SelectedPage);
                    OnPageDropDownClicked(args);

                    // Do we need to show a context menu
                    if (!args.Cancel && CommonHelper.ValidKryptonContextMenu(args.KryptonContextMenu))
                    {
                        args.KryptonContextMenu.Show(this, Control.MousePosition);
                    }
                }
            }
        }
        /// <summary>
        /// Add a KryptonPage array into an existing cell.
        /// </summary>
        /// <param name="cell">Reference to existing workspace cell.</param>
        /// <param name="pages">Array of KryptonPage instances to be added.</param>
        public void CellAppend(KryptonWorkspaceCell cell, KryptonPage[] pages)
        {
            // Demand that pages are not already present
            DemandPagesNotBePresent(pages);

            // Cannot insert to a null cell
            if (cell == null)
            {
                throw new ArgumentNullException(nameof(cell));
            }

            // Check that we actually contain the provided workspace cell
            KryptonWorkspaceCell checkCell = SpaceControl.FirstCell();

            while (checkCell != null)
            {
                if (checkCell == cell)
                {
                    break;
                }

                checkCell = SpaceControl.NextCell(checkCell);
            }

            if (cell != checkCell)
            {
                throw new ArgumentException("KryptonWorkspaceCell reference is not inside this workspace");
            }

            // Append all the pages to end of the cell pages collection
            if (pages != null)
            {
                ObserveAutoHiddenSlideSize(pages);
                cell.Pages.AddRange(pages);
            }
        }
示例#29
0
 /// <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 });
 }
示例#30
0
        /// <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
            KryptonWorkspaceSequence parent = Cell.WorkspaceParent as KryptonWorkspaceSequence;
            if (parent != null)
            {
                // 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;
                        if (parent.Orientation == Orientation.Horizontal)
                            sequenceOrientation = Orientation.Vertical;
                        else
                            sequenceOrientation = 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 transfered 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;
        }
示例#31
0
 /// <summary>
 /// Initialize a new instance of the WorkspaceCellEventArgs class.
 /// </summary>
 /// <param name="cell">Workspace cell associated with the event.</param>
 public WorkspaceCellEventArgs(KryptonWorkspaceCell cell) => Cell = cell;
示例#32
0
 /// <summary>
 /// Raises the type specific cell adding event determinated by the derived class.
 /// </summary>
 /// <param name="cell">Referecence to new cell being added.</param>
 protected abstract void RaiseCellAdding(KryptonWorkspaceCell cell);
示例#33
0
        /// <summary>
        /// Update the cell settings to reflect the provided page, cell and page flag settings.
        /// </summary>
        /// <param name="cell">Reference to workspace cell that needs updating.</param>
        /// <param name="cellState">Reference to cell specific cached state.</param>
        protected virtual void UpdateCellActions(KryptonWorkspaceCell cell, CachedCellState cellState)
        {
            if (ApplyDockingDropDownAction)
            {
                // First time around we need to create the pin button spec
                if (cellState.DropDownButtonSpec == null)
                {
                    cellState.DropDownButtonSpec                             = new ButtonSpecNavigator();
                    cellState.DropDownButtonSpec.Type                        = PaletteButtonSpecStyle.DropDown;
                    cellState.DropDownButtonSpec.ToolTipTitle                = DropDownTooltip;
                    cellState.DropDownButtonSpec.KryptonContextMenu          = new KryptonContextMenu();
                    cellState.DropDownButtonSpec.KryptonContextMenu.Opening += new CancelEventHandler(OnCellDropDownOpening);
                    cell.Button.ButtonSpecs.Add(cellState.DropDownButtonSpec);
                }

                if (cell.SelectedPage == null)
                {
                    cellState.DropDownButtonSpec.Visible = false;
                }
                else
                {
                    cellState.DropDownButtonSpec.Visible = cell.SelectedPage.AreFlagsSet(KryptonPageFlags.DockingAllowDropDown);
                }
            }

            if (ApplyDockingPinAction)
            {
                // First time around we need to create the pin button spec
                if (cellState.PinButtonSpec == null)
                {
                    cellState.PinButtonSpec              = new ButtonSpecNavigator();
                    cellState.PinButtonSpec.Type         = (AutoHiddenHost ? PaletteButtonSpecStyle.PinHorizontal : PaletteButtonSpecStyle.PinVertical);
                    cellState.PinButtonSpec.ToolTipTitle = PinTooltip;
                    cellState.PinButtonSpec.Click       += new EventHandler(OnCellAutoHiddenAction);
                    cell.Button.ButtonSpecs.Add(cellState.PinButtonSpec);
                }

                if (cell.SelectedPage == null)
                {
                    cellState.PinButtonSpec.Visible = false;
                }
                else
                {
                    if (AutoHiddenHost)
                    {
                        cellState.PinButtonSpec.Visible = cell.SelectedPage.AreFlagsSet(KryptonPageFlags.DockingAllowDocked);
                    }
                    else
                    {
                        cellState.PinButtonSpec.Visible = cell.SelectedPage.AreFlagsSet(KryptonPageFlags.DockingAllowAutoHidden);
                    }
                }
            }

            if (ApplyDockingCloseAction)
            {
                // First time around we need to create the close button spec
                if (cellState.CloseButtonSpec == null)
                {
                    cellState.CloseButtonSpec              = new ButtonSpecNavigator();
                    cellState.CloseButtonSpec.Type         = PaletteButtonSpecStyle.Close;
                    cellState.CloseButtonSpec.ToolTipTitle = CloseTooltip;
                    cellState.CloseButtonSpec.Click       += new EventHandler(OnCellCloseAction);
                    cell.Button.ButtonSpecs.Add(cellState.CloseButtonSpec);
                }

                if (cell.SelectedPage == null)
                {
                    cellState.CloseButtonSpec.Visible = false;
                }
                else
                {
                    cellState.CloseButtonSpec.Visible = cell.SelectedPage.AreFlagsSet(KryptonPageFlags.DockingAllowClose);
                }
            }
        }
示例#34
0
        /// <summary>
        /// Initialize a new cell.
        /// </summary>
        /// <param name="cell">Cell being added to the control.</param>
        protected override void NewCellInitialize(KryptonWorkspaceCell cell)
        {
            // Let base class perform event hooking and customizations
            base.NewCellInitialize(cell);

            // Should be apply docking specific appearance settings?
            if (ApplyDockingAppearance)
            {
                if (cell.Pages.VisibleCount == 1)
                {
                    cell.NavigatorMode = NavigatorMode.HeaderGroup;
                }
                else
                {
                    cell.NavigatorMode = NavigatorMode.HeaderGroupTab;
                }

                cell.Bar.BarMultiline                    = BarMultiline.Shrinkline;
                cell.Bar.BarOrientation                  = VisualOrientation.Bottom;
                cell.Bar.TabBorderStyle                  = TabBorderStyle.DockOutsize;
                cell.Bar.TabStyle                        = TabStyle.Dock;
                cell.Button.ButtonDisplayLogic           = ButtonDisplayLogic.None;
                cell.Button.CloseButtonDisplay           = ButtonDisplay.Hide;
                cell.Header.HeaderStylePrimary           = HeaderStyle.DockInactive;
                cell.Header.HeaderVisibleSecondary       = false;
                cell.Header.HeaderValuesPrimary.MapImage = MapKryptonPageImage.None;
                cell.ToolTips.AllowButtonSpecToolTips    = true;
            }

            // Hook into cell specific events
            cell.ShowContextMenu            += new EventHandler <ShowContextMenuArgs>(OnCellShowContextMenu);
            cell.SelectedPageChanged        += new EventHandler(OnCellSelectedPageChanged);
            cell.PrimaryHeaderLeftClicked   += new EventHandler(OnCellPrimaryHeaderLeftClicked);
            cell.PrimaryHeaderRightClicked  += new EventHandler(OnCellPrimaryHeaderRightClicked);
            cell.PrimaryHeaderDoubleClicked += new EventHandler(OnCellPrimaryHeaderDoubleClicked);
            cell.TabDoubleClicked           += new EventHandler <KryptonPageEventArgs>(OnCellTabDoubleClicked);
            cell.TabVisibleCountChanged     += new EventHandler(OnCellTabVisibleCountChanged);
            cell.Pages.Inserting            += new TypedHandler <KryptonPage>(OnCellPagesInserting);

            // Create and store per-cell cached state
            CachedCellState cellState = new CachedCellState();

            cellState.Cell = cell;
            _lookupCellState.Add(cell, cellState);
            UpdateCellActions(cell, cellState);

            // We need to know when the focus enters/leaves a cell so styles can be updated
            FocusMonitorControl(cell, true);

            // If there is already a selected page then ensure we process its selected state
            if (cell.SelectedPage != null)
            {
                OnCellSelectedPageChanged(cell, EventArgs.Empty);
            }

            // If the cell already have pages then raise inserting events for those pages
            if (cell.Pages.Count > 0)
            {
                for (int i = cell.Pages.Count - 1; i >= 0; i--)
                {
                    OnCellPageInserting(new KryptonPageEventArgs(cell.Pages[i], i));
                }
            }
        }
示例#35
0
        private void buttonFloatingComplex_Click(object sender, EventArgs e)
        {
            // Add single page to a new floating window
            KryptonDockingFloatingWindow window = kryptonDockingManager.AddFloatingWindow("Floating",
                                                                                          new KryptonPage[] { NewInput() },
                                                                                          new Size(500, 400));

            // Create a sequence that contains two cells, with a page in each cell
            KryptonWorkspaceSequence seq = new KryptonWorkspaceSequence(Orientation.Vertical);
            KryptonWorkspaceCell cell1 = new KryptonWorkspaceCell();
            KryptonWorkspaceCell cell2 = new KryptonWorkspaceCell();
            seq.Children.AddRange(new Component[] { cell1, cell2 });
            cell1.Pages.Add(NewPropertyGrid());
            cell2.Pages.Add(NewDocument());

            // Add new sequence into the floating window
            window.FloatspaceElement.FloatspaceControl.Root.Children.Add(seq);
        }
示例#36
0
        private void buttonDocumentSingle_Click(object sender, EventArgs e)
        {
            // Get access to current active cell or create new cell if none are present
            KryptonWorkspaceCell cell = kryptonDockableWorkspace.ActiveCell;
            if (cell == null)
            {
                cell = new KryptonWorkspaceCell();
                kryptonDockableWorkspace.Root.Children.Add(cell);
            }

            // Create new document to be added into workspace
            KryptonPage page = NewDocument();
            cell.Pages.Add(page);

            // Make the new page the selected page
            cell.SelectedPage = page;
        }
示例#37
0
 /// <summary>
 /// Raises the type specific cell adding event determinated by the derived class.
 /// </summary>
 /// <param name="cell">Referecence to new cell being added.</param>
 protected abstract void RaiseCellAdding(KryptonWorkspaceCell cell);
        /// <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;
        }
 /// <summary>
 /// Initialize a new instance of the CellDragCancelEventArgs class.
 /// </summary>
 /// <param name="e">Event to upgrade to this event.</param>
 /// <param name="cell">Workspace cell associated with pages.</param>
 public CellDragCancelEventArgs(PageDragCancelEventArgs e,
                                KryptonWorkspaceCell cell)
     : base(e.ScreenPoint, e.ElementOffset, e.Control, e.Pages)
 {
     _cell = cell;
 }
示例#40
0
        /// <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="pages">Array of KryptonPage instances to be added.</param>
        public void CellInsert(KryptonWorkspaceCell cell, int index, KryptonPage[] pages)
        {
            // Demand that pages are not already present
            DemandPagesNotBePresent(pages);

            // Cannot insert to a null cell
            if (cell == null)
                throw new ArgumentNullException("cell");

            // Check that we actually contain the provided workspace cell
            KryptonWorkspaceCell checkCell = SpaceControl.FirstCell();
            while (checkCell != null)
            {
                if (checkCell == cell)
                    break;

                checkCell = SpaceControl.NextCell(checkCell);
            }

            if (cell != checkCell)
                throw new ArgumentException("KryptonWorkspaceCell reference is not inside this workspace");

            if (pages != null)
            {
                // Insert all the pages in sequence starting at the provided index
                foreach (KryptonPage page in pages)
                    cell.Pages.Insert(index++, page);
            }
        }
示例#41
0
        /// <summary>
        /// Process the drag pages in the context of a target navigator.
        /// </summary>
        /// <param name="workspace">Target workspace instance.</param>
        /// <param name="target">Target workspace cell instance.</param>
        /// <param name="data">Dragged page data.</param>
        /// <returns>Last page to be transferred.</returns>
        protected KryptonPage ProcessDragEndData(KryptonWorkspace workspace,
                                                 KryptonWorkspaceCell target,
                                                 PageDragEndData data)
        {
            KryptonPage ret = null;

            // Add each source page to the target
            foreach (KryptonPage page in data.Pages)
            {
                // Only add the page if one of the allow flags is set
                if ((page.Flags & (int)AllowFlags) != 0)
                {
                    // Use event to allow decision on if the page should be dropped
                    // (or even swap the page for a different page to be dropped)
                    PageDropEventArgs e = new PageDropEventArgs(page);
                    workspace.OnPageDrop(e);

                    if (!e.Cancel && (e.Page != null))
                    {
                        target.Pages.Add(e.Page);
                        ret = e.Page;
                    }
                }
            }

            return ret;
        }
示例#42
0
 /// <summary>
 /// Raises the type specific cell removed event determinated by the derived class.
 /// </summary>
 /// <param name="cell">Referecence to an existing cell being removed.</param>
 protected override void RaiseCellRemoved(KryptonWorkspaceCell cell)
 {
     // Generate event so the dockspace cell customization can be reversed.
     KryptonDockingManager dockingManager = DockingManager;
     if (dockingManager != null)
     {
         DockspaceCellEventArgs args = new DockspaceCellEventArgs(DockspaceControl, this, cell);
         dockingManager.RaiseDockspaceCellRemoved(args);
     }
 }
示例#43
0
 private void buttonDocumentTabbed_Click(object sender, EventArgs e)
 {
     // Add a new cell with three pages into the root sequence of the workspace
     KryptonWorkspaceCell cell = new KryptonWorkspaceCell();
     cell.Pages.AddRange(new KryptonPage[] { NewDocument(), NewDocument(), NewDocument() });
     kryptonDockableWorkspace.Root.Children.Add(cell);
 }
示例#44
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);
        }
示例#45
0
        private void UpdateCell(KryptonWorkspaceCell cell)
        {
            NavigatorMode newMode = NavigatorMode.BarTabGroup;

            if (checkSetDocMode.CheckedButton == buttonTabs)
                newMode = NavigatorMode.BarTabGroup;
            else if (checkSetDocMode.CheckedButton == buttonRibbonTabs)
                newMode = NavigatorMode.BarRibbonTabGroup;
            else if (checkSetDocMode.CheckedButton == buttonCheckButtons)
                newMode = NavigatorMode.BarCheckButtonGroupOutside;
            else if (checkSetDocMode.CheckedButton == buttonHeaderGroup)
                newMode = NavigatorMode.HeaderGroup;
            else if (checkSetDocMode.CheckedButton == buttonHeaderBar)
                newMode = NavigatorMode.HeaderBarCheckButtonHeaderGroup;
            else if (checkSetDocMode.CheckedButton == buttonStack)
                newMode = NavigatorMode.StackCheckButtonGroup;

            cell.NavigatorMode = newMode;

            // Set mode specific properties
            switch (newMode)
            {
                case NavigatorMode.BarRibbonTabGroup:
                case NavigatorMode.BarRibbonTabOnly:
                    cell.PageBackStyle = PaletteBackStyle.ControlRibbon;
                    cell.Group.GroupBackStyle = PaletteBackStyle.ControlRibbon;
                    cell.Group.GroupBorderStyle = PaletteBorderStyle.ControlRibbon;
                    break;
                default:
                    cell.PageBackStyle = PaletteBackStyle.ControlClient;
                    cell.Group.GroupBackStyle = PaletteBackStyle.ControlClient;
                    cell.Group.GroupBorderStyle = PaletteBorderStyle.ControlClient;
                    break;
            }
        }
示例#46
0
 /// <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 });
 }
示例#47
0
        /// <summary>
        /// Add a KryptonPage array into an existing cell.
        /// </summary>
        /// <param name="cell">Reference to existing workspace cell.</param>
        /// <param name="pages">Array of KryptonPage instances to be added.</param>
        public void CellAppend(KryptonWorkspaceCell cell, KryptonPage[] pages)
        {
            // Demand that pages are not already present
            DemandPagesNotBePresent(pages);

            // Cannot insert to a null cell
            if (cell == null)
                throw new ArgumentNullException("cell");

            // Check that we actually contain the provided workspace cell
            KryptonWorkspaceCell checkCell = SpaceControl.FirstCell();
            while (checkCell != null)
            {
                if (checkCell == cell)
                    break;

                checkCell = SpaceControl.NextCell(checkCell);
            }

            if (cell != checkCell)
                throw new ArgumentException("KryptonWorkspaceCell reference is not inside this workspace");

            // Append all the pages to end of the cell pages collection
            if (pages != null)
                cell.Pages.AddRange(pages);
        }
 /// <summary>
 /// Raises the type specific cell adding event determinated by the derived class.
 /// </summary>
 /// <param name="cell">Referecence to new cell being added.</param>
 protected override void RaiseCellAdding(KryptonWorkspaceCell cell)
 {
     // Generate event so the floatspace cell customization can be performed.
     KryptonDockingManager dockingManager = DockingManager;
     if (dockingManager != null)
     {
         FloatspaceCellEventArgs args = new FloatspaceCellEventArgs(FloatspaceControl, this, cell);
         dockingManager.RaiseFloatspaceCellAdding(args);
     }
 }
 /// <summary>
 /// Initialize a new instance of the ActiveCellChangedEventArgs class.
 /// </summary>
 /// <param name="oldCell">Previous active cell value.</param>
 /// <param name="newCell">New active cell value.</param>
 public ActiveCellChangedEventArgs(KryptonWorkspaceCell oldCell,
                                   KryptonWorkspaceCell newCell)
 {
     _oldCell = oldCell;
     _newCell = newCell;
 }
示例#50
0
 private void UpdateCell(KryptonWorkspaceCell cell)
 {
     cell.NavigatorMode = _mode;
 }
 /// <summary>
 /// Initialize a new instance of the WorkspaceCellEventArgs class.
 /// </summary>
 /// <param name="cell">Workspace cell associated with the event.</param>
 public WorkspaceCellEventArgs(KryptonWorkspaceCell cell)
 {
     _cell = cell;
 }
示例#52
0
        /// <summary>
        /// Release unmanaged and optionally managed resources.
        /// </summary>
        /// <param name="disposing">Called from Dispose method.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
                _cell = null;

            base.Dispose(disposing);
        }
        /// <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);
        }
示例#54
0
 /// <summary>
 /// Raises the type specific cell removed event determinated by the derived class.
 /// </summary>
 /// <param name="cell">Referecence to an existing cell being removed.</param>
 protected abstract void RaiseCellRemoved(KryptonWorkspaceCell cell);
示例#55
0
        /// <summary>
        /// Add a KryptonPage array to the currently active cell or create a new cell is no cell is currently active.
        /// </summary>
        /// <param name="pages">Array of KryptonPage instances to be added.</param>
        public void Append(KryptonPage[] pages)
        {
            // Demand that pages are not already present
            DemandPagesNotBePresent(pages);

            if (pages != null)
            {
                // If there is no active cell...
                KryptonWorkspaceCell cell = SpaceControl.ActiveCell;
                if (cell == null)
                {
                    // ...create a new cell and place at the end of the root collection
                    cell = new KryptonWorkspaceCell();
                    SpaceControl.Root.Children.Add(cell);
                }

                // Add all provided pages into the cell
                cell.Pages.AddRange(pages);
            }
        }
示例#56
0
        /// <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);
        }
示例#57
0
 /// <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 });
 }
示例#58
0
 /// <summary>
 /// Raises the type specific cell removed event determinated by the derived class.
 /// </summary>
 /// <param name="cell">Referecence to an existing cell being removed.</param>
 protected abstract void RaiseCellRemoved(KryptonWorkspaceCell cell);
示例#59
0
 /// <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 });
 }
示例#60
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Create three cells that each contain two pages
            KryptonWorkspaceCell cell1 = new KryptonWorkspaceCell();
            KryptonWorkspaceCell cell2 = new KryptonWorkspaceCell();
            KryptonWorkspaceCell cell3 = new KryptonWorkspaceCell();
            cell1.Pages.AddRange(new KryptonPage[] { CreatePage(), CreatePage() });
            cell2.Pages.AddRange(new KryptonPage[] { CreatePage(), CreatePage() });
            cell3.Pages.AddRange(new KryptonPage[] { CreatePage(), CreatePage() });

            // Create a vertical sequence that contains two of the pages
            KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence(Orientation.Vertical);
            sequence.Children.AddRange(new KryptonWorkspaceCell[] { cell2, cell3 });

            // Remove starting contents and add a cell with a sequence
            kryptonWorkspace.Root.Children.Clear();
            kryptonWorkspace.Root.Children.Add(cell1);
            kryptonWorkspace.Root.Children.Add(sequence);
        }