public static void SetDockLevel(DependencyObject obj, DockLevel value) { if (obj == null) { throw new ArgumentNullException(nameof(obj)); } obj.SetValue(DockLevelProperty, value); }
/// <summary> /// Arrange children position after measure children size. /// </summary> /// <param name="finalSize"></param> /// <returns></returns> protected override Size ArrangeOverride(Size arrangeSize) { UIElementCollection internalChildren = this.InternalChildren; int count = internalChildren.Count; double width = arrangeSize.Width; double height = arrangeSize.Height; double highLevelCount = 0; for (int i = 0; i < count; i++) { UIElement element = InternalChildren[i]; if (element != null && element.Visibility != Visibility.Collapsed) { Size desiredSize = element.DesiredSize; DockLevel dockLevel = HierarchicalPanel.GetDockLevel(element); if (dockLevel == DockLevel.Low) { width -= desiredSize.Width; height -= desiredSize.Height; } else { highLevelCount++; } } } double x = 0.0; double y = 0.0; double num2 = 0.0; double num3 = 0.0; for (int index = 0; index < count; ++index) { UIElement element = internalChildren[index]; if (element != null && element.Visibility != Visibility.Collapsed) { Size desiredSize = element.DesiredSize; Rect finalRect = new Rect(x, y, Math.Max(0.0, arrangeSize.Width - (x + num2)), Math.Max(0.0, arrangeSize.Height - (y + num3))); if (HierarchicalPanel.GetDockLevel(element) == DockLevel.Low) { switch (DockPanel.GetDock(element)) { case Dock.Left: x += desiredSize.Width; finalRect.Width = desiredSize.Width; break; case Dock.Top: y += desiredSize.Height; finalRect.Height = desiredSize.Height; break; case Dock.Right: num2 += desiredSize.Width; finalRect.X = Math.Max(0.0, arrangeSize.Width - num2); finalRect.Width = desiredSize.Width; break; case Dock.Bottom: num3 += desiredSize.Height; finalRect.Y = Math.Max(0.0, arrangeSize.Height - num3); finalRect.Height = desiredSize.Height; break; } } else { switch (DockPanel.GetDock(element)) { case Dock.Left: x += width / highLevelCount; finalRect.Width = width / highLevelCount; break; case Dock.Top: y += height / highLevelCount; finalRect.Height = height / highLevelCount; break; case Dock.Right: num2 += width / highLevelCount; finalRect.X = Math.Max(0.0, arrangeSize.Width - num2); finalRect.Width = desiredSize.Width; break; case Dock.Bottom: num3 += height / highLevelCount; finalRect.Y = Math.Max(0.0, arrangeSize.Height - num3); finalRect.Height = desiredSize.Height; break; } } element.Arrange(finalRect); } } return(arrangeSize); }