예제 #1
0
        public void UpdateTargets(DragAbsoluteEventArgs args)
        {
            FloatingWindow ancestor = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestor <FloatingWindow>((Visual)args.OriginalSource);

            this.UpdateDockPreview(args, (FloatingElement)ancestor);
            this.UpdateAdorners(args, ancestor);
            this.UpdateIsFloatingWindowDragWithin(args, ancestor);
        }
예제 #2
0
 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();
     }
 }
예제 #3
0
        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);
        }
예제 #4
0
        protected virtual void UpdateAdorners(DragAbsoluteEventArgs args, FloatingElement floatingElement, IList <DockSiteType> types, ViewElement element)
        {
            DockManager.DockSiteHitTestResult hitElement = this.FindHitElement(args.ScreenPoint, (Predicate <DockManager.DockSite>)(s =>
            {
                if (s.Visual != floatingElement)
                {
                    return(!(s.Visual is DockAdornerWindow));
                }
                return(false);
            }));
            ICollection <DockAdornerWindow> addedAdorners = (ICollection <DockAdornerWindow>) new List <DockAdornerWindow>();

            PerformanceUtility.MeasurePerformanceUntilRender(PerformanceEvent.DisplayDockingAdorner);
            if (hitElement != null)
            {
                addedAdorners = this.AddAdorners(hitElement.DockSite, hitElement.VisualHit, types, element);
            }
            this.ClearAdorners((Predicate <Visual>)(visual => !addedAdorners.Contains(visual as DockAdornerWindow)));
        }
예제 #5
0
        private void UpdateAdorners(DragAbsoluteEventArgs args, FloatingWindow floatingWindow)
        {
            List <DockSiteType> list = new List <DockSiteType>();

            list.Add(DockSiteType.Default);
            list.Add(DockSiteType.NonDraggable);
            FloatSite floatSite = floatingWindow.DataContext as FloatSite;

            if (floatSite == null)
            {
                return;
            }
            ViewElement child = floatSite.Child;

            if (child == null)
            {
                return;
            }
            this.UpdateAdorners(args, (FloatingElement)floatingWindow, (IList <DockSiteType>)list, child);
        }
예제 #6
0
 private void UpdateIsFloatingWindowDragWithin(DragAbsoluteEventArgs args, FloatingWindow floatingWindow)
 {
     FloatingWindow.SetIsFloatingWindowDragWithin((IEnumerable <DependencyObject>) this.currentlyDragWithin, false);
     DockManager.DockSiteHitTestResult hitElement = this.FindHitElement(args.ScreenPoint, (Predicate <DockManager.DockSite>)(s =>
     {
         if (s.Visual != floatingWindow)
         {
             return(s.Visual is DockAdornerWindow);
         }
         return(false);
     }));
     if (hitElement != null)
     {
         this.currentlyDragWithin = new List <DependencyObject>(this.GetHierarchy((DependencyObject)hitElement.VisualHit, (DependencyObject)null));
         FloatingWindow.SetIsFloatingWindowDragWithin((IEnumerable <DependencyObject>) this.currentlyDragWithin, true);
     }
     else
     {
         this.currentlyDragWithin.Clear();
     }
 }
예제 #7
0
        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();
        }