Exemplo n.º 1
0
 public SectionContent(
     IEnumerable <PageContextElement> childs,
     ColumnsConfiguration columnsConfiguration,
     SectionContentBreak sectionBreak)
 {
     _childs = childs.ToArray();
     _columnsConfiguration = columnsConfiguration;
     this.SectionBreak     = sectionBreak;
 }
Exemplo n.º 2
0
        public void Prepare(
            PageRegion previousSection,
            PageRegion previousContent,
            SectionContentBreak previousBreak,
            Func <PageNumber, IPage> pageFactory)
        {
            var context = this.CreateInitialPageContext(previousSection, previousContent, previousBreak, pageFactory);

            Func <PagePosition, PageContextElement, PageContext> childContextRequest = (pagePosition, child)
                                                                                       => this.OnChildPageContextRequest(pagePosition, pageFactory);

            var spaceAfterPrevious = 0.0;

            foreach (var child in _childs)
            {
                child.Prepare(context, childContextRequest);
                var lastRegion = child.LastPageRegion;
                spaceAfterPrevious = child.CalculateSpaceAfter(_childs);
                context            = this.CreateContextForPagePosition(lastRegion.PagePosition, lastRegion.Region, spaceAfterPrevious, pageFactory);
            }

            this.ResetPageRegionsFrom(_childs);
        }
Exemplo n.º 3
0
        private PageContext CreateInitialPageContext(
            PageRegion previousSection,
            PageRegion previousContent,
            SectionContentBreak previousBreak,
            Func <PageNumber, IPage> pageFactory)
        {
            var spaceAfterPrevious = 0;

            switch (previousBreak)
            {
            case SectionContentBreak.None:
            {
                var pp = previousSection.PagePosition.SamePage(PageColumn.First, _columnsConfiguration.ColumnsCount);
                return(this.CreateContextForPagePosition(pp, previousSection.Region, spaceAfterPrevious, pageFactory));
            }

            case SectionContentBreak.Column:
            {
                var pp             = previousContent.PagePosition.Next();
                var occupiedRegion = pp.PageNumber == previousSection.PagePosition.PageNumber
                            ? previousSection.Region
                            : Rectangle.Empty;

                return(this.CreateContextForPagePosition(pp, occupiedRegion, spaceAfterPrevious, pageFactory));
            }

            case SectionContentBreak.Page:
            {
                var pp = previousContent.PagePosition.NextPage(PageColumn.First, _columnsConfiguration.ColumnsCount);
                return(this.CreateContextForPagePosition(pp, Rectangle.Empty, spaceAfterPrevious, pageFactory));
            }

            default:
                throw new RendererException("unhandled section break;");
            }
        }