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); }
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); }