/// <summary> /// Initializes a new instance of the <see cref="T:Dt.Cells.Data.GcReportContext" /> class. /// </summary> /// <param name="report">The report.</param> /// <param name="dpi">The dpi.</param> public GcReportContext(GcReport report, int dpi) { this.upi = 0x48; this.pages = new List <List <GcPageBlock> >(); this.pageRects = new GcPageRectangles(); this.measure = new Utilities.MeasureUtility(UnitType.CentileInch, defaultFont); this.pageFooter = null; this.pageHeader = null; this.report = report; this.dpi = dpi; }
/// <summary> /// Generates the pages. /// </summary> /// <param name="context">The context</param> /// <param name="continuePage">If set to <c>true</c>, [continue page]</param> /// <param name="offset">The offset</param> /// <param name="pageHeaderOffset">The page header offset</param> /// <returns></returns> internal virtual bool GeneratePages(GcReportContext context, bool continuePage, ref double offset, ref double pageHeaderOffset) { int num; GcPageHeaderSection pageHeader = context.PageHeader; GcPageFooterSection pageFooter = context.PageFooter; GcSection.GcSectionCache pageHeaderCache = context.PageHeaderCache; GcSection.GcSectionCache pageFooterCache = context.PageFooterCache; List <int> horizontalPageBreaks = this.GetHorizontalPageBreaks(); GcSection.GcSectionCache cache = base.GetCache(context); Windows.Foundation.Size allSize = base.GetAllSize(cache); PaperCutter cutter = new PaperCutter((int)context.PageRects.CropRectangle.Height, (int)allSize.Height, (IEnumerable <int>)horizontalPageBreaks); bool flag = this is IGcAllowAppendixSection; if (flag) { if (pageHeader != null) { cutter.MaxLength -= (int)pageHeader.GetAllSize(pageHeaderCache).Height; } if (pageFooter != null) { cutter.MaxLength -= (int)pageFooter.GetAllSize(pageFooterCache).Height; } } if (this.PageBreakBefore || (offset >= cutter.MaxLength)) { continuePage = false; } if (!continuePage) { offset = 0.0; pageHeaderOffset = 0.0; } List <GcPageBlock> list2 = (continuePage && (context.Pages.Count > 0)) ? context.Pages[context.Pages.Count - 1] : new List <GcPageBlock>(); if (continuePage) { cutter.AddBreakIfFirst((int)(cutter.MaxLength - offset)); } object buildInControlState = this.CreateBuildInControlState(context); double num2 = offset; bool horizontal = false; int num3 = 0; while (cutter.Next(out num) || this.HasMorePage(buildInControlState, horizontal)) { int num6; List <int> verticalPageBreaks = this.GetVerticalPageBreaks(); int width = (int)allSize.Width; if (flag) { width = Math.Max(width, context.PageHeaderFooterMaxWidth); } PaperCutter cutter2 = new PaperCutter((int)context.PageRects.CropRectangle.Width, width, (IEnumerable <int>)verticalPageBreaks); int num5 = 0; while (cutter2.Next(out num6) || this.HasMorePage(buildInControlState, horizontal)) { if (num5 >= list2.Count) { list2.Add(context.CreateNewPage()); } GcPageBlock block = list2[num5]; int x = cutter2.Current - num6; int y = cutter.Current - num; int height = 0; if (flag) { if ((pageHeader != null) && (block.PageHeader == null)) { height = (int)pageHeader.GetAllSize(pageHeaderCache).Height; } if (pageFooter != null) { num3 = (int)pageFooter.GetAllSize(pageFooterCache).Height; } if ((height + num3) >= num) { num3 = 0; } if ((height + num3) >= num) { height = 0; } } else if ((pageFooter != null) && (block.PageFooter != null)) { num3 = (int)pageFooter.GetAllSize(pageFooterCache).Height; if ((height + num3) >= num) { num3 = 0; } } GcRangeBlock block2 = base.GetRange(context, x, y, num6, num, cache, buildInControlState, horizontal, continuePage); if (flag) { if (((pageHeader != null) && (block.PageHeader == null)) && (height > 0)) { block.PageHeader = pageHeader.GetRange(context, pageHeader.HorizontalExtend ? x : 0, 0, (int)context.PageRects.PageHeaderRectangle.Width, (int)context.PageRects.PageHeaderRectangle.Height, pageHeaderCache, buildInControlState, horizontal, continuePage); if (continuePage) { GcRangeBlock block1 = block.PageHeader; block1.Y += pageHeaderOffset; } } if (((pageFooter != null) && (block.PageFooter == null)) && (num3 > 0)) { block.PageFooter = pageFooter.GetRange(context, pageFooter.HorizontalExtend ? x : 0, 0, (int)context.PageRects.PageFooterRectangle.Width, (int)context.PageRects.PageFooterRectangle.Height, pageFooterCache, buildInControlState, horizontal, continuePage); block.PageFooter.Y = ((int)context.PageRects.CropRectangle.Height) - num3; } } if ((context.TopMargin != null) && (block.TopMargin == null)) { block.TopMargin = context.TopMargin.GetRange(context, context.TopMargin.HorizontalExtend ? x : 0, 0, (int)context.PageRects.TopMarginRectangle.Width, (int)context.PageRects.TopMarginRectangle.Height, context.TopMarginCache, buildInControlState, horizontal, continuePage); block.TopMargin.X = context.PageRects.TopMarginRectangle.X; block.TopMargin.Y = context.PageRects.TopMarginRectangle.Y; } if ((context.BottomMargin != null) && (block.BottomMargin == null)) { block.BottomMargin = context.BottomMargin.GetRange(context, context.BottomMargin.HorizontalExtend ? x : 0, 0, (int)context.PageRects.BottomMarginRectangle.Width, (int)context.PageRects.BottomMarginRectangle.Height, context.BottomMarginCache, buildInControlState, horizontal, continuePage); block.BottomMargin.X = context.PageRects.BottomMarginRectangle.X; block.BottomMargin.Y = context.PageRects.BottomMarginRectangle.Y; } block2.Y += height; if (continuePage) { block2.Y += num2; } if ((!flag && (pageFooter != null)) && (block.PageFooter != null)) { block.PageFooter.Y = block2.Y; block2.Y += num3; } block.Blocks.Add(block2); if (!horizontal) { offset = (num2 + block2.Height) + height; } num5++; horizontal = true; } pageHeaderOffset = 0.0; num2 = 0.0; horizontal = false; continuePage = false; if (!context.Pages.Contains(list2)) { context.Pages.Add(list2); } list2 = new List <GcPageBlock>(); } continuePage = !this.PageBreakAfter; if (continuePage && (offset >= (context.PageRects.CropRectangle.Height - num3))) { continuePage = !continuePage; } if (!continuePage) { offset = 0.0; } pageHeaderOffset = flag ? 0.0 : offset; return(continuePage); }
/// <summary> /// Generates the page blocks. /// </summary> public void GeneratePageBlocks() { this.pageHeader = this.Report.PageHeaderInner; this.pageFooter = this.Report.PageFooterInner; this.topMargin = this.Report.TopMarginInner; this.bottomMargin = this.Report.BottomMarginInner; if (this.pageHeader != null) { this.phCache = this.pageHeader.GetCache(this); this.pageHeaderFooterMaxWidth = Math.Max(this.pageHeaderFooterMaxWidth, (int)this.pageHeader.GetAllSize(this.phCache).Width); } if (this.pageFooter != null) { this.pfCache = this.pageFooter.GetCache(this); this.pageHeaderFooterMaxWidth = Math.Max(this.pageHeaderFooterMaxWidth, (int)this.pageFooter.GetAllSize(this.pfCache).Width); } if (this.topMargin != null) { this.tmCache = this.topMargin.GetCache(this); } if (this.bottomMargin != null) { this.bmCache = this.bottomMargin.GetCache(this); } List <GcMultiplePageSection> sortedSections = this.Report.GetSortedSections(); bool autoFit = this.Report.AutoFit; this.Report.RealZoom = this.Report.ZoomFactor; double realZoom = this.Report.RealZoom; double num2 = 0.1; bool flag2 = false; Label_014B: this.pages.Clear(); try { this.InitPageRectangles(); } catch (Exception exception) { throw new ArgumentOutOfRangeException(ResourceStrings.ReportingMarginError, exception); } bool continuePage = false; double offset = 0.0; double pageHeaderOffset = 0.0; for (int i = 0; i < sortedSections.Count; i++) { continuePage = sortedSections[i].GeneratePages(this, continuePage, ref offset, ref pageHeaderOffset); } if (autoFit) { bool flag4 = false; if ((this.Report.FitPagesTall != -1) && (this.pages.Count > this.Report.FitPagesTall)) { flag4 = true; } if (this.Report.FitPagesWide != -1) { int num6 = 0; using (List <List <GcPageBlock> > .Enumerator enumerator = this.pages.GetEnumerator()) { while (enumerator.MoveNext()) { num6 = Math.Max(enumerator.Current.Count, num6); } } if (num6 > this.Report.FitPagesWide) { flag4 = true; } } if ((flag4 || flag2) && ((this.Report.RealZoom > 0.1) && ((realZoom - num2) >= 0.05))) { flag2 = true; if (flag4) { realZoom = this.Report.RealZoom; } else { num2 = this.Report.RealZoom; } this.Report.RealZoom = (realZoom + num2) / 2.0; goto Label_014B; } if ((flag4 && ((realZoom - num2) < 0.05)) && (this.Report.RealZoom != num2)) { this.Report.RealZoom = num2; goto Label_014B; } } }