Пример #1
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
            bool    flag    = false;
            TabItem tabItem = this.FindAncestor <TabItem>();

            if (tabItem != null)
            {
                DraggedTabInfo draggedTabInfo = DockManager.Instance.DraggedTabInfo;
                if (draggedTabInfo != null && draggedTabInfo.DraggedViewElement == this.ViewElement)
                {
                    flag = true;
                    ReorderTabPanel parent = tabItem.Parent as ReorderTabPanel ?? VisualTreeHelper.GetParent(tabItem) as ReorderTabPanel;
                    if (parent != null && draggedTabInfo != null && (draggedTabInfo.TabStrip != parent || parent.Children.Count != draggedTabInfo.TabRects.Count))
                    {
                        draggedTabInfo.TabStrip = parent;
                        draggedTabInfo.TabStrip.IsNotificationNeeded = true;
                    }
                }
            }
            bool flag1 = (DockManager.Instance.UndockingInformation == null ? false : DockManager.Instance.UndockingInformation.Element == this.ViewElement);

            if (NativeMethods.IsLeftButtonPressed() && (flag1 || flag))
            {
                this.BeginDragging((flag1 ? DockManager.Instance.UndockingInformation.Location : NativeMethods.GetCursorPos()));
            }
        }
Пример #2
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);
        }