/// <summary>
        /// Occurs when the component is being removed from the designer.
        /// </summary>
        /// <param name="sender">Source of the event.</param>
        /// <param name="e">A ComponentEventArgs containing event data.</param>
        protected override void OnComponentRemoving(object sender, ComponentEventArgs e)
        {
            // If our control is being removed
            if (e.Component == Navigator)
            {
                // If this workspace cell is inside a parent
                KryptonWorkspaceCell cell = (KryptonWorkspaceCell)Navigator;
                if (cell.WorkspaceParent != null)
                {
                    // Cell an only be inside a workspace sequence
                    KryptonWorkspaceSequence sequence = (KryptonWorkspaceSequence)cell.WorkspaceParent;
                    if (sequence != null)
                    {
                        // Remove the cell from the parent
                        sequence.Children.Remove(cell);
                    }
                }
            }

            base.OnComponentRemoving(sender, e);
        }
示例#2
0
        private void CompactRemoveEmptyCells(CompactFlags flags)
        {
            if ((flags & CompactFlags.RemoveEmptyCells) == CompactFlags.RemoveEmptyCells)
            {
                // Search for child cell items
                for (int i = Children.Count - 1; i >= 0; i--)
                {
                    // If a cell and that cell does not have any pages
                    KryptonWorkspaceCell cell = Children[i] as KryptonWorkspaceCell;
                    if ((cell != null) && (cell.Pages.Count == 0))
                    {
                        Children.RemoveAt(i);

                        // If the cell is not inside a controls collection then we need to dispose of it here
                        // because the layout code will never try and dispose on remove from controls collection
                        // as it is not inside the controls collection
                        if ((cell.Parent == null) && (cell.DisposeOnRemove))
                        {
                            cell.Dispose();
                        }
                    }
                }
            }
        }
示例#3
0
 /// <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;
 }
示例#4
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
            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);
        }
示例#5
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)
        {
            // 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
                    Workspace.Root.Orientation = Workspace.Root.Orientation == Orientation.Horizontal
                        ? Orientation.Vertical
                        : 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
                // 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);
        }
示例#6
0
 /// <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;
 }
示例#7
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;
 }