Inheritance: KryptonDockingSpace
コード例 #1
0
        private void OnDockspaceSeparatorMoveRect(object sender, SplitterMoveRectMenuArgs e)
        {
            // Cast to correct type and grab associated dockspace element
            KryptonDockspaceSeparator separatorControl = (KryptonDockspaceSeparator)sender;
            KryptonDockingDockspace   dockspaceElement = _lookupSeparator[separatorControl];

            // Events are generated from the parent docking manager
            KryptonDockingManager dockingManager = DockingManager;

            if (dockingManager != null)
            {
                // Allow the movement rectangle to be modified by event handlers
                DockspaceSeparatorResizeEventArgs dockspaceResizeRectArgs = new DockspaceSeparatorResizeEventArgs(separatorControl, dockspaceElement, FindMovementRect(dockspaceElement, e.MoveRect));
                dockingManager.RaiseDockspaceSeparatorResize(dockspaceResizeRectArgs);
                e.MoveRect = dockspaceResizeRectArgs.ResizeRect;
            }

            KryptonDockingControl c = GetParentType(typeof(KryptonDockingControl)) as KryptonDockingControl;

            if (c != null)
            {
                // Inform our owning control that an update is starting, this will prevent drawing of the control area
                c.PropogateAction(DockingPropogateAction.StartUpdate, (string[])null);
                _update = true;
            }
        }
コード例 #2
0
 /// <summary>
 /// Initialize a new instance of the DockspaceSeparatorResizeEventArgs class.
 /// </summary>
 /// <param name="separator">Reference to separator control instance.</param>
 /// <param name="element">Reference to dockspace docking element that is managing the separator.</param>
 /// <param name="resizeRect">Initial resizing rectangle.</param>
 public DockspaceSeparatorResizeEventArgs(KryptonSeparator separator,
                                          KryptonDockingDockspace element,
                                          Rectangle resizeRect)
     : base(separator, element)
 {
     ResizeRect = resizeRect;
 }
コード例 #3
0
        private void OnDockspaceSeparatorMoved(object sender, SplitterEventArgs e)
        {
            // Cast to correct type and grab associated dockspace element
            KryptonDockspaceSeparator separatorControl = (KryptonDockspaceSeparator)sender;
            KryptonDockingDockspace   dockspaceElement = _lookupSeparator[separatorControl];

            // Update with delta change
            switch (Edge)
            {
            case DockingEdge.Left:
                dockspaceElement.DockspaceControl.Width += e.SplitX;
                break;

            case DockingEdge.Right:
                dockspaceElement.DockspaceControl.Width -= e.SplitX;
                break;

            case DockingEdge.Top:
                dockspaceElement.DockspaceControl.Height += e.SplitY;
                break;

            case DockingEdge.Bottom:
                dockspaceElement.DockspaceControl.Height -= e.SplitY;
                break;
            }

            if (_update)
            {
                // Inform our owning control that the update has ended, allowing the client area to be drawn
                KryptonDockingControl c = GetParentType(typeof(KryptonDockingControl)) as KryptonDockingControl;
                c.PropogateAction(DockingPropogateAction.EndUpdate, (string[])null);
                _update = false;
            }
        }
コード例 #4
0
 /// <summary>
 /// Initialize a new instance of the DockspaceSeparatorResizeEventArgs class.
 /// </summary>
 /// <param name="separator">Reference to separator control instance.</param>
 /// <param name="element">Reference to dockspace docking element that is managing the separator.</param>
 /// <param name="resizeRect">Initial resizing rectangle.</param>
 public DockspaceSeparatorResizeEventArgs(KryptonSeparator separator,
                                          KryptonDockingDockspace element,
                                          Rectangle resizeRect)
     : base(separator, element)
 {
     _resizeRect = resizeRect;
 }
 /// <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)
 {
     DockspaceControl = dockspace;
     DockspaceElement = element;
     CellControl      = cell;
 }
コード例 #6
0
 /// <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;
 }
コード例 #7
0
 /// <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;
 }
コード例 #8
0
        private void OnDockingDockspaceHasVisibleCells(object sender, EventArgs e)
        {
            // Cast to correct type and grab associated separator control
            KryptonDockingDockspace   dockspaceElement = (KryptonDockingDockspace)sender;
            KryptonDockspaceSeparator separatorControl = _lookupDockspace[dockspaceElement];

            // Now have a visible cell so we show the controls
            dockspaceElement.DockspaceControl.Visible = true;
            separatorControl.Visible = true;
        }
コード例 #9
0
        private KryptonDockingDockspace CreateAndInsertDockspace(int index, string name, Size size)
        {
            // Create a dockspace separator do the dockspace can be resized
            KryptonDockspaceSeparator separatorControl = new KryptonDockspaceSeparator(Edge, false);

            separatorControl.SplitterMoveRect += OnDockspaceSeparatorMoveRect;
            separatorControl.SplitterMoved    += OnDockspaceSeparatorMoved;
            separatorControl.SplitterNotMoved += OnDockspaceSeparatorNotMoved;
            separatorControl.Disposed         += OnDockspaceSeparatorDisposed;

            // Create and add the dockspace to the collection
            KryptonDockingDockspace dockspaceElement = new KryptonDockingDockspace(name, Edge, size);

            dockspaceElement.HasVisibleCells   += OnDockingDockspaceHasVisibleCells;
            dockspaceElement.HasNoVisibleCells += OnDockingDockspaceHasNoVisibleCells;
            dockspaceElement.Disposed          += OnDockingDockspaceDisposed;
            InternalInsert(index, dockspaceElement);

            // Create lookup associations
            _lookupSeparator.Add(separatorControl, dockspaceElement);
            _lookupDockspace.Add(dockspaceElement, separatorControl);

            // Events are generated from the parent docking manager
            KryptonDockingManager dockingManager = DockingManager;

            if (dockingManager != null)
            {
                // Allow the dockspace and dockspace separator to be customized by event handlers
                DockspaceEventArgs          spaceArgs     = new DockspaceEventArgs(dockspaceElement.DockspaceControl, dockspaceElement);
                DockspaceSeparatorEventArgs separatorArgs = new DockspaceSeparatorEventArgs(separatorControl, dockspaceElement);
                dockingManager.RaiseDockspaceAdding(spaceArgs);
                dockingManager.RaiseDockspaceSeparatorAdding(separatorArgs);
            }

            if (index == 0)
            {
                InsertAtOuterMost(separatorControl);
                InsertAtOuterMost(dockspaceElement.DockspaceControl);
            }
            else if (index == (Count - 1))
            {
                InsertAtInnerMost(dockspaceElement.DockspaceControl);
                InsertAtInnerMost(separatorControl);
            }
            else
            {
                KryptonDockingDockspace target = this[index + 1] as KryptonDockingDockspace;
                InsertAfter(dockspaceElement.DockspaceControl, target.DockspaceControl);
                InsertAfter(separatorControl, target.DockspaceControl);
            }

            return(dockspaceElement);
        }
コード例 #10
0
        private void OnDockingDockspaceDisposed(object sender, EventArgs e)
        {
            // Cast to correct type and unhook event handlers so garbage collection can occur
            KryptonDockingDockspace dockspaceElement = (KryptonDockingDockspace)sender;

            dockspaceElement.HasVisibleCells   -= OnDockingDockspaceHasVisibleCells;
            dockspaceElement.HasNoVisibleCells -= OnDockingDockspaceHasNoVisibleCells;
            dockspaceElement.Disposed          -= OnDockingDockspaceDisposed;

            // Remove the element from our child collection as it is no longer valid
            InternalRemove(dockspaceElement);

            // Ensure the matching separator is also disposed
            KryptonDockspaceSeparator separatorControl = _lookupDockspace[dockspaceElement];

            if (!separatorControl.IsDisposed)
            {
                separatorControl.Dispose();
            }

            // Remove lookup association
            _lookupDockspace.Remove(dockspaceElement);
        }
コード例 #11
0
        /// <summary>
        /// Perform docking element specific actions for loading a child xml.
        /// </summary>
        /// <param name="xmlReader">Xml reader object.</param>
        /// <param name="pages">Collection of available pages.</param>
        /// <param name="child">Optional reference to existing child docking element.</param>
        protected override void LoadChildDockingElement(XmlReader xmlReader,
                                                        KryptonPageCollection pages,
                                                        IDockingElement child)
        {
            if (child != null)
            {
                child.LoadElementFromXml(xmlReader, pages);
            }
            else
            {
                Size   dockspaceSize = _defaultDockspaceSize;
                string elementSize   = xmlReader.GetAttribute("S");

                // Cache the loading size
                if (!string.IsNullOrEmpty(elementSize))
                {
                    dockspaceSize = CommonHelper.StringToSize(elementSize);
                }

                // Create a new dockspace and then reload it
                KryptonDockingDockspace dockspace = AppendDockspace(xmlReader.GetAttribute("N"), dockspaceSize);
                dockspace.LoadElementFromXml(xmlReader, pages);
            }
        }
コード例 #12
0
 /// <summary>
 /// Initialize a new instance of the DockspaceEventArgs class.
 /// </summary>
 /// <param name="dockspace">Reference to new dockspace control instance.</param>
 /// <param name="element">Reference to docking dockspace element that is managing the dockspace control.</param>
 public DockspaceEventArgs(KryptonDockspace dockspace,
                           KryptonDockingDockspace element)
 {
     DockspaceControl = dockspace;
     DockspaceElement = element;
 }
コード例 #13
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)
        {
            // Find our docking edge
            KryptonDockingEdge dockingEdge = null;

            switch (Edge)
            {
            case VisualOrientation.Left:
                dockingEdge = ControlElement["Left"] as KryptonDockingEdge;
                break;

            case VisualOrientation.Right:
                dockingEdge = ControlElement["Right"] as KryptonDockingEdge;
                break;

            case VisualOrientation.Top:
                dockingEdge = ControlElement["Top"] as KryptonDockingEdge;
                break;

            case VisualOrientation.Bottom:
                dockingEdge = ControlElement["Bottom"] as KryptonDockingEdge;
                break;
            }

            if (dockingEdge != null)
            {
                // Find the docked edge
                KryptonDockingEdgeDocked dockedEdge = dockingEdge["Docked"] as KryptonDockingEdgeDocked;
                if (dockingEdge != null)
                {
                    KryptonDockingManager manager = dockedEdge.DockingManager;
                    if (manager != null)
                    {
                        // Create a list of pages that are allowed to be transferred into the dockspace
                        List <KryptonPage> transferPages       = new List <KryptonPage>();
                        List <string>      transferUniqueNames = new List <string>();
                        foreach (KryptonPage page in data.Pages)
                        {
                            if (page.AreFlagsSet(KryptonPageFlags.DockingAllowDocked))
                            {
                                // Use event to indicate the page is becoming docked and allow it to be cancelled
                                CancelUniqueNameEventArgs args = new CancelUniqueNameEventArgs(page.UniqueName, false);
                                manager.RaisePageDockedRequest(args);

                                if (!args.Cancel)
                                {
                                    transferPages.Add(page);
                                    transferUniqueNames.Add(page.UniqueName);
                                }
                            }
                        }

                        // Transfer valid pages into the new dockspace
                        if (transferPages.Count > 0)
                        {
                            // Convert the incoming pages into store pages for restoring later
                            manager.PropogateAction(DockingPropogateAction.StorePages, transferUniqueNames.ToArray());

                            // Create a new dockspace at the start of the list so it is closest to the control edge
                            KryptonDockingDockspace dockspace = (_outsideEdge ? dockedEdge.InsertDockspace(0) : dockedEdge.AppendDockspace());

                            // Add pages into the target
                            dockspace.Append(transferPages.ToArray());

                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
コード例 #14
0
 /// <summary>
 /// Initialize a new instance of the DockspaceEventArgs class.
 /// </summary>
 /// <param name="dockspace">Reference to new dockspace control instance.</param>
 /// <param name="element">Reference to docking dockspace element that is managing the dockspace control.</param>
 public DockspaceEventArgs(KryptonDockspace dockspace,
                           KryptonDockingDockspace element)
 {
     _dockspace = dockspace;
     _element = element;
 }
コード例 #15
0
 /// <summary>
 /// Initialize a new instance of the DockspaceSeparatorEventArgs class.
 /// </summary>
 /// <param name="separator">Reference to separator control instance.</param>
 /// <param name="element">Reference to dockspace docking element that is managing the separator.</param>
 public DockspaceSeparatorEventArgs(KryptonSeparator separator,
                                    KryptonDockingDockspace element)
 {
     _separator = separator;
     _element   = element;
 }
コード例 #16
0
 /// <summary>
 /// Initialize a new instance of the DockspaceSeparatorEventArgs class.
 /// </summary>
 /// <param name="separator">Reference to separator control instance.</param>
 /// <param name="element">Reference to dockspace docking element that is managing the separator.</param>
 public DockspaceSeparatorEventArgs(KryptonSeparator separator,
                                    KryptonDockingDockspace element)
 {
     SeparatorControl = separator;
     DockspaceElement = element;
 }
コード例 #17
0
        private Rectangle FindMovementRect(KryptonDockingDockspace dockspaceElement, Rectangle moveRect)
        {
            // Find the available inner rectangle of our containing control
            Rectangle innerRect = DockingHelper.InnerRectangle(Control);

            // How much can we reduce the width/height of the dockspace to reach the minimum
            Size dockspaceMinimum = dockspaceElement.DockspaceControl.MinimumSize;
            int  reduceWidth      = Math.Max(dockspaceElement.DockspaceControl.Width - dockspaceMinimum.Width, 0);
            int  reduceHeight     = Math.Max(dockspaceElement.DockspaceControl.Height - dockspaceMinimum.Height, 0);

            // Get the minimum size requested for the inner area of the control
            Size innerMinimum = Size.Empty;

            if (GetParentType(typeof(KryptonDockingControl)) is KryptonDockingControl dockingControl)
            {
                innerMinimum = dockingControl.InnerMinimum;
            }

            // How much can we expand the width/height of the dockspace to reach the inner minimum
            int expandWidth  = Math.Max(innerRect.Width - innerMinimum.Width, 0);
            int expandHeight = Math.Max(innerRect.Height - innerMinimum.Height, 0);

            // Limit check we are not growing bigger than the maximum allowed
            Size dockspaceMaximum = dockspaceElement.DockspaceControl.MaximumSize;

            if (dockspaceMaximum.Width > 0)
            {
                expandWidth = Math.Min(expandWidth, dockspaceMaximum.Width);
            }

            if (dockspaceMaximum.Height > 0)
            {
                expandHeight = Math.Min(expandHeight, dockspaceMaximum.Height);
            }

            // Allow movement rectangle to extend inwards according to inner rectangle and outwards according to dockspace size
            Rectangle retRect = Rectangle.Empty;

            switch (Edge)
            {
            case DockingEdge.Left:
                retRect = new Rectangle(moveRect.X - reduceWidth, moveRect.Y, moveRect.Width + reduceWidth + expandWidth, moveRect.Height);
                break;

            case DockingEdge.Right:
                retRect = new Rectangle(moveRect.X - expandWidth, moveRect.Y, moveRect.Width + reduceWidth + expandWidth, moveRect.Height);
                break;

            case DockingEdge.Top:
                retRect = new Rectangle(moveRect.X, moveRect.Y - reduceHeight, moveRect.Width, moveRect.Height + reduceHeight + expandHeight);
                break;

            case DockingEdge.Bottom:
                retRect = new Rectangle(moveRect.X, moveRect.Y - expandHeight, moveRect.Width, moveRect.Height + reduceHeight + expandHeight);
                break;
            }

            // We do not allow negative width/height
            retRect.Width  = Math.Max(retRect.Width, 0);
            retRect.Height = Math.Max(retRect.Height, 0);

            return(retRect);
        }
コード例 #18
0
 /// <summary>
 /// Initialize a new instance of the DockspaceEventArgs class.
 /// </summary>
 /// <param name="dockspace">Reference to new dockspace control instance.</param>
 /// <param name="element">Reference to docking dockspace element that is managing the dockspace control.</param>
 public DockspaceEventArgs(KryptonDockspace dockspace,
                           KryptonDockingDockspace element)
 {
     _dockspace = dockspace;
     _element   = element;
 }