Exemplo n.º 1
0
        public StopOr<Change<Children>> Split(Unit pageHeight, Unit spaceLeftToEndPage)
        {
            var signal = TryFitTo(pageHeight, spaceLeftToEndPage);

            if (signal.OperationWasNotAllowed)
                return new Stop<Change<Children>>();

            var upper = new Children(from change in signal.Result
                                     from line in change
                                     where line.Top < spaceLeftToEndPage
                                     select line);

            var lower = new Children(from change in signal.Result
                                     from line in change
                                     where line.Top >= spaceLeftToEndPage
                                     select line.MoveDown(-spaceLeftToEndPage));

            return new Changed<Children>(upper, lower);
            ;
        }
Exemplo n.º 2
0
        LayoutedElement LayoutElement(ElementSpecification element)
        {
            var hasDefinedWidth = element.InnerWidth != Unit.Undefined;
            var hasDefinedHeight = element.InnerHeight != Unit.Undefined;

            if (element.Children.Any())
            {
                var verticalSpaceForChildren = hasDefinedWidth ? element.InnerWidth : containerInnerWidth - element.Edge.TotalHorizontal;
                var heightForChildren = hasDefinedHeight ? element.InnerHeight : Unit.Max(containerInnerHeight - element.Edge.TotalVertical, Unit.Zero);
                var lines = new LiningLayouter(verticalSpaceForChildren, heightForChildren).PositionElements(element.Children);
                var children = new Children(lines);

                return new LayoutedElement(element, children)
                {
                    Name = element.Name,
                    ForcedInnerWidth = hasDefinedWidth ? element.InnerWidth : children.OuterWidth,
                    ForcedInnerHeight = element.InnerHeight,
                };
            }

            if (hasDefinedWidth)
            {
                return new LayoutedElement(element, Children.Empty)
                {
                    Name = element.Name,
                    ForcedInnerWidth = element.InnerWidth,
                    ForcedInnerHeight = element.InnerHeight,
                };
            }

            return new LayoutedElement(element, Children.Empty)
            {
                Name = element.Name,
                ForcedInnerWidth = Unit.Undefined,
                ForcedInnerHeight = element.InnerHeight
            };
        }
Exemplo n.º 3
0
 public LayoutedElement(ElementSpecification specification, Children children)
 {
     this.specification = specification;
     this.children = children;
 }