コード例 #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="report">report document</param>
        /// <param name="data">multiple report data</param>
        /// <exception cref="ArgumentException">Need at least two ReportData objects</exception>
        public MultipleReportPaginator(ReportDocument report, IEnumerable <ReportData> data)
        {
            if (data == null)
            {
                throw new ArgumentException("Need at least two ReportData objects");
            }

            // create a list of report paginators and compute page counts
            _pageCount = 0;
            int dataCount = 0;

            foreach (ReportData rd in data)
            {
                if (rd == null)
                {
                    continue;
                }
                ReportPaginator paginator = new ReportPaginator(report, rd);
                _reportPaginators.Add(paginator);
                DocumentPage dp = paginator.GetPage(0);
                if ((dp != DocumentPage.Missing) && (dp.Size != Size.Empty))
                {
                    _pageSize = paginator.PageSize;
                }
                _firstPages.Add(dp); // just cache the generated first page
                _pageCount += paginator.PageCount;
                dataCount++;
            }
            if ((_reportPaginators.Count <= 0) || (dataCount < 2))
            {
                throw new ArgumentException("Need at least two ReportData objects");
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets a document page of the appropriate generated report
        /// </summary>
        /// <param name="pageNumber">page number</param>
        /// <returns>parsed DocumentPage</returns>
        public override DocumentPage GetPage(int pageNumber)
        {
            // find the appropriate paginator for the page
            int             currentPage    = 0;
            int             paginatorIndex = 0;
            ReportPaginator pagePaginator  = null;

            foreach (ReportPaginator paginator in _reportPaginators)
            {
                int pageCount = paginator.PageCount;
                if (pageNumber >= currentPage + pageCount)
                {
                    currentPage += pageCount;
                    paginatorIndex++;
                    continue;
                }
                pagePaginator = paginator;
                break;
            }
            if (pagePaginator == null)
            {
                return(DocumentPage.Missing);
            }

            DocumentPage dp;

            if (pageNumber == 0)
            {
                dp = _firstPages[paginatorIndex];
            }
            else
            {
                dp = pagePaginator.GetPage(pageNumber - currentPage);
            }
            if (dp == DocumentPage.Missing)
            {
                return(DocumentPage.Missing);
            }
            _pageSize = dp.Size;
            return(dp);
        }