Ejemplo n.º 1
0
        public static LineSegment CreateLineSegment(
            this Stack <LineElement> fromElements,
            HorizontalSpace space,
            LineAlignment lineAlignment,
            double defaultLineHeight,
            PageVariables variables)
        {
            var overflow = lineAlignment == LineAlignment.Justify ? 2 : 0;
            var elements = fromElements
                           .GetElementsToFitMaxWidth(space.Width + overflow, variables)
                           .ToArray();

            return(new LineSegment(elements, lineAlignment, space, defaultLineHeight));
        }
Ejemplo n.º 2
0
        public LineSegment(
            IEnumerable <LineElement> elements,
            LineAlignment lineAlignment,
            HorizontalSpace space,
            double defaultLineHeight)
        {
            _elements        = elements.ToArray();
            _trimmedElements = _elements
                               .SkipWhile(e => e is SpaceElement) // skip leading spaces
                               .Reverse()
                               .SkipWhile(e => e is SpaceElement) // skip trailing spaces
                               .Reverse()
                               .ToArray();

            _lineAlignment = lineAlignment;
            _space         = space;

            var _lineHeight = _trimmedElements.MaxOrDefault(e => e.Size.Height, defaultLineHeight);

            this.Size = new Size(_space.Width, _lineHeight);
        }
Ejemplo n.º 3
0
 public PageContext Crop(HorizontalSpace space)
 => this.Crop(0, this.Region.Width - space.X - space.Width, 0, space.X);