protected virtual bool IsValidFillPreviewOperation(DockTarget dockTarget, ViewElement dockingView) { bool flag = false; if (dockTarget != null && dockTarget.DockTargetType == DockTargetType.FillPreview && (DockOperations.AreDockRestrictionsFulfilled(dockingView, dockTarget.TargetElement) && dockTarget.TargetElement.AreDockTargetsEnabled)) { flag = true; } return(flag); }
private void UpdateDockPreview(DragAbsoluteEventArgs args, FloatingElement floatingElement) { DockManager.DockSiteHitTestResult hitElement = this.FindHitElement(args.ScreenPoint, (Predicate <DockManager.DockSite>)(s => s.Visual != floatingElement)); if (hitElement != null) { DockSiteAdorner ancestorOrSelf1 = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestorOrSelf <DockSiteAdorner>(hitElement.VisualHit); DockAdornerWindow ancestorOrSelf2 = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestorOrSelf <DockAdornerWindow>(hitElement.VisualHit); DockTarget ancestorOrSelf3 = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestorOrSelf <DockTarget>(hitElement.VisualHit); FloatSite floatSite = floatingElement.Content as FloatSite; DockDirection dockDirection = DockDirection.Fill; FrameworkElement adornedElement = (FrameworkElement)null; if (floatSite == null) { throw new InvalidOperationException("Dragging element must be a FloatSite"); } if (floatSite.Child == null) { throw new InvalidOperationException("floatSite must have at least one child."); } ViewElement child = floatSite.Child; if (this.IsValidFillPreviewOperation(ancestorOrSelf3, child)) { dockDirection = DockDirection.Fill; adornedElement = ancestorOrSelf3.AdornmentTarget == null ? (FrameworkElement)ancestorOrSelf3 : ancestorOrSelf3.AdornmentTarget; } if (ancestorOrSelf1 != null && ancestorOrSelf2 != null && ancestorOrSelf2.AdornedElement != null) { dockDirection = ancestorOrSelf1.DockDirection; adornedElement = ancestorOrSelf2.AdornedElement; if (!ancestorOrSelf1.CreatesDocumentGroup && dockDirection != DockDirection.Fill && adornedElement.DataContext is DocumentGroup) { adornedElement = (FrameworkElement)Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestor <DocumentGroupContainerControl>((Visual)adornedElement); } } if (adornedElement != null) { Rect dockPreviewRect = this.GetDockPreviewRect(dockDirection, adornedElement, child); this.DockPreviewWindow.Left = dockPreviewRect.Left; this.DockPreviewWindow.Top = dockPreviewRect.Top; this.DockPreviewWindow.Width = dockPreviewRect.Width; this.DockPreviewWindow.Height = dockPreviewRect.Height; this.OnDockPreviewWindowShowing(this.DockPreviewWindow, dockDirection); this.DockPreviewWindow.Show(); } else { this.HideDockPreview(); } } else { this.HideDockPreview(); } }
internal virtual DraggedTabInfo GetAutodockTarget(DragAbsoluteEventArgs args) { DraggedTabInfo draggedTabInfo = (DraggedTabInfo)null; FloatingElement floatingElement = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestor <FloatingElement>((Visual)(args.OriginalSource as DragUndockHeader)); if (this.DraggedTabInfo != null && this.DraggedTabInfo.TabStripRect.Contains(args.ScreenPoint)) { draggedTabInfo = this.DraggedTabInfo; } else { DockManager.DockSiteHitTestResult hitElement = this.FindHitElement(args.ScreenPoint, (Predicate <DockManager.DockSite>)(s => { if (s.Visual != floatingElement) { return(!(s.Visual is DockAdornerWindow)); } return(false); })); if (hitElement != null) { ReorderTabPanel reorderTabPanel = (ReorderTabPanel)null; for (DependencyObject sourceElement = (DependencyObject)hitElement.VisualHit; sourceElement != null && reorderTabPanel == null; sourceElement = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.GetVisualOrLogicalParent(sourceElement)) { DockTarget dockTarget = sourceElement as DockTarget; if (dockTarget != null && dockTarget.DockTargetType == DockTargetType.Auto && dockTarget.Visibility == Visibility.Visible) { reorderTabPanel = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindDescendant <ReorderTabPanel>((DependencyObject)dockTarget); } } if (reorderTabPanel != null) { draggedTabInfo = new DraggedTabInfo(); draggedTabInfo.TabStrip = reorderTabPanel; draggedTabInfo.MeasureTabStrip(); ViewGroup viewGroup = reorderTabPanel.DataContext as ViewGroup; if (viewGroup == null) { throw new InvalidOperationException("Reorder tab panel should always have ViewGroup as its DataContext."); } draggedTabInfo.NestedGroup = (ViewElement)viewGroup; if (viewGroup.VisibleChildren.Count > 0) { draggedTabInfo.Sibling = viewGroup.VisibleChildren[0]; } } } } return(draggedTabInfo); }
protected override void UpdateContentCore() { base.UpdateContentCore(); DockTarget adornedElement = base.AdornedElement as DockTarget; if (adornedElement != null) { this.DockSiteType = adornedElement.DockSiteType; SplitterItem splitterItem = adornedElement.FindAncestor <SplitterItem>(); if (splitterItem != null) { this.IsFirst = SplitterPanel.GetIsFirst(splitterItem); this.IsLast = SplitterPanel.GetIsLast(splitterItem); } } }
protected Orientation?GetTargetOrientation(DockTarget target) { Orientation?nullable = new Orientation?(); if (target.DockSiteType == DockSiteType.NonDraggable) { DocumentGroupContainer documentGroupContainer = target.TargetElement as DocumentGroupContainer; if (documentGroupContainer == null) { DocumentGroup documentGroup = target.TargetElement as DocumentGroup; if (documentGroup != null) { documentGroupContainer = documentGroup.Parent as DocumentGroupContainer; } } if (documentGroupContainer != null && documentGroupContainer.VisibleChildren.Count > 1) { nullable = new Orientation?(documentGroupContainer.Orientation); } } return(nullable); }
public void PerformDrop(DragAbsoluteEventArgs args) { DragUndockHeader dragUndockHeader = args.OriginalSource as DragUndockHeader; FloatingWindow floatingWindow = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestor <FloatingWindow>((Visual)dragUndockHeader); DockManager.DockSiteHitTestResult hitElement = this.FindHitElement(args.ScreenPoint, (Predicate <DockManager.DockSite>)(s => s.Visual != floatingWindow)); if (hitElement != null) { DockSiteAdorner ancestorOrSelf1 = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestorOrSelf <DockSiteAdorner>(hitElement.VisualHit); DockAdornerWindow ancestorOrSelf2 = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestorOrSelf <DockAdornerWindow>(hitElement.VisualHit); DockTarget dockTarget = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestorOrSelf <DockTarget>(hitElement.VisualHit); DockDirection dockDirection = DockDirection.Fill; bool flag = false; bool createDocumentGroup = false; if (floatingWindow != null && this.IsValidFillPreviewOperation(dockTarget, dragUndockHeader.ViewElement)) { dockDirection = DockDirection.Fill; flag = true; } if (ancestorOrSelf1 != null && ancestorOrSelf2 != null && ancestorOrSelf2.AdornedElement != null) { dockDirection = ancestorOrSelf1.DockDirection; dockTarget = ancestorOrSelf2.AdornedElement as DockTarget; if (DockOperations.AreDockRestrictionsFulfilled(dragUndockHeader.ViewElement, dockTarget.TargetElement)) { flag = true; createDocumentGroup = ancestorOrSelf1.CreatesDocumentGroup; } } if (flag) { PerformanceUtility.MeasurePerformanceUntilRender(PerformanceEvent.DockPalette); dockTarget.RaiseEvent((RoutedEventArgs) new FloatingElementDockedEventArgs(DockManager.FloatingElementDockedEvent, dragUndockHeader.ViewElement, dockDirection, createDocumentGroup)); } } this.ClearAdorners(); }