/// <summary> /// 获取内部子元素相对大小之和 /// </summary> /// <returns></returns> internal Tabs.RelativeSizes GetSumOfRelativeSizes() { Tabs.RelativeSizes size = new Tabs.RelativeSizes(); bool horizontal = this.Orientation == Orientation.Horizontal; foreach (var item in Items) { if (item.Visibility == Visibility.Collapsed) { continue; } double splitterChange = TabItemPanel.GetSplitterChange(item); double length = TabItemPanel.GetLength(item, horizontal); size.LengthSum += length; if (splitterChange == 0.0) { size.WithoutChange += length; } else { size.ChangesSum += splitterChange; size.WithChangeSet += length; } } return(size); }
Size GetSize(DockPosition p_dock, RelativeSizes p_relativeSizes, Size p_parentSize, Size p_draggedSize) { Size size = base.RenderSize; if (p_dock != DockPosition.Center) { bool isDockHor = (p_dock == DockPosition.Left) || (p_dock == DockPosition.Right); bool isParentHor = OwnWinItem.Orientation == Orientation.Horizontal; bool findHorizontal = isParentHor == (isDockHor == isParentHor); double length = 0.0; if (isDockHor != isParentHor) { double relativeSizeSum = TabItemPanel.GetLength(this, isDockHor) + GetLength(p_draggedSize, isDockHor); p_relativeSizes = GetRelativeSizesSum(relativeSizeSum); } length = GetRenderLength( 0.0, GetLength(p_draggedSize, findHorizontal), GetLength(p_parentSize, findHorizontal), p_relativeSizes); if (findHorizontal) { size.Width = length; return(size); } size.Height = length; } return(size); }
Point GetTopLeft(DockPosition dock, RelativeSizes relativeSizes, Size parentRenderSize, Size draggedElementRenderSize) { Point topLeft = new Point(); bool shouldTransform = true; if (dock != DockPosition.Center) { int index = OwnWinItem.Items.IndexOf(this); if ((dock == DockPosition.Right) || (dock == DockPosition.Bottom)) { index++; } bool isDockHor = (dock == DockPosition.Left) || (dock == DockPosition.Right); bool isParentHor = OwnWinItem.Orientation == Orientation.Horizontal; double length = 0.0; if (isParentHor != isDockHor) { if ((dock == DockPosition.Right) || (dock == DockPosition.Bottom)) { length = GetLength(parentRenderSize, isDockHor) - GetLength(draggedElementRenderSize, isDockHor); } } else { for (int i = 0; i < index; i++) { FrameworkElement element = OwnWinItem.Items[i] as FrameworkElement; if (element.Visibility == Visibility.Visible) { length += GetRenderLength( TabItemPanel.GetSplitterChange(element), TabItemPanel.GetLength(element, isParentHor), GetLength(parentRenderSize, isParentHor), relativeSizes); } } shouldTransform = false; } if (isParentHor == (isDockHor == isParentHor)) { topLeft.X = length; } else { topLeft.Y = length; } } if (shouldTransform) { return(base.TransformToVisual(OwnWinItem).TransformPoint(topLeft)); } UIElement firstChild = OwnWinItem.Items[0] as UIElement; return(firstChild.TransformToVisual(OwnWinItem).TransformPoint(topLeft)); }