internal static void InvokeDragEvent(object sender, DockEventArgs e) { if (dragEvent != null) { dragEvent(sender, e); } if (!e.ShowDockGuide) { HideDockGuide(); } }
/// <summary> /// Invokes a drag event that accepts a valid position for docking. /// </summary> /// <param name="confirm">Set this flag to confirm the docking position, if available.</param> /// <returns>Returns the target <see cref="DockContainer"/>.</returns> internal DockContainer SendDockEvent(bool confirm) { DockEventArgs e = new DockEventArgs(new Point(MousePosition.X, MousePosition.Y), rootContainer.DockType, confirm); DockManager.InvokeDragEvent(this, e); if (e.Release) { DockManager.HideDockGuide(); } return(e.Target); }
internal static void UpdateDockGuide(DockContainer target, DockEventArgs e) { if ((target == null) | noGuidePlease | (style != DockVisualStyle.VS2005) | fastMoveDraw) { HideDockGuide(); return; } if (dockGuide == null) { dockGuide = new OverlayForm(); } dockGuide.TargetHost = target; dockGuide.Size = target.Size; if (!dockGuide.Visible) { dockGuide.Show(); } if (target.Parent != null) { dockGuide.Location = target.RectangleToScreen(target.ClientRectangle).Location; } else { dockGuide.Location = target.Location; } dockGuide.BringToFront(); // Make tests. DockStyle dstStyle = dockGuide.HitTest(e.Point); if (dstStyle != DockStyle.None) { e.Point = target.GetVirtualDragDest(dstStyle); } else { e.Handled = true; } e.ShowDockGuide = true; }
/// <summary> /// The <see cref="DragWindow"/> event handler for dockable windows. /// Used to enable a <see cref="DockWindow"/> to send its position changes to this container. /// Calls recursively all <see cref="DragWindow"/> event handlers of the child containers. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">An <see cref="DockEventArgs"/> that contains the docking data.</param> /// <returns>The success of the operation.</returns> public bool DragWindow(object sender, DockEventArgs e) { if (e.Handled) return true; try { // First, check if the given point is in the current tree and lots of more cool features. if ((e.DockType == DockContainerType.None) | ((e.DockType == DockContainerType.Document) & (dockType == DockContainerType.ToolWindow)) | ((conList.Count > 0) & !e.IgnoreHierarchy) | (sender == this.TopLevelControl) | (autoHide == true) | ((!this.TopLevelControl.Visible) & (sender is DockForm))) { //Console.WriteLine(e.invokeCounter + "\t" + HitTest(e.Point).ToString() + "\t" + dockType.ToString() + "\t" + e.DockType.ToString() + "\t" + conList.Count + "\t" + (sender == this.TopLevelControl)); return false; } // Last important question: am I'm moving myself or do I like getting more containers? if (this.TopLevelControl is DockForm) if ((this.TopLevelControl as DockForm).Moving | !(this.TopLevelControl as DockForm).AllowDock | !(this.TopLevelControl as DockForm).Visible) return false; // Hit test. if (!HitTest(e.Point)) return false; DockForm f = DockManager.GetFormAtPoint(e.Point, 1); if ((f != this.TopLevelControl) & (f != null)) return false; // Update DockGuide. DockManager.UpdateDockGuide(this, e); if (e.Handled) return false; // Get the source object size. Size size = Size.Empty; if (sender is DockForm) size = (sender as DockForm).Size; else if (sender is DockContainer) size = (sender as DockContainer).Size; else if (sender is DockWindow) size = (sender as DockWindow).Size; // Then check for valid destinations. e.Target = GetTarget(size, e.DockType, e.Point); if (e.Target == null) return false; // The event has finished. e.Handled = true; // Take the results and add the whole stuff to the own collection. if (e.Release) { // Transfer all own panels to a higher hierarchy level. if (!conList.Contains(e.Target) & (e.Target != this)) { // Create new container and fill it with own panels. DockContainer cont = new DockContainer(); cont.removeable = removeable; cont.DockBorder = dockBorder; removeable = true; DockPanel temp = ActivePanel; cont.Controls.AddRange((DockPanel[])panList.ToArray(typeof(DockPanel))); cont.ActivePanel = temp; cont.DockType = dockType; if (conList.Count > 1) { disableOnControlRemove = true; cont.Controls.AddRange((DockContainer[])conList.ToArray(typeof(DockContainer))); disableOnControlRemove = false; } this.Controls.Add(cont); cont.Dock = DockStyle.Fill; } // Add the container to the list object. if (sender is DockWindow) { AddPanel((sender as DockWindow).ControlContainer, e.Target); } else { DockContainer src = null; if (sender is DockForm) src = (sender as DockForm).RootContainer; else if (sender is DockContainer) src = (sender as DockContainer); AddWindowContent(src, e.Target); } // Set focus. this.TopLevelControl.BringToFront(); this.TopLevelControl.Invalidate(true); } } catch (Exception ex) { Console.WriteLine("DockContainer.DragWindow: " + ex.Message); } return true; }
internal void StopAutoHide() { // Undock. hideStorage.manager.AutoHideContainer(this, hideStorage.toplevelDock, false); // Is the old parent container still properly docked? // - If the TopLevelContainer property returns the same object, the container is on its own. // - The DockStyle property has to be set. // - The container must not contain more containers or the whole thing will end up in a mess. if ((hideStorage.parent.TopLevelContainer != hideStorage.parent) & (hideStorage.parent.Dock != DockStyle.None)) { // The container is still present in its old shape. Point pt = hideStorage.parent.GetVirtualDragDest(hideStorage.parentDock); DockEventArgs e = new DockEventArgs(pt, this.DockType, true); e.IgnoreHierarchy = true; DockManager.NoGuidePlease = true; hideStorage.parent.DragWindow(this, e); DockManager.NoGuidePlease = false; } else { // The container has moved or changed its content in some way. Point pt = hideStorage.manager.GetVirtualDragDest(hideStorage.toplevelDock); DockEventArgs e = new DockEventArgs(pt, this.DockType, true); e.IgnoreHierarchy = true; DockManager.NoGuidePlease = true; hideStorage.manager.DragWindow(this, e); DockManager.NoGuidePlease = false; } }
/// <summary> /// Invokes a drag event that accepts a valid position for docking. /// </summary> /// <param name="confirm">Set this flag to confirm the docking position, if available.</param> /// <returns>Returns the target <see cref="DockContainer"/>.</returns> internal DockContainer SendDockEvent(bool confirm) { DockEventArgs e = new DockEventArgs(new Point(MousePosition.X, MousePosition.Y), rootContainer.DockType, confirm); DockManager.InvokeDragEvent(this, e); if (e.Release) DockManager.HideDockGuide(); return e.Target; }
internal static void UpdateDockGuide(DockContainer target, DockEventArgs e) { if ((target == null) | noGuidePlease | (style != DockVisualStyle.VS2005) | fastMoveDraw) { HideDockGuide(); return; } if (dockGuide == null) dockGuide = new OverlayForm(); dockGuide.TargetHost = target; dockGuide.Size = target.Size; if (!dockGuide.Visible) dockGuide.Show(); if (target.Parent != null) dockGuide.Location = target.RectangleToScreen(target.ClientRectangle).Location; else dockGuide.Location = target.Location; dockGuide.BringToFront(); // Make tests. DockStyle dstStyle = dockGuide.HitTest(e.Point); if (dstStyle != DockStyle.None) e.Point = target.GetVirtualDragDest(dstStyle); else e.Handled = true; e.ShowDockGuide = true; }
internal static void InvokeDragEvent(object sender, DockEventArgs e) { if (dragEvent != null) dragEvent(sender, e); if (!e.ShowDockGuide) HideDockGuide(); }