private void OnViewHeaderDragStarted(object sender, DragAbsoluteEventArgs args) { DragUndockHeader dragUndockHeader = (DragUndockHeader)args.OriginalSource; if (dragUndockHeader.ViewElement != null && DockManager.Instance.DraggedViewElements.Count == 0) { DockManager.Instance.SetDraggedViewElements(dragUndockHeader.ViewElement); } if (!dragUndockHeader.IsWindowTitleBar && dragUndockHeader.ViewElement != null) { dragUndockHeader.CancelDrag(); if (DockManager.Instance.DraggedTabInfo != null && this.IsAutoDockAllowed(DockManager.Instance.DraggedTabInfo.TabStrip)) { if (-1 != DockManager.Instance.DraggedTabInfo.DraggedTabPosition) { DockManager.Instance.DraggedTabInfo.RemoveTabRect(DockManager.Instance.DraggedTabInfo.DraggedTabPosition); } DockManager.Instance.DraggedTabInfo.Initialize(dragUndockHeader.ViewElement); DockManager.Instance.DraggedTabInfo.DraggedTabPosition = -1; } else { DockManager.Instance.DraggedTabInfo = (DraggedTabInfo)null; } Rect currentUndockingRect = Rect.Empty; if (dragUndockHeader.ViewFrameworkElement != null && ExtensionMethods.IsConnectedToPresentationSource((DependencyObject)dragUndockHeader.ViewFrameworkElement)) { currentUndockingRect = new Rect(dragUndockHeader.ViewFrameworkElement.PointToScreen(new Point(0.0, 0.0)), DpiHelper.LogicalToDeviceUnits(dragUndockHeader.ViewFrameworkElement.RenderSize)); } DockOperations.Undock(dragUndockHeader.ViewElement, dragUndockHeader.ViewElement.WindowProfile, args.ScreenPoint, currentUndockingRect); } DockManager.Instance.IsDragging = true; }
public Rect MeasureTabStrip() { if (this.TabStrip == null) { throw new InvalidOperationException("TabStrip must be initialized."); } this.draggedTabPosition = -1; Point topLeft = new Point(double.MaxValue, double.MaxValue); Point bottomRight = new Point(double.MinValue, double.MinValue); this.tabRects.Clear(); foreach (UIElement uiElement in this.TabStrip.Children) { TabItem tabChild = uiElement as TabItem; if (tabChild != null) { this.MeasureTabItem(tabChild, ref topLeft, ref bottomRight); ViewElement viewElement = tabChild.DataContext as ViewElement; if (viewElement != null && viewElement == this.DraggedViewElement) { this.draggedTabPosition = this.tabRects.Count - 1; } } } if (topLeft.X == double.MaxValue || topLeft.Y == double.MaxValue || (bottomRight.X == double.MinValue || bottomRight.Y == double.MinValue)) { topLeft.X = 0.0; topLeft.Y = 0.0; bottomRight.X = 0.0; bottomRight.Y = 0.0; this.tabRects.Clear(); } this.tabStripRect = new Rect(topLeft, bottomRight); DockTarget ancestor = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestor <DockTarget>((Visual)this.TabStrip); if (ancestor != null && ancestor.DockTargetType == DockTargetType.Auto && ExtensionMethods.IsConnectedToPresentationSource((DependencyObject)ancestor)) { this.tabStripRect = new Rect(ancestor.PointToScreen(new Point(0.0, 0.0)), DpiHelper.LogicalToDeviceUnits(new Size(ancestor.ActualWidth, ancestor.ActualHeight))); } this.NormalizeTabHeight(); return(this.tabStripRect); }