示例#1
0
        protected override void OnFixChildrenDockLengths()
        {
            if (base.ActualWidth == 0 || base.ActualHeight == 0)
            {
                return;
            }
            LayoutPanel layoutPanel = this._model;

            if (this._model.Orientation == System.Windows.Controls.Orientation.Horizontal)
            {
                if (!this._model.ContainsChildOfType <LayoutDocumentPane, LayoutDocumentPaneGroup>())
                {
                    for (int i = 0; i < this._model.Children.Count; i++)
                    {
                        ILayoutPositionableElement item = this._model.Children[i] as ILayoutPositionableElement;
                        if (!item.DockWidth.IsStar)
                        {
                            item.DockWidth = new GridLength(1, GridUnitType.Star);
                        }
                    }
                    return;
                }
                for (int j = 0; j < this._model.Children.Count; j++)
                {
                    ILayoutContainer           layoutContainer = this._model.Children[j] as ILayoutContainer;
                    ILayoutPositionableElement gridLength      = this._model.Children[j] as ILayoutPositionableElement;
                    if (layoutContainer != null && (layoutContainer.IsOfType <LayoutDocumentPane, LayoutDocumentPaneGroup>() || layoutContainer.ContainsChildOfType <LayoutDocumentPane, LayoutDocumentPaneGroup>()))
                    {
                        gridLength.DockWidth = new GridLength(1, GridUnitType.Star);
                    }
                    else if (gridLength != null && gridLength.DockWidth.IsStar)
                    {
                        double num = Math.Max((gridLength as ILayoutPositionableElementWithActualSize).ActualWidth, gridLength.DockMinWidth);
                        num = Math.Min(num, base.ActualWidth / 2);
                        num = Math.Max(num, gridLength.DockMinWidth);
                        gridLength.DockWidth = new GridLength(num, GridUnitType.Pixel);
                    }
                }
                return;
            }
            if (!this._model.ContainsChildOfType <LayoutDocumentPane, LayoutDocumentPaneGroup>())
            {
                for (int k = 0; k < this._model.Children.Count; k++)
                {
                    ILayoutPositionableElement layoutPositionableElement = this._model.Children[k] as ILayoutPositionableElement;
                    if (!layoutPositionableElement.DockHeight.IsStar)
                    {
                        layoutPositionableElement.DockHeight = new GridLength(1, GridUnitType.Star);
                    }
                }
                return;
            }
            for (int l = 0; l < this._model.Children.Count; l++)
            {
                ILayoutContainer           item1       = this._model.Children[l] as ILayoutContainer;
                ILayoutPositionableElement gridLength1 = this._model.Children[l] as ILayoutPositionableElement;
                if (item1 != null && (item1.IsOfType <LayoutDocumentPane, LayoutDocumentPaneGroup>() || item1.ContainsChildOfType <LayoutDocumentPane, LayoutDocumentPaneGroup>()))
                {
                    gridLength1.DockHeight = new GridLength(1, GridUnitType.Star);
                }
                else if (gridLength1 != null && gridLength1.DockHeight.IsStar)
                {
                    double num1 = Math.Max((gridLength1 as ILayoutPositionableElementWithActualSize).ActualHeight, gridLength1.DockMinHeight);
                    num1 = Math.Min(num1, base.ActualHeight / 2);
                    num1 = Math.Max(num1, gridLength1.DockMinHeight);
                    gridLength1.DockHeight = new GridLength(num1, GridUnitType.Pixel);
                }
            }
        }
示例#2
0
        public static AnchorSide GetSide(this ILayoutElement element)
        {
            AnchorSide             anchorSide;
            ILayoutOrientableGroup parent = element.Parent as ILayoutOrientableGroup;

            if (parent != null)
            {
                if (!parent.ContainsChildOfType <LayoutDocumentPaneGroup, LayoutDocumentPane>())
                {
                    return(parent.GetSide());
                }
                using (IEnumerator <ILayoutElement> enumerator = parent.Children.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ILayoutElement current = enumerator.Current;
                        if (current == element || current.Descendents().Contains(element))
                        {
                            anchorSide = (parent.Orientation == Orientation.Horizontal ? AnchorSide.Left : AnchorSide.Top);
                            return(anchorSide);
                        }
                        else
                        {
                            ILayoutContainer layoutContainer = current as ILayoutContainer;
                            if (layoutContainer == null || !layoutContainer.IsOfType <LayoutDocumentPane, LayoutDocumentPaneGroup>() && !layoutContainer.ContainsChildOfType <LayoutDocumentPane, LayoutDocumentPaneGroup>())
                            {
                                continue;
                            }
                            anchorSide = (parent.Orientation == Orientation.Horizontal ? AnchorSide.Right : AnchorSide.Bottom);
                            return(anchorSide);
                        }
                    }
                    return(AnchorSide.Right);
                }
                return(anchorSide);
            }
            return(AnchorSide.Right);
        }