Пример #1
0
        private Rect PreviewDockCounterOrientation(DockDirection dockDirection, FrameworkElement adornedElement, ViewElement viewElement, SplitterLength itemLength, Orientation orientation)
        {
            List <UIElement> list          = new List <UIElement>();
            Point            point1        = new Point(0.0, 0.0);
            SplitterItem     splitterItem1 = new SplitterItem();
            int          index             = 0;
            Size         availableSize     = new Size(adornedElement.ActualWidth, adornedElement.ActualHeight);
            SplitterItem splitterItem2     = new SplitterItem();

            list.Add((UIElement)splitterItem2);
            if (dockDirection == DockDirection.Right || dockDirection == DockDirection.Bottom)
            {
                index = 1;
            }
            list.Insert(index, (UIElement)splitterItem1);
            SplitterLength splitterLength = !(viewElement is MainSite) ? (orientation == Orientation.Horizontal ? viewElement.DockedWidth : viewElement.DockedHeight) : new SplitterLength(1.0, SplitterUnitType.Fill);

            SplitterPanel.SetSplitterLength((UIElement)splitterItem2, splitterLength);
            SplitterPanel.SetSplitterLength((UIElement)splitterItem1, itemLength);
            Point point2 = DpiHelper.DeviceToLogicalUnits(adornedElement.PointToScreen(new Point(0.0, 0.0)));

            Rect[] elementBounds;
            SplitterPanel.Measure(availableSize, orientation, (IEnumerable)list, false, out elementBounds, (SplitterPanel)null);
            Rect rect = elementBounds[index];

            rect.Offset(point2.X, point2.Y);
            return(rect);
        }
Пример #2
0
        private Rect PreviewDockFill(FrameworkElement adornedElement)
        {
            Point location = DpiHelper.DeviceToLogicalUnits(adornedElement.PointToScreen(new Point(0.0, 0.0)));
            Size  size     = new Size();

            if (Microsoft.VisualStudio.PlatformUI.ExtensionMethods.IsNonreal(adornedElement.ActualHeight) || Microsoft.VisualStudio.PlatformUI.ExtensionMethods.IsNonreal(adornedElement.ActualWidth))
            {
                size = adornedElement.DesiredSize;
            }
            else
            {
                size.Width  = adornedElement.ActualWidth;
                size.Height = adornedElement.ActualHeight;
            }
            return(new Rect(location, size));
        }
Пример #3
0
        public void EnsureFloatingSiteInVisibleBounds(FloatSite site)
        {
            Rect        logicalRect = new Rect(site.FloatingLeft, site.FloatingTop, site.FloatingWidth, site.FloatingHeight);
            RECT        lprc        = new RECT(DpiHelper.LogicalToDeviceUnits(logicalRect));
            IntPtr      hMonitor    = Microsoft.VisualStudio.PlatformUI.NativeMethods.MonitorFromRect(ref lprc, 1U);
            MONITORINFO monitorInfo = new MONITORINFO();

            monitorInfo.cbSize = (uint)Marshal.SizeOf((object)monitorInfo);
            if (!Microsoft.VisualStudio.PlatformUI.NativeMethods.GetMonitorInfo(hMonitor, ref monitorInfo))
            {
                return;
            }
            Rect rect  = DpiHelper.DeviceToLogicalUnits(monitorInfo.rcWork.WPFRectValue);
            bool flag1 = logicalRect.Right < rect.Left + (double)this.MonitorPadding;
            bool flag2 = logicalRect.Left > rect.Right - (double)this.MonitorPadding;
            bool flag3 = logicalRect.Top < rect.Top + (double)this.MonitorPadding;
            bool flag4 = logicalRect.Top > rect.Bottom - (double)this.MonitorPadding;

            if (!flag1 && !flag2 && (!flag3 && !flag4))
            {
                return;
            }
            if (flag1)
            {
                site.FloatingLeft = rect.Left;
            }
            else if (flag2)
            {
                site.FloatingLeft = rect.Right - site.FloatingWidth;
            }
            if (flag3)
            {
                site.FloatingTop = rect.Top;
            }
            else
            {
                if (!flag4)
                {
                    return;
                }
                site.FloatingTop = rect.Bottom - site.FloatingHeight;
            }
        }
Пример #4
0
        private Rect PreviewDockSameOrientation(DockDirection dockDirection, SplitterPanel panel, ViewElement viewElement, SplitterLength itemLength, Orientation orientation, int originalIndex)
        {
            List <UIElement> list          = new List <UIElement>();
            Point            point1        = new Point(0.0, 0.0);
            SplitterItem     splitterItem1 = new SplitterItem();
            Size             availableSize = new Size();

            availableSize.Width  = panel.ActualWidth;
            availableSize.Height = panel.ActualHeight;
            SplitterItem splitterItem2 = (SplitterItem)null;

            foreach (SplitterItem splitterItem3 in panel.Children)
            {
                list.Add((UIElement)splitterItem3);
                if (splitterItem3.Content == viewElement)
                {
                    splitterItem2 = splitterItem3;
                    panel.Children.IndexOf((UIElement)splitterItem2);
                }
            }
            int index = splitterItem2 != null?list.IndexOf((UIElement)splitterItem2) : originalIndex;

            if (dockDirection == DockDirection.Right || dockDirection == DockDirection.Bottom)
            {
                ++index;
            }
            list.Insert(index, (UIElement)splitterItem1);
            SplitterPanel.SetSplitterLength((UIElement)splitterItem1, itemLength);
            Point point2 = DpiHelper.DeviceToLogicalUnits(panel.PointToScreen(new Point(0.0, 0.0)));

            Rect[] elementBounds;
            SplitterPanel.Measure(availableSize, orientation, (IEnumerable)list, false, out elementBounds, panel);
            Rect rect = elementBounds[index];

            rect.Offset(point2.X, point2.Y);
            return(rect);
        }
Пример #5
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);
        }