示例#1
0
        public void PrepareAndShow(DockAdornerWindow insertAfter)
        {
            DockTarget dockTarget = this.AdornedElement as DockTarget;

            if (this.dockTarget != dockTarget)
            {
                this.PrepareAndHide();
                this.dockTarget = dockTarget;
            }
            if (this.window == null)
            {
                this.UpdateContent();
                this.window = new HwndSource(new HwndSourceParameters()
                {
                    Width               = 0,
                    Height              = 0,
                    ParentWindow        = this.ownerHwnd,
                    UsesPerPixelOpacity = true,
                    WindowName          = "DockAdornerWindow",
                    WindowStyle         = -2013265880
                });
                this.window.SizeToContent = SizeToContent.WidthAndHeight;
                this.window.RootVisual    = (Visual)this;
                DockManager.Instance.RegisterSite((Visual)this, this.window.Handle);
            }
            this.UpdatePositionAndVisibility(insertAfter);
        }
示例#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
            public DockAdornerWindow GetAdornerLayer(DockDirection type)
            {
                DockAdornerWindow dockAdornerWindow;

                if (!this.adorners.TryGetValue(type, out dockAdornerWindow))
                {
                    dockAdornerWindow   = new DockAdornerWindow(this.Handle);
                    this.adorners[type] = dockAdornerWindow;
                }
                return(dockAdornerWindow);
            }
示例#4
0
        public IList <DockAdornerWindow> GetAdornerWindows()
        {
            List <DockAdornerWindow> list = new List <DockAdornerWindow>();

            foreach (DockManager.DockSite dockSite in this.visualToSite.Values)
            {
                DockAdornerWindow dockAdornerWindow = dockSite.Visual as DockAdornerWindow;
                if (dockAdornerWindow != null)
                {
                    list.Add(dockAdornerWindow);
                }
            }
            return((IList <DockAdornerWindow>)list);
        }
示例#5
0
        protected virtual ICollection <DockAdornerWindow> PrepareAndShowAdornerLayers(SortedList <DockDirection, DockTarget> targets, DockManager.DockSite site, ViewElement floatingElement)
        {
            HashSet <DockAdornerWindow> hashSet     = new HashSet <DockAdornerWindow>();
            DockAdornerWindow           insertAfter = (DockAdornerWindow)null;

            foreach (KeyValuePair <DockDirection, DockTarget> keyValuePair in targets)
            {
                DockAdornerWindow adornerLayer = site.GetAdornerLayer(keyValuePair.Key);
                hashSet.Add(adornerLayer);
                adornerLayer.AdornedElement             = (FrameworkElement)keyValuePair.Value;
                adornerLayer.DockDirection              = keyValuePair.Key;
                adornerLayer.Orientation                = this.GetTargetOrientation(keyValuePair.Value);
                adornerLayer.AreOuterTargetsEnabled     = floatingElement.DockRestriction == DockRestrictionType.None;
                adornerLayer.AreInnerTargetsEnabled     = !this.IsDocumentGroupContainerTarget(keyValuePair.Value);
                adornerLayer.IsInnerCenterTargetEnabled = keyValuePair.Value.DockTargetType != DockTargetType.SidesOnly;
                adornerLayer.AreInnerSideTargetsEnabled = keyValuePair.Value.DockTargetType != DockTargetType.CenterOnly;
                this.PrepareAdornerLayer(adornerLayer, floatingElement);
                adornerLayer.PrepareAndShow(insertAfter);
                insertAfter = adornerLayer;
            }
            return((ICollection <DockAdornerWindow>)hashSet);
        }
示例#6
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();
        }
示例#7
0
        private void UpdatePositionAndVisibility(DockAdornerWindow insertAfter)
        {
            if (!this.IsArrangeValid)
            {
                this.UpdateLayout();
            }
            double actualWidth  = this.ActualWidth;
            double actualHeight = this.ActualHeight;
            double num1         = actualWidth - this.AdornedElement.ActualWidth;
            double num2         = actualHeight - this.AdornedElement.ActualHeight;
            Point  point1       = DpiHelper.DeviceToLogicalUnits(this.AdornedElement.PointToScreen(new Point(0.0, 0.0)));
            RECT   lpRect;

            NativeMethods.GetWindowRect(this.ownerHwnd, out lpRect);
            Point  point2  = new Point((double)lpRect.Left, (double)lpRect.Top);
            Vector vector  = Point.Subtract(point1, point2);
            double num3    = vector.X - num1 / 2.0;
            double num4    = vector.Y - num2 / 2.0;
            double x       = vector.X;
            double num5    = vector.X - actualWidth + this.AdornedElement.ActualWidth;
            double y       = vector.Y;
            double num6    = vector.Y - actualHeight + this.AdornedElement.ActualHeight;
            double offsetX = 0.0;
            double offsetY = 0.0;

            switch (this.DockDirection)
            {
            case DockDirection.FirstValue:
                offsetX = num3;
                offsetY = y;
                break;

            case DockDirection.Bottom:
                offsetX = num3;
                offsetY = num6;
                break;

            case DockDirection.Left:
                offsetX = x;
                offsetY = num4;
                break;

            case DockDirection.Right:
                offsetX = num5;
                offsetY = num4;
                break;

            case DockDirection.Fill:
                offsetX = num3;
                offsetY = num4;
                break;
            }
            IntPtr hWndInsertAfter = NativeMethods.HWND_TOPMOST;

            if (insertAfter != null)
            {
                hWndInsertAfter = insertAfter.window.Handle;
            }
            point2.Offset(offsetX, offsetY);
            Point point3 = DpiHelper.LogicalToDeviceUnits(point2);

            NativeMethods.SetWindowPos(this.window.Handle, hWndInsertAfter, (int)point3.X, (int)point3.Y, 0, 0, 593);
        }
示例#8
0
 protected virtual void PrepareAdornerLayer(DockAdornerWindow adornerLayer, ViewElement floatingElement)
 {
 }
 internal DockAdornerWindowAutomationPeer(DockAdornerWindow owner)
     : base((FrameworkElement)owner)
 {
 }