/// <summary> /// Constructor /// </summary> /// <param name="report">report document</param> /// <param name="data">report data</param> /// <exception cref="ArgumentException">Flow document must have a specified page height</exception> /// <exception cref="ArgumentException">Flow document must have a specified page width</exception> /// <exception cref="ArgumentException">Flow document can have only one report header section</exception> /// <exception cref="ArgumentException">Flow document can have only one report footer section</exception> public ReportPaginator(ReportDocument report, ReportData data) { _report = report; _data = data; _flowDocument = report.CreateFlowDocument(); _pageSize = new Size(_flowDocument.PageWidth, _flowDocument.PageHeight); if (_flowDocument.PageHeight == double.NaN) throw new ArgumentException("Flow document must have a specified page height"); if (_flowDocument.PageWidth == double.NaN) throw new ArgumentException("Flow document must have a specified page width"); _dynamicCache = new ReportPaginatorDynamicCache(_flowDocument); ArrayList listPageHeaders = _dynamicCache.GetFlowDocumentVisualListByType(typeof(SectionReportHeader)); if (listPageHeaders.Count > 1) throw new ArgumentException("Flow document can have only one report header section"); if (listPageHeaders.Count == 1) _blockPageHeader = (SectionReportHeader)listPageHeaders[0]; ArrayList listPageFooters = _dynamicCache.GetFlowDocumentVisualListByType(typeof(SectionReportFooter)); if (listPageFooters.Count > 1) throw new ArgumentException("Flow document can have only one report footer section"); if (listPageFooters.Count == 1) _blockPageFooter = (SectionReportFooter)listPageFooters[0]; _paginator = ((IDocumentPaginatorSource)_flowDocument).DocumentPaginator; // remove header and footer in our working copy Block block = _flowDocument.Blocks.FirstBlock; while (block != null) { Block thisBlock = block; block = block.NextBlock; if ((thisBlock == _blockPageHeader) || (thisBlock == _blockPageFooter)) _flowDocument.Blocks.Remove(thisBlock); } // get report context values _reportContextValues = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(IInlineContextValue)); FillData(); }
// ReSharper restore InconsistentNaming /// <summary> /// Constructor /// </summary> /// <param name="report">report document</param> /// <param name="data">report data</param> /// <exception cref="ArgumentException">Flow document must have a specified page height</exception> /// <exception cref="ArgumentException">Flow document must have a specified page width</exception> /// <exception cref="ArgumentException">Flow document can have only one report header section</exception> /// <exception cref="ArgumentException">Flow document can have only one report footer section</exception> public ReportPaginator(ReportDocument report, ReportData data) { _report = report; _data = data; _flowDocument = report.CreateFlowDocument(); _pageSize = new Size(_flowDocument.PageWidth, _flowDocument.PageHeight); if (_flowDocument.PageHeight == double.NaN) { throw new ArgumentException("Flow document must have a specified page height"); } if (_flowDocument.PageWidth == double.NaN) { throw new ArgumentException("Flow document must have a specified page width"); } _dynamicCache = new ReportPaginatorDynamicCache(_flowDocument); ArrayList listPageHeaders = _dynamicCache.GetFlowDocumentVisualListByType(typeof(SectionReportHeader)); if (listPageHeaders.Count > 1) { throw new ArgumentException("Flow document can have only one report header section"); } if (listPageHeaders.Count == 1) { _blockPageHeader = (SectionReportHeader)listPageHeaders[0]; } ArrayList listPageFooters = _dynamicCache.GetFlowDocumentVisualListByType(typeof(SectionReportFooter)); if (listPageFooters.Count > 1) { throw new ArgumentException("Flow document can have only one report footer section"); } if (listPageFooters.Count == 1) { _blockPageFooter = (SectionReportFooter)listPageFooters[0]; } _paginator = ((IDocumentPaginatorSource)_flowDocument).DocumentPaginator; // remove header and footer in our working copy Block block = _flowDocument.Blocks.FirstBlock; while (block != null) { Block thisBlock = block; block = block.NextBlock; if ((thisBlock == _blockPageHeader) || (thisBlock == _blockPageFooter)) { _flowDocument.Blocks.Remove(thisBlock); } } // get report context values _reportContextValues = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(IInlineContextValue)); FillData(); }
// ReSharper restore InconsistentNaming /// <summary> /// Constructor /// </summary> /// <param name="report">report document</param> /// <param name="data">report data</param> /// <exception cref="ArgumentException">Flow document must have a specified page height</exception> /// <exception cref="ArgumentException">Flow document must have a specified page width</exception> /// <exception cref="ArgumentException">Flow document can have only one report header section</exception> /// <exception cref="ArgumentException">Flow document can have only one report footer section</exception> public ReportPaginator(ReportDocument report, ReportData data, Action<int, int> PageGeneratedCallBack = null, FlowDocument flowDocument = null) { _report = report; _data = data; _pageGeneratedCallBack = PageGeneratedCallBack; _flowDocument = flowDocument; if (_flowDocument == null) _flowDocument = report.CreateFlowDocument(); _pageSize = new Size(_flowDocument.PageWidth, _flowDocument.PageHeight); if (_flowDocument.PageHeight == double.NaN) throw new ArgumentException("Flow document must have a specified page height"); if (_flowDocument.PageWidth == double.NaN) throw new ArgumentException("Flow document must have a specified page width"); _dynamicCache = new ReportPaginatorDynamicCache(_flowDocument); ArrayList listPageHeaders = _dynamicCache.GetFlowDocumentVisualListByType(typeof(SectionReportHeader)); if (listPageHeaders.Count > 1) throw new ArgumentException("Flow document can have only one report header section"); if (listPageHeaders.Count == 1) _blockPageHeader = (SectionReportHeader)listPageHeaders[0]; ArrayList listPageFooters = _dynamicCache.GetFlowDocumentVisualListByType(typeof(SectionReportFooter)); if (listPageFooters.Count > 1) throw new ArgumentException("Flow document can have only one report footer section"); if (listPageFooters.Count == 1) _blockPageFooter = (SectionReportFooter)listPageFooters[0]; _paginator = ((IDocumentPaginatorSource)_flowDocument).DocumentPaginator; // remove header and footer in our working copy Block block = _flowDocument.Blocks.FirstBlock; while (block != null) { Block thisBlock = block; block = block.NextBlock; if ((thisBlock == _blockPageHeader) || (thisBlock == _blockPageFooter)) _flowDocument.Blocks.Remove(thisBlock); } // get report context values _reportContextValues = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(IInlineContextValue)); FillData(); /*Application.Current.Dispatcher.Invoke(new Action(() => { Window aa = new Window(); FlowDocumentPageViewer bb = new FlowDocumentPageViewer(); bb.Document = _flowDocument; aa.Content = bb; aa.SizeToContent = SizeToContent.WidthAndHeight; aa.ShowDialog(); }));*/ }
// ReSharper restore InconsistentNaming /// <summary> /// Constructor /// </summary> /// <param name="report">report document</param> /// <param name="data">report data</param> /// <exception cref="ArgumentException">Flow document must have a specified page height</exception> /// <exception cref="ArgumentException">Flow document must have a specified page width</exception> /// <exception cref="ArgumentException">Flow document can have only one report header section</exception> /// <exception cref="ArgumentException">Flow document can have only one report footer section</exception> public ReportPaginator(ReportDocument report, ReportData data, Action <int, int> PageGeneratedCallBack = null, FlowDocument flowDocument = null) { _report = report; _data = data; _pageGeneratedCallBack = PageGeneratedCallBack; _flowDocument = flowDocument; if (_flowDocument == null) { _flowDocument = report.CreateFlowDocument(); } _pageSize = new Size(_flowDocument.PageWidth, _flowDocument.PageHeight); if (_flowDocument.PageHeight == double.NaN) { throw new ArgumentException("Flow document must have a specified page height"); } if (_flowDocument.PageWidth == double.NaN) { throw new ArgumentException("Flow document must have a specified page width"); } _dynamicCache = new ReportPaginatorDynamicCache(_flowDocument); ArrayList listPageHeaders = _dynamicCache.GetFlowDocumentVisualListByType(typeof(SectionReportHeader)); if (listPageHeaders.Count > 1) { throw new ArgumentException("Flow document can have only one report header section"); } if (listPageHeaders.Count == 1) { _blockPageHeader = (SectionReportHeader)listPageHeaders[0]; } ArrayList listPageFooters = _dynamicCache.GetFlowDocumentVisualListByType(typeof(SectionReportFooter)); if (listPageFooters.Count > 1) { throw new ArgumentException("Flow document can have only one report footer section"); } if (listPageFooters.Count == 1) { _blockPageFooter = (SectionReportFooter)listPageFooters[0]; } _paginator = ((IDocumentPaginatorSource)_flowDocument).DocumentPaginator; // remove header and footer in our working copy Block block = _flowDocument.Blocks.FirstBlock; while (block != null) { Block thisBlock = block; block = block.NextBlock; if ((thisBlock == _blockPageHeader) || (thisBlock == _blockPageFooter)) { _flowDocument.Blocks.Remove(thisBlock); } } // get report context values _reportContextValues = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(IInlineContextValue)); FillData(); /*Application.Current.Dispatcher.Invoke(new Action(() => * { * Window aa = new Window(); * FlowDocumentPageViewer bb = new FlowDocumentPageViewer(); * bb.Document = _flowDocument; * aa.Content = bb; * aa.SizeToContent = SizeToContent.WidthAndHeight; * aa.ShowDialog(); * }));*/ }