private void HandleDragAbsoluteMoveTabInPlace(DragUndockHeader header, DragAbsoluteEventArgs args) { DraggedTabInfo draggedTabInfo = DockManager.Instance.DraggedTabInfo; bool flag = draggedTabInfo.GetTabIndexAt(args.ScreenPoint) == draggedTabInfo.DraggedTabPosition; if (flag) { draggedTabInfo.ClearVirtualTabRect(); } if (header.ViewElement == null && draggedTabInfo.DraggedViewElement == null) { return; } ViewElement tab = header.ViewElement ?? draggedTabInfo.DraggedViewElement; if (!draggedTabInfo.TabStripRect.Contains(args.ScreenPoint) || flag || draggedTabInfo.VirtualTabRect.Contains(args.ScreenPoint)) { return; } int tabIndexAt = draggedTabInfo.GetTabIndexAt(args.ScreenPoint); if (-1 == tabIndexAt) { return; } DockOperations.MoveTab(tab, tabIndexAt); draggedTabInfo.SetVirtualTabRect(tabIndexAt); draggedTabInfo.MoveTabRect(draggedTabInfo.DraggedTabPosition, tabIndexAt); draggedTabInfo.DraggedTabPosition = tabIndexAt; }
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; }
private void OnViewHeaderDragAbsolute(object sender, DragAbsoluteEventArgs args) { DragUndockHeader header = (DragUndockHeader)args.OriginalSource; if (header.IsWindowTitleBar) { this.HandleDragAbsoluteFloatingWindow(header, args); } else { if (DockManager.Instance.DraggedTabInfo == null) { return; } this.HandleDragAbsoluteMoveTabInPlace(header, args); } }
internal override DraggedTabInfo GetAutodockTarget(DragAbsoluteEventArgs args) { FloatingElement ancestor = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestor <FloatingElement>((Visual)(args.OriginalSource as DragUndockHeader)); if (ancestor != null) { FloatSite floatSite = ancestor.DataContext as FloatSite; if (floatSite != null) { ConstrainedView constrainedView = floatSite.Child as ConstrainedView; if (constrainedView != null && !constrainedView.CanAutoDock()) { return((DraggedTabInfo)null); } } } return(base.GetAutodockTarget(args)); }
private void HandleDragAbsoluteFloatingWindow(DragUndockHeader header, DragAbsoluteEventArgs args) { DockManager.Instance.UpdateTargets(args); DraggedTabInfo autodockTarget = DockManager.Instance.GetAutodockTarget(args); bool flag = true; ViewGroup viewGroup = header.ViewElement as ViewGroup; if (viewGroup != null) { flag = viewGroup.VisibleChildren.Count == 1; } if (autodockTarget == null || !flag || DockManager.Instance.IsFloatingOverDockAdorner) { return; } ViewElement viewElement = header.ViewElement; this.HandleDockIntoTabStrip(autodockTarget, header, args); DockManager.Instance.DraggedTabInfo = autodockTarget; DockManager.Instance.DraggedTabInfo.DraggedViewElement = viewElement; }
private void HandleDockIntoTabStrip(DraggedTabInfo tabInfo, DragUndockHeader header, DragAbsoluteEventArgs args) { int dockPosition = tabInfo.GetClosestTabIndexAt(args.ScreenPoint); if (-1 == dockPosition) { return; } ViewElement viewElement = tabInfo.TargetElement; if (viewElement == null && tabInfo.GroupContainer != null) { viewElement = (ViewElement)DockOperations.CreateDocumentGroupAt(tabInfo.GroupContainer, tabInfo.GroupPosition); viewElement.DockedHeight = tabInfo.GroupDockedHeight; viewElement.DockedWidth = tabInfo.GroupDockedWidth; viewElement.FloatingHeight = tabInfo.GroupFloatingHeight; viewElement.FloatingWidth = tabInfo.GroupFloatingWidth; } if (!DockOperations.AreDockRestrictionsFulfilled(header.ViewElement, viewElement)) { return; } bool flag = false; ViewGroup viewGroup = tabInfo.NestedGroup as ViewGroup; if (viewGroup != null) { flag = viewGroup.Children.Contains(header.ViewElement); } if (!flag && tabInfo.TabRects.Count > 0 && args.ScreenPoint.X > tabInfo.TabRects[tabInfo.TabRects.Count - 1].Right) { dockPosition = tabInfo.TabRects.Count; } if (tabInfo.TabRects.Count == 0) { dockPosition = 0; } if (DockManager.Instance.DraggedTabInfo != null && -1 != DockManager.Instance.DraggedTabInfo.DraggedTabPosition) { DockManager.Instance.DraggedTabInfo.RemoveTabRect(DockManager.Instance.DraggedTabInfo.DraggedTabPosition); } DockOperations.DockAt(viewElement, header.ViewElement, dockPosition); tabInfo.TabStrip.IsNotificationNeeded = true; tabInfo.DraggedTabPosition = dockPosition; tabInfo.ClearVirtualTabRect(); DockManager.Instance.ClearAdorners(); }