예제 #1
0
        public override void Prepare(PageContext pageContext, Func <PagePosition, PageContextElement, PageContext> nextPageContextFactory)
        {
            var currentPageContext = pageContext
                                     .Crop(_contentMargin.Top, _contentMargin.Right, 0, _contentMargin.Left);

            Func <PagePosition, PageContextElement, PageContext> onNewPage = (pagePosition, childElement) =>
            {
                currentPageContext = nextPageContextFactory(pagePosition, this);
                return(currentPageContext.Crop(0, _contentMargin.Right, 0, _contentMargin.Left));
            };

            Rectangle availableRegion = currentPageContext.Region;

            foreach (var child in _childs)
            {
                var context = new PageContext(currentPageContext.PagePosition, availableRegion, currentPageContext.PageVariables);
                child.Prepare(context, onNewPage);

                var lastPage = child.LastPageRegion.Region;

                availableRegion = currentPageContext
                                  .Region
                                  .Clip(lastPage.BottomLeft);
            }

            this.ResetPageRegionsFrom(_childs, _contentMargin);
        }