/// <summary> /// Initialize a new instance of the DragTargetControlEdge 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="controlElement">Workspace instance that contains cell.</param> /// <param name="allowFlags">Only drop pages that have one of these flags defined.</param> /// <param name="outsideEdge">Add to the outside edge (otherwise the inner edge).</param> public DragTargetControlEdge(Rectangle screenRect, Rectangle hotRect, Rectangle drawRect, DragTargetHint hint, KryptonDockingControl controlElement, KryptonPageFlags allowFlags, bool outsideEdge) : base(screenRect, hotRect, drawRect, hint, allowFlags) { _controlElement = controlElement; _outsideEdge = outsideEdge; // Find the orientation by looking for a matching hint (we need to exclude flags from the hint enum) switch (hint & DragTargetHint.ExcludeFlags) { case DragTargetHint.Transfer: case DragTargetHint.EdgeLeft: _edge = VisualOrientation.Left; break; case DragTargetHint.EdgeRight: _edge = VisualOrientation.Right; break; case DragTargetHint.EdgeTop: _edge = VisualOrientation.Top; break; case DragTargetHint.EdgeBottom: _edge = VisualOrientation.Bottom; break; default: Debug.Assert(false); throw new ArgumentOutOfRangeException("Hint must be an edge value."); } }
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; } }
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; } }
/// <summary> /// Initialize a new instance of the DragTargetControlEdge 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="controlElement">Workspace instance that contains cell.</param> /// <param name="allowFlags">Only drop pages that have one of these flags defined.</param> /// <param name="outsideEdge">Add to the outside edge (otherwise the inner edge).</param> public DragTargetControlEdge(Rectangle screenRect, Rectangle hotRect, Rectangle drawRect, DragTargetHint hint, KryptonDockingControl controlElement, KryptonPageFlags allowFlags, bool outsideEdge) : base(screenRect, hotRect, drawRect, hint, allowFlags) { ControlElement = controlElement; _outsideEdge = outsideEdge; // Find the orientation by looking for a matching hint (we need to exclude flags from the hint enum) switch (hint & DragTargetHint.ExcludeFlags) { case DragTargetHint.Transfer: case DragTargetHint.EdgeLeft: Edge = VisualOrientation.Left; break; case DragTargetHint.EdgeRight: Edge = VisualOrientation.Right; break; case DragTargetHint.EdgeTop: Edge = VisualOrientation.Top; break; case DragTargetHint.EdgeBottom: Edge = VisualOrientation.Bottom; break; default: Debug.Assert(false); throw new ArgumentOutOfRangeException("Hint must be an edge value."); } }
/// <summary> /// Release unmanaged and optionally managed resources. /// </summary> /// <param name="disposing">Called from Dispose method.</param> protected override void Dispose(bool disposing) { if (disposing) { _controlElement = null; } base.Dispose(disposing); }
private void OnDockspaceSeparatorNotMoved(object sender, EventArgs e) { 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; } }
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; KryptonDockingControl dockingControl = GetParentType(typeof(KryptonDockingControl)) as KryptonDockingControl; if (dockingControl != null) { 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); }
/// <summary> /// Release unmanaged and optionally managed resources. /// </summary> /// <param name="disposing">Called from Dispose method.</param> protected override void Dispose(bool disposing) { if (disposing) _controlElement = null; base.Dispose(disposing); }
/// <summary> /// Manage auto hidden/docked capabilities for provided control. /// </summary> /// <param name="name">Name for new docking element.</param> /// <param name="c">Reference to control instance.</param> /// <param name="workspace">Reference to docking workspace that is inside the control.</param> /// <returns>KryptonDockingControl instance created.</returns> public KryptonDockingControl ManageControl(string name, Control c, KryptonDockingWorkspace workspace) { KryptonDockingControl dockingControl = new KryptonDockingControl(name, c, workspace); Add(dockingControl); return dockingControl; }
/// <summary> /// Manage auto hidden/docked capabilities for provided control. /// </summary> /// <param name="name">Name for new docking element.</param> /// <param name="c">Reference to control instance.</param> /// <param name="navigator">Reference to docking navigator that is inside the control.</param> /// <returns>KryptonDockingControl instance created.</returns> public KryptonDockingControl ManageControl(string name, Control c, KryptonDockingNavigator navigator) { KryptonDockingControl dockingControl = new KryptonDockingControl(name, c, navigator); Add(dockingControl); return dockingControl; }
/// <summary> /// Manage auto hidden/docked capabilities for provided control. /// </summary> /// <param name="name">Name for new docking element.</param> /// <param name="c">Reference to control instance.</param> /// <returns>KryptonDockingControl instance created.</returns> public KryptonDockingControl ManageControl(string name, Control c) { KryptonDockingControl dockingControl = new KryptonDockingControl(name, c); Add(dockingControl); return dockingControl; }