Пример #1
0
        public override Size CalcIdealContentSize(IUserInterfaceRenderContext renderContext, Size maxSize)
        {
            UpdateChildLists();

            maxSize = LayoutMath.ConstrainMaxSize(maxSize, Style.Size);

            switch (Direction)
            {
            case FlexDirection.Column:
            case FlexDirection.ColumnReverse:
                return(vertical.CalcIdealSize(renderContext, maxSize, layoutChildren));

            case FlexDirection.Row:
            case FlexDirection.RowReverse:
                return(horizontal.CalcIdealSize(renderContext, maxSize, layoutChildren));

            default:
                throw new InvalidOperationException();
            }
        }
Пример #2
0
        public void ConstrainMaxSizeWithFixedSizeConstraintTest(
            int initialWidth,
            int initialHeight,
            int maxWidth,
            int maxHeight,
            int expectedMaxWidth,
            int expectedMaxHeight)
        {
            Size initial = new Size(initialWidth, initialHeight);

            SizeConstraints constraints = new SizeConstraints
            {
                MaxWidth  = maxWidth,
                MaxHeight = maxHeight,
            };

            Size result = LayoutMath.ConstrainMaxSize(initial, constraints);

            result.Width.Should().Be(expectedMaxWidth);
            result.Height.Should().Be(expectedMaxHeight);
        }