private void SetInsertionPoint() { bool flag = false; if (this.oldDockAdorner != null) { this.oldDockAdorner.IsActive = false; } DockAdorner dockAdorner = this.ActiveView.AdornerService.GetHitAdorner(this.Pointer, new Type[1] { typeof(DockPanelAdorner) }) as DockAdorner; this.oldDockAdorner = dockAdorner; if (dockAdorner != null) { this.oldDockAdorner.IsActive = true; if (dockAdorner is DockPanelAdorner) { DockPanelElement dockPanel = (DockPanelElement)dockAdorner.Element; DockPanelAdorner dockPanelAdorner = (DockPanelAdorner)dockAdorner; this.insertionPoint.DockPanel = dockPanel; this.insertionPoint.Dock = dockPanelAdorner.Dock; this.insertionPoint.Index = DockPanelLayoutUtilities.GetFillRegionInsertionIndex(dockPanel); flag = true; } } if (flag || this.insertionPoint.IsEmpty) { return; } this.insertionPoint.Clear(); }
public static int GetChildInsertionIndex(DockPanelElement dockPanel, BaseFrameworkElement dockPanelChild, Dock adornerDock) { int num = dockPanel.Children.IndexOf((SceneNode)dockPanelChild); switch (DockPanel.GetDock((UIElement)(dockPanelChild.ViewObject.PlatformSpecificObject as FrameworkElement))) { case Dock.Left: case Dock.Top: if (adornerDock == Dock.Left || adornerDock == Dock.Top) { return(num); } if (adornerDock == Dock.Right || adornerDock == Dock.Bottom) { return(num + 1); } throw new ArgumentException(ExceptionStringTable.IllegalFillAdornerOnDockChild); case Dock.Right: case Dock.Bottom: if (adornerDock == Dock.Left || adornerDock == Dock.Top) { return(num + 1); } if (adornerDock == Dock.Right || adornerDock == Dock.Bottom) { return(num); } throw new ArgumentException(ExceptionStringTable.IllegalFillAdornerOnDockChild); default: throw new ArgumentException(ExceptionStringTable.IllegalFillAdornerOnDockChild); } }
public static int GetFillRegionInsertionIndex(DockPanelElement dockPanel) { int num = -1; if (num == -1) { num = dockPanel.Children.Count; } return(num); }
private static Rect GetFillRegionRectangle(DockPanelElement dockPanel) { Rect computedTightBounds = dockPanel.GetComputedTightBounds(); double left = computedTightBounds.Left; double right = computedTightBounds.Right; double top = computedTightBounds.Top; double bottom = computedTightBounds.Bottom; for (int index = 0; index < DockPanelLayoutUtilities.GetFillRegionInsertionIndex(dockPanel); ++index) { BaseFrameworkElement frameworkElement = dockPanel.Children[index] as BaseFrameworkElement; if (frameworkElement != null) { Dock dock = (Dock)frameworkElement.GetComputedValue(DockPanelElement.DockProperty); Rect computedBounds = frameworkElement.GetComputedBounds((Base2DElement)dockPanel); switch (dock) { case Dock.Left: left += computedBounds.Width; continue; case Dock.Top: top += computedBounds.Height; continue; case Dock.Right: right -= computedBounds.Width; continue; case Dock.Bottom: bottom -= computedBounds.Height; continue; default: throw new NotImplementedException(ExceptionStringTable.DockPanelInvalidDock); } } } double width = Math.Max(0.0, right - left); double height = Math.Max(0.0, bottom - top); return(new Rect(left, top, width, height)); }