Exemple #1
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);
        }