public PageDrawing(Pages pgs) { // Set up the tooltip _tt = new ToolTip(); _tt.Active = false; _tt.ShowAlways = true; _HitList = new List<HitListEntry>(); _SelectList = new List<PageItem>(); _LastZoom = 1; _pgs = pgs; // Get our graphics DPI Graphics ga = null; try { ga = this.CreateGraphics(); DpiX = ga.DpiX; DpiY = ga.DpiY; } catch { DpiX = DpiY = 96; } finally { if (ga != null) ga.Dispose(); } // force to double buffering for smoother drawing //this.SetStyle(ControlStyles.DoubleBuffer | // ControlStyles.UserPaint | // ControlStyles.AllPaintingInWmPaint, // true); this.DoubleBuffered = true; }
internal float HeightOfRows(Pages pgs, Row r) { if (this.Visibility != null && Visibility.IsHidden(pgs.Report, r)) { return 0; } return _TableRows.HeightOfRows(pgs, r); }
internal void RunPage(Pages pgs, Row row) { WorkClass wc = this.GetValue(pgs.Report); if (wc.OutputRow == row && wc.OutputPage == pgs.CurrentPage) return; Page p = pgs.CurrentPage; //we need to run through all parent groupings to see if there are groups that we are to repeat on new page float height = p.YOffset + HeightOfRows(pgs, row); if (height > pgs.BottomOfPage) { bool bRepeatedParent = this.RepeatOnNewPage; Table t = OwnerTable; if (Parent.GetType() == typeof(TableGroup)) { TableGroup tg = (TableGroup)Parent; TableGroups tmp = (TableGroups)tg.Parent; for (int i = 0; i < tmp.Items.Count; i++) { if (tmp.Items[i] == tg) //if we reached current header - break(no need to look at child groups) break; if (tmp.Items[i].Header._RepeatOnNewPage) { bRepeatedParent = true; break; } } } //if we have repeated parent group - we call RunPageHeader to repeat them //if current header is repeating too - we return(as we already put it) //if no - we put it to new page p = t.RunPageNew(pgs, p); if (bRepeatedParent) { t.RunPageHeader(pgs, row, false, null); if (this.RepeatOnNewPage) return; } } //this will add current header _TableRows.RunPage(pgs, row); wc.OutputRow = row; wc.OutputPage = pgs.CurrentPage; return; }
internal void RunPage(Pages pgs) { if (OwnerReport.Subreport != null) return; // don't process page footers for sub-reports if (_ReportItems == null) return; Report rpt = pgs.Report; rpt.TotalPages = pgs.PageCount; foreach (Page p in pgs) { rpt.CurrentPage = p; // needs to know for page header/footer expr processing p.YOffset = OwnerReport.PageHeight.Points - OwnerReport.BottomMargin.Points - this._Height.Points; p.XOffset = 0; pgs.CurrentPage = p; rpt.PageNumber = p.PageNumber; if (p.PageNumber == 1 && pgs.Count > 1 && !_PrintOnFirstPage) continue; // Don't put footer on the first page if (p.PageNumber == pgs.Count && !_PrintOnLastPage) continue; // Don't put footer on the last page _ReportItems.RunPage(pgs, null, OwnerReport.LeftMargin.Points); } }
/// <summary> /// Updates the current page and location based on the ReportItems /// that are above it in the report. /// </summary> /// <param name="pgs"></param> internal void SetPagePositionBegin(Pages pgs) { // Update the current page if (this._YParents != null) { ReportItem saveri=GetReportItemAbove(pgs.Report); if (saveri != null) { WorkClass wc = saveri.GetWC(pgs.Report); pgs.CurrentPage = wc.CurrentPage; pgs.CurrentPage.YOffset = wc.BottomPosition; } } else if (this.Parent.Parent is PageHeader) { pgs.CurrentPage.YOffset = OwnerReport.TopMargin.Points; } else if (this.Parent.Parent is PageFooter) { pgs.CurrentPage.YOffset = OwnerReport.PageHeight.Points - OwnerReport.BottomMargin.Points - OwnerReport.PageFooter.Height.Points; } else if (!(this.Parent.Parent is Body)) { // if not body then we don't need to do anything } else if (this.OwnerReport.Subreport != null) { // pgs.CurrentPage = this.OwnerReport.Subreport.FirstPage; // pgs.CurrentPage.YOffset = top; } else { pgs.CurrentPage = pgs.FirstPage; // if nothing above it (in body) then it goes on first page pgs.CurrentPage.YOffset = OwnerReport.TopOfPage; } return; }
internal virtual void RunPage(Pages pgs, Row row) { return; }
private void RunPageGroups(Pages pgs, WorkClass wc, List<GroupEntry> groupEntries) { Report rpt = pgs.Report; Page p = pgs.CurrentPage; float pagebottom = OwnerReport.BottomOfPage; // p.YOffset += (Top == null? 0: this.Top.Points); p.YOffset += this.RelativeY(rpt); float listoffset = GetOffsetCalc(pgs.Report) + LeftCalc(pgs.Report); float height; Row row; foreach (GroupEntry ge in groupEntries) { // set the group entry value int index; if (ge.Group != null) // groups? { ge.Group.ResetHideDuplicates(rpt); // reset duplicate checking index = ge.Group.GetIndex(rpt); // yes } else // no; must be main dataset index = 0; wc.Data.CurrentGroups[index] = ge; if (ge.NestedGroup.Count > 0) RunGroupsSetGroups(rpt, wc, ge.NestedGroup); if (ge.Group == null) { // need to run all the rows since no group defined for (int r=ge.StartRow; r <= ge.EndRow; r++) { row = wc.Data.Data[r]; height = HeightOfList(rpt, pgs.G, row); if (p.YOffset + height > pagebottom && !p.IsEmpty()) // need another page for this row? p = RunPageNew(pgs, p); // yes; if at end this page is empty float saveYoffset = p.YOffset; // this can be affected by other page items if (_ReportItems != null) _ReportItems.RunPage(pgs, row, listoffset); if (p == pgs.CurrentPage) // did subitems force new page? { // no use the height of the list p.YOffset = saveYoffset + height; } else { // got forced to new page; just add the padding on p = pgs.CurrentPage; // set to new page if (this.Style != null) { p.YOffset += this.Style.EvalPaddingBottom(rpt, row); } } } } else { // need to process just whole group as a List entry if (ge.Group.PageBreakAtStart && !p.IsEmpty()) p = RunPageNew(pgs, p); // pass the first row of the group row = wc.Data.Data[ge.StartRow]; height = HeightOfList(rpt, pgs.G, row); if (p.YOffset + height > pagebottom && !p.IsEmpty()) // need another page for this row? p = RunPageNew(pgs, p); // yes; if at end this page is empty float saveYoffset = p.YOffset; // this can be affected by other page items if (_ReportItems != null) _ReportItems.RunPage(pgs, row, listoffset); if (p == pgs.CurrentPage) // did subitems force new page? { // no use the height of the list p.YOffset = saveYoffset + height; } else { // got forced to new page; just add the padding on p = pgs.CurrentPage; // set to new page if (this.Style != null) { p.YOffset += this.Style.EvalPaddingBottom(rpt, row); } } if (ge.Group.PageBreakAtEnd || // need another page for next group? p.YOffset + height > pagebottom) { p = RunPageNew(pgs, p); // yes; if at end empty page will be cleaned up later } } RemoveWC(rpt); } }
internal float HeightOfRows(Pages pgs, Row r) { return(_TableRows.HeightOfRows(pgs, r)); }
internal void RunPage(Pages pgs, Row row, float xOffset) { SetXOffset(pgs.Report, xOffset); foreach (ReportItem ri in _Items) { ri.RunPage(pgs, row); } return; }
// we don't have paging turned on for xml public void RunPages(Pages pgs) { return; }
internal override void RunPage(Pages pgs, Row row) { Report r = pgs.Report; bool bHidden = IsHidden(r, row); SetPagePositionBegin(pgs); // Handle page breaking at start if (this.PageBreakAtStart && !IsTableOrMatrixCell(r) && !pgs.CurrentPage.IsEmpty() && !bHidden) { // force page break at beginning of dataregion pgs.NextOrNew(); pgs.CurrentPage.YOffset = OwnerReport.TopOfPage; } PageRectangle pr = new PageRectangle(); SetPagePositionAndStyle(r, pr, row); if (pr.SI.BackgroundImage != null) pr.SI.BackgroundImage.H = pr.H; // and in the background image if (!bHidden) { Page p = pgs.CurrentPage; p.AddObject(pr); if (_ReportItems != null) { float saveY = p.YOffset; // p.YOffset += (Top == null ? 0 : this.Top.Points); p.YOffset = pr.Y; // top of rectangle is base for contained report items _ReportItems.RunPage(pgs, row, GetOffsetCalc(pgs.Report) + LeftCalc(r)); p.YOffset = saveY; } // Handle page breaking at end if (this.PageBreakAtEnd && !IsTableOrMatrixCell(r) && !pgs.CurrentPage.IsEmpty()) { // force page break at beginning of dataregion pgs.NextOrNew(); pgs.CurrentPage.YOffset = OwnerReport.TopOfPage; } } // SetPagePositionEnd(pgs, pgs.CurrentPage.YOffset); SetPagePositionEnd(pgs, pr.Y + pr.H); }
internal override void RunPage(Pages pgs, Row row) { Report r = pgs.Report; if (IsHidden(r, row)) return; base.RunPage(pgs, row); // need to save the owner report and nest in this defintion ReportDefn saveReport = r.ReportDefinition; NeedPassword np = r.GetDataSourceReferencePassword; // get current password r.SetReportDefinition(_ReportDefn); r.Folder = _ReportDefn.ParseFolder; // folder needs to get set since the id of the report is used by the cache r.GetDataSourceReferencePassword = np; DataSourcesDefn saveDS = r.ParentConnections; if (this.MergeTransactions) r.ParentConnections = saveReport.DataSourcesDefn; else r.ParentConnections = null; r.SubreportDataRetrievalTriggerEvent(); bool bRows = true; if (_Parameters == null) { // When no parameters we only retrieve data once SubreportWorkClass wc = r.Cache.Get(this, "report") as SubreportWorkClass; if (wc == null) { // run report first time; bRows = r.RunGetData(null); if (!r.IsSubreportDataRetrievalDefined) // if use has defined subreportdataretrieval they might set data r.Cache.Add(this, "report", new SubreportWorkClass(bRows)); // so we can't cache } else bRows = wc.bRows; } else { SetSubreportParameters(r, row); // apply the parameters bRows = r.RunGetData(null); } SetPageLeft(r); // Set the Left attribute since this will be the margin for this report SetPagePositionBegin(pgs); float yOffset; if (bRows) // Only run subreport if have a row in some Dataset { // // Run the subreport -- this is the major effort in creating the display objects in the page // r.ReportDefinition.Body.RunPage(pgs); // create a the subreport items yOffset = pgs.CurrentPage.YOffset; } else { // Handle NoRows message string msg; if (this.NoRows != null) msg = this.NoRows.EvaluateString(pgs.Report, null); else msg = null; if (msg != null) { PageText pt = new PageText(msg); SetPagePositionAndStyle(pgs.Report, pt, null); if (pt.SI.BackgroundImage != null) pt.SI.BackgroundImage.H = pt.H; // and in the background image pgs.CurrentPage.AddObject(pt); yOffset = pt.Y + pt.H; } else yOffset = pgs.CurrentPage.YOffset; } r.SetReportDefinition(saveReport); // restore the current report r.ParentConnections = saveDS; // restore the data connnections SetPagePositionEnd(pgs, yOffset); }
internal void RunPage(Pages pgs, Row row) { RunPage(pgs, row, false); }
public void RunPages(Pages pages) { //loop thru the pages foreach (Page page in pages) { //set the page height pageHeight = (int)report.ReportDefinition.PageHeight.Points; //set the page size in the document and create a new document page document.SetPageSize(new iTextSharp.text.Rectangle(report.ReportDefinition.PageWidth.Points, report.ReportDefinition.PageHeight.Points)); document.NewPage(); //process the page processPage(pages, page); } }
internal override void RunPage(Pages pgs, Row row) { Report rpt = pgs.Report; if (IsHidden(pgs.Report, row)) return; SetPagePositionBegin(pgs); // Build the Chart bitmap, along with data regions Page p = pgs.CurrentPage; ICustomReportItem cri = null; Bitmap bm = null; try { cri = EngineConfig.CreateCustomReportItem(_Type); SetProperties(pgs.Report, row, cri); int width = WidthCalc(rpt, pgs.G) - (Style == null? 0 : (Style.EvalPaddingLeftPx(rpt, row) + Style.EvalPaddingRightPx(rpt, row))); int height = RSize.PixelsFromPoints(this.HeightOrOwnerHeight) - (Style == null? 0 : (Style.EvalPaddingTopPx(rpt, row) + Style.EvalPaddingBottomPx(rpt, row))); bm = new Bitmap(width, height); cri.DrawImage(bm); MemoryStream ostrm = new MemoryStream(); // 06122007AJM Changed to use high quality JPEG encoding //bm.Save(ostrm, IMAGEFORMAT); // generate a jpeg TODO: get png to work with pdf System.Drawing.Imaging.ImageCodecInfo[] info; info = ImageCodecInfo.GetImageEncoders(); EncoderParameters encoderParameters; encoderParameters = new EncoderParameters(1); // 20022008 AJM GJL - Using centralised image quality encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, ImageQualityManager.CustomImageQuality); System.Drawing.Imaging.ImageCodecInfo codec = null; for (int i = 0; i < info.Length; i++) { if (info[i].FormatDescription == "JPEG") { codec = info[i]; break; } } bm.Save(ostrm, codec, encoderParameters); byte[] ba = ostrm.ToArray(); ostrm.Close(); PageImage pi = new PageImage(IMAGEFORMAT, ba, width, height); // Create an image pi.Sizing = ImageSizingEnum.Clip; // RunPageRegionBegin(pgs); SetPagePositionAndStyle(rpt, pi, row); if (pgs.CurrentPage.YOffset + pi.Y + pi.H >= pgs.BottomOfPage && !pgs.CurrentPage.IsEmpty()) { // force page break if it doesn't fit on the page pgs.NextOrNew(); pgs.CurrentPage.YOffset = OwnerReport.TopOfPage; if (this.YParents != null) pi.Y = 0; } p = pgs.CurrentPage; p.AddObject(pi); // Put image onto the current page // RunPageRegionEnd(pgs); if (!this.PageBreakAtEnd && !IsTableOrMatrixCell(rpt)) { float newY = pi.Y + pi.H; p.YOffset += newY; // bump the y location } SetPagePositionEnd(pgs, pi.Y + pi.H); } catch (Exception ex) { rpt.rl.LogError(8, string.Format("Exception in CustomReportItem handling: {0}", ex.Message)); } finally { if (cri != null) cri.Dispose(); } return; }
internal void RunPage(Pages pgs, Row row) { // todo: visibility on the column should really only be evaluated once at the beginning // of the table processing; also this doesn't account for the affect of colspan correctly // where if any of the spanned columns are visible the value would show?? TableColumn tc = _OwnerTable.TableColumns[_ColIndex]; if (tc.Visibility != null && tc.Visibility.IsHidden(pgs.Report, row)) // column visible? return; // no nothing to do _ReportItems.Items[0].RunPage(pgs, row); return; }
internal override void RunPage(Pages pgs, Row row) { Report r = pgs.Report; if (IsHidden(r, row)) return; WorkClass wc = GetValue(r); wc.Data = GetFilteredData(r, row); SetPagePositionBegin(pgs); if (!AnyRowsPage(pgs, wc.Data)) // if no rows return return; // nothing left to do RunPageRegionBegin(pgs); RunSetGrouping(pgs.Report, wc); RunPageGroups(pgs, wc, wc.Groups); RunPageRegionEnd(pgs); SetPagePositionEnd(pgs, pgs.CurrentPage.YOffset); RemoveValue(r); }
public void RunPages(Pages pgs) // we don't have paging turned on for xml { return; }
// we don't have paging turned on for html public void RunPages(Pages pgs) { }
internal void RunPage(Pages pgs, Row row) { Page p = pgs.CurrentPage; if (p.YOffset + HeightOfRows(pgs, row) > pgs.BottomOfPage) { p = OwnerTable.RunPageNew(pgs, p); OwnerTable.RunPageHeader(pgs, row, false, null); } _TableRows.RunPage(pgs, row); return; }
internal Page RunPageNew(Pages pgs, Page p) { if (p.IsEmpty()) // if the page is empty it won't help to create another one return p; // Do we need a new page or have should we fill out more body columns Body b = OwnerReport.Body; int ccol = b.IncrCurrentColumn(pgs.Report); // bump to next column float top = OwnerReport.TopOfPage; // calc top of page if (ccol < b.Columns) { // Stay on same page but move to new column p.XOffset = ((OwnerReport.Width.Points + b.ColumnSpacing.Points) * ccol); p.YOffset = top; p.SetEmpty(); // consider this page empty } else { // Go to new page b.SetCurrentColumn(pgs.Report, 0); pgs.NextOrNew(); p = pgs.CurrentPage; p.YOffset = top; p.XOffset = 0; } return p; }
/// <summary> /// Call LoadPageIfNeeded when a routine requires the report to be loaded in order /// to fulfill the request. /// </summary> private void LoadPageIfNeeded() { if (_pgs == null) { Cursor savec=null; System.Threading.Thread t=null; try { // 15052008 AJM - Updating Render notification window - This could be improved to show current action in the future if (_ShowWaitDialog) { t = new System.Threading.Thread(new System.Threading.ThreadStart(showWait)); t.Start(); } _InLoading = true; savec = this.Cursor; // this could take a while so put up wait cursor this.Cursor = Cursors.WaitCursor; _pgs = GetPages(); _DrawPanel.Pgs = _pgs; CalcZoom(); // this could affect zoom } finally { _InLoading = false; if (savec != null) this.Cursor = savec; if (t != null) { int i = 0; while ((t.ThreadState & System.Threading.ThreadState.AbortRequested) != System.Threading.ThreadState.AbortRequested && (t.ThreadState & System.Threading.ThreadState.Aborted) != System.Threading.ThreadState.Aborted && (t.ThreadState & System.Threading.ThreadState.Stopped) != System.Threading.ThreadState.Stopped && (t.ThreadState & System.Threading.ThreadState.StopRequested) != System.Threading.ThreadState.StopRequested) { try { t.Abort(); } catch //(Exception e) PJR don't declare variable as we aren't using it anyway. { } i++; } } } RdlViewer_Layout(this, null); // re layout based on new report } }
internal void SetPagePositionEnd(Pages pgs, float pos) { if (_TC != null || _InMatrix) // don't mess with page if part of a table or in a matrix return; WorkClass wc = GetWC(pgs.Report); wc.CurrentPage = pgs.CurrentPage; wc.BottomPosition = pos; }
public Viewer() { _SourceFileName=null; _SourceRdl=null; _Parameters=null; // parameters to run the report _pgs=null; // the pages of the report to view _loadFailed=false; _PageWidth=0; _PageHeight=0; _ReportDescription=null; _ReportAuthor=null; _ReportName=null; _zoom=-1; // force zoom to be calculated // Get our graphics DPI Graphics g = null; try { g = this.CreateGraphics(); DpiX = g.DpiX; DpiY = g.DpiY; } catch { DpiX = DpiY = 96; } finally { if (g != null) g.Dispose(); } _ScrollMode = ScrollModeEnum.Continuous; // Handle the controls _vScroll = new VScrollBar(); _vScroll.Scroll += new ScrollEventHandler(this.VerticalScroll); _vScroll.Enabled = false; // tooltip _vScrollToolTip = new ToolTip(); _vScrollToolTip.AutomaticDelay = 100; // .1 seconds _vScrollToolTip.AutoPopDelay = 1000; // 1 second _vScrollToolTip.ReshowDelay = 100; // .1 seconds _vScrollToolTip.InitialDelay = 10; // .01 seconds _vScrollToolTip.ShowAlways = false; _vScrollToolTip.SetToolTip(_vScroll, ""); _hScroll = new HScrollBar(); _hScroll.Scroll += new ScrollEventHandler(this.HorizontalScroll); _hScroll.Enabled = false; _DrawPanel = new PageDrawing(null); _DrawPanel.Parent = this; _DrawPanel.Paint += new PaintEventHandler(this.DrawPanelPaint); _DrawPanel.Resize += new EventHandler(this.DrawPanelResize); _DrawPanel.MouseWheel +=new MouseEventHandler(DrawPanelMouseWheel); _DrawPanel.KeyDown += new KeyEventHandler(DrawPanelKeyDown); _RunButton = new Button(); _RunButton.Parent = this; _RunButton.Text = "Run Report"; _RunButton.Width = 90; _RunButton.FlatStyle = FlatStyle.Flat; _RunButton.Click += new System.EventHandler(ParametersViewClick); _WarningButton = new PictureBox(); _WarningButton.Parent = this; _WarningButton.Width = 15; _WarningButton.Height = 15; _WarningButton.Paint +=new PaintEventHandler(_WarningButton_Paint); _WarningButton.Click += new System.EventHandler(WarningClick); ToolTip tip = new ToolTip(); tip.AutomaticDelay = 500; tip.ShowAlways = true; tip.SetToolTip(_WarningButton, "Click to see Report Warnings"); _ParameterPanel = new ScrollableControl(); _FindCtl = new ViewerFind(); _FindCtl.Height = 27; _FindCtl.Parent = this; _FindCtl.Viewer = this; _FindCtl.Visible = false; this.Layout +=new LayoutEventHandler(RdlViewer_Layout); this.SuspendLayout(); // Must be added in this order for DockStyle to work correctly this.Controls.Add(_FindCtl); this.Controls.Add(_DrawPanel); this.Controls.Add(_vScroll); this.Controls.Add(_hScroll); this.Controls.Add(_ParameterPanel); this.ResumeLayout(false); }
internal float HeightOfRows(Pages pgs, Row r) { return _TableRows.HeightOfRows(pgs, r); }
private void ParametersViewClick(object sender, System.EventArgs e) { Cursor.Current = Cursors.WaitCursor; System.Threading.Thread t = null; try { _RunButton.Enabled = false; _errorMsgs = null; // reset the error message if (this._Report == null) return; // Force parameters to get built foreach (Control ctl in _ParameterPanel.Controls) { if (ctl.Tag is UserReportParameter) { if (ctl is TextBox) this.ParametersTextValidated(ctl, new EventArgs()); else if (ctl is ComboBox) this.ParametersLeave(ctl, new EventArgs()); } } bool bFail = false; foreach (UserReportParameter rp in _Report.UserReportParameters) { if (rp.Prompt == null) continue; if (rp.Value == null && !rp.Nullable) { MessageBox.Show(string.Format("Parameter '{0}' is required but not provided.", rp.Prompt), "Report Parameter Missing"); bFail = true; } } if (bFail) return; if (_ShowWaitDialog) { t = new System.Threading.Thread(new System.Threading.ThreadStart(showWait)); t.Start(); } _pgs = GetPages(this._Report); _DrawPanel.Pgs = _pgs; _vScroll.Value = 0; CalcZoom(); _WarningButton.Visible = WarningVisible(); _DrawPanel.Invalidate(); } catch { // don't fail out; occasionally get thread abort exception } finally { _RunButton.Enabled = true; Cursor.Current = Cursors.Default; if (t != null) { int i = 0; while (t.ThreadState != System.Threading.ThreadState.AbortRequested && t.ThreadState != System.Threading.ThreadState.Aborted && t.ThreadState != System.Threading.ThreadState.Stopped && t.ThreadState != System.Threading.ThreadState.StopRequested) { t.Abort(); i++; } } } }
/// <summary> /// Forces the report to get rebuilt especially after changing parameters or data. /// </summary> public void Rebuild() { // Aulofee customization - start. Code added (2 lines) to avoid to execute twice GetPages and so the SQL query (custo end). if (_pgs == null) { LoadPageIfNeeded(); if (_Report == null) throw new Exception("Report must be loaded prior to Rebuild being called."); // Aulofee customization - start. Code added (2 lines) to avoid to execute twice GetPages and so the SQL query (custo end). } else _pgs = GetPages(this._Report); _DrawPanel.Pgs = _pgs; _vScroll.Value = 0; CalcZoom(); _DrawPanel.Invalidate(); }
internal bool AnyRowsPage(Pages pgs, Rows data) { if (data != null && data.Data != null && data.Data.Count > 0) return true; string msg; if (this.NoRows != null) msg = this.NoRows.EvaluateString(pgs.Report, null); else msg = null; if (msg == null) return false; // OK we have a message we need to put out RunPageRegionBegin(pgs); // still perform page break if needed PageText pt = new PageText(msg); SetPagePositionAndStyle(pgs.Report, pt, null); if (pt.SI.BackgroundImage != null) pt.SI.BackgroundImage.H = pt.H; // and in the background image pgs.CurrentPage.AddObject(pt); RunPageRegionEnd(pgs); // perform end page break if needed SetPagePositionEnd(pgs, pt.Y + pt.H); return false; }
internal void RunPage(Pages pgs, Rows rs, int start, int end, float footerHeight) { // if no rows output or rows just leave if (rs == null || rs.Data == null) return; if (this.Visibility != null && Visibility.IsHidden(pgs.Report, rs.Data[start])) return; // not visible Page p; Row row; for (int r=start; r <= end; r++) { p = pgs.CurrentPage; // this can change after running a row row = rs.Data[r]; float hrows = HeightOfRows(pgs, row); // height of all the rows in the details float height = p.YOffset + hrows; if (r == end) height += footerHeight; // on last row; may need additional room for footer if (height > pgs.BottomOfPage) { p = OwnerTable.RunPageNew(pgs, p); OwnerTable.RunPageHeader(pgs, row, false, null); _TableRows.RunPage(pgs, row, true); // force checking since header + hrows might be > BottomOfPage } else _TableRows.RunPage(pgs, row, hrows > pgs.BottomOfPage); } return; }
internal void RunPageRegionEnd(Pages pgs) { if (this.TC == null && this.PageBreakAtEnd && !pgs.CurrentPage.IsEmpty()) { // force page break at beginning of dataregion pgs.NextOrNew(); pgs.CurrentPage.YOffset = OwnerReport.TopOfPage; } }
/// <summary> /// Render all the objects in a page /// </summary> private void processPage(Pages pages, IEnumerable page) { //loop thru the items in the page foreach (PageItem pageItem in page) { if (pageItem.SI.BackgroundImage != null) { //put out any background image PageImage backgroundImage = pageItem.SI.BackgroundImage; float imageWidth = RSize.PointsFromPixels(pages.G, backgroundImage.SamplesW); float imageHeight = RSize.PointsFromPixels(pages.G, backgroundImage.SamplesH); int repeatX = 0; int repeatY = 0; float itemWidth = pageItem.W - (pageItem.SI.PaddingLeft + pageItem.SI.PaddingRight); float itemHeight = pageItem.H - (pageItem.SI.PaddingTop + pageItem.SI.PaddingBottom); switch (backgroundImage.Repeat) { case ImageRepeat.Repeat: repeatX = (int)Math.Floor(itemWidth / imageWidth); repeatY = (int)Math.Floor(itemHeight / imageHeight); break; case ImageRepeat.RepeatX: repeatX = (int)Math.Floor(itemWidth / imageWidth); repeatY = 1; break; case ImageRepeat.RepeatY: repeatY = (int)Math.Floor(itemHeight / imageHeight); repeatX = 1; break; case ImageRepeat.NoRepeat: default: repeatX = repeatY = 1; break; } //make sure the image is drawn at least 1 times repeatX = Math.Max(repeatX, 1); repeatY = Math.Max(repeatY, 1); float currX = pageItem.X + pageItem.SI.PaddingLeft; float currY = pageItem.Y + pageItem.SI.PaddingTop; float startX = currX; float startY = currY; for (int i = 0; i < repeatX; i++) { for (int j = 0; j < repeatY; j++) { currX = startX + i * imageWidth; currY = startY + j * imageHeight; addImage(backgroundImage.SI, currX, currY, imageWidth, imageHeight, RectangleF.Empty, backgroundImage.ImageData, null, pageItem.Tooltip); } } } else if (pageItem is PageTextHtml) { PageTextHtml pageTextHtml = pageItem as PageTextHtml; pageTextHtml.Build(pages.G); processPage(pages, pageTextHtml); continue; } else if (pageItem is PageText) { PageText pageText = pageItem as PageText; float[] textwidth; string[] measureStrings = RenderUtility.MeasureString(pageText, pages.G, out textwidth); addText(pageText.X, pageText.Y, pageText.W, pageText.H, measureStrings, pageText.SI, textwidth, pageText.CanGrow, pageText.HyperLink, pageText.NoClip, pageText.Tooltip); continue; } else if (pageItem is PageLine) { PageLine pageLine = pageItem as PageLine; addLine(pageLine.X, pageLine.Y, pageLine.X2, pageLine.Y2, pageLine.SI); continue; } else if (pageItem is PageEllipse) { PageEllipse pageEllipse = pageItem as PageEllipse; addEllipse(pageEllipse.X, pageEllipse.Y, pageEllipse.W, pageEllipse.H, pageEllipse.SI, pageEllipse.HyperLink); continue; } else if (pageItem is PageImage) { PageImage pageImage = pageItem as PageImage; //Duc Phan added 20 Dec, 2007 to support sized image RectangleF r2 = new RectangleF(pageImage.X + pageImage.SI.PaddingLeft, pageImage.Y + pageImage.SI.PaddingTop, pageImage.W - pageImage.SI.PaddingLeft - pageImage.SI.PaddingRight, pageImage.H - pageImage.SI.PaddingTop - pageImage.SI.PaddingBottom); //work rectangle RectangleF adjustedRect; RectangleF clipRect = RectangleF.Empty; switch (pageImage.Sizing) { case ImageSizingEnum.AutoSize: adjustedRect = new RectangleF(r2.Left, r2.Top, r2.Width, r2.Height); break; case ImageSizingEnum.Clip: adjustedRect = new RectangleF(r2.Left, r2.Top, RSize.PointsFromPixels(pages.G, pageImage.SamplesW), RSize.PointsFromPixels(pages.G, pageImage.SamplesH)); clipRect = new RectangleF(r2.Left, r2.Top, r2.Width, r2.Height); break; case ImageSizingEnum.FitProportional: float height; float width; float ratioIm = (float)pageImage.SamplesH / pageImage.SamplesW; float ratioR = r2.Height / r2.Width; height = r2.Height; width = r2.Width; if (ratioIm > ratioR) { //this means the rectangle width must be corrected width = height * (1 / ratioIm); } else if (ratioIm < ratioR) { //this means the rectangle height must be corrected height = width * ratioIm; } adjustedRect = new RectangleF(r2.X, r2.Y, width, height); break; case ImageSizingEnum.Fit: default: adjustedRect = r2; break; } if (pageImage.ImgFormat != System.Drawing.Imaging.ImageFormat.Wmf && pageImage.ImgFormat != System.Drawing.Imaging.ImageFormat.Emf) addImage(pageImage.SI, adjustedRect.X, adjustedRect.Y, adjustedRect.Width, adjustedRect.Height, clipRect, pageImage.ImageData, pageImage.HyperLink, pageImage.Tooltip); continue; } else if (pageItem is PageRectangle) { PageRectangle pageRectangle = pageItem as PageRectangle; addRectangle(pageRectangle.X, pageRectangle.Y, pageRectangle.W, pageRectangle.H, pageItem.SI, pageItem.HyperLink, pageItem.Tooltip); continue; } else if (pageItem is PagePie) { PagePie pagePie = pageItem as PagePie; addPie(pagePie.X, pagePie.Y, pagePie.W, pagePie.H, pageItem.SI, pageItem.HyperLink, pageItem.Tooltip); continue; } else if (pageItem is PagePolygon) { PagePolygon pagePolygon = pageItem as PagePolygon; addPolygon(pagePolygon.Points, pageItem.SI, pageItem.HyperLink); continue; } else if (pageItem is PageCurve) { PageCurve pageCurve = pageItem as PageCurve; addCurve(pageCurve.Points, pageItem.SI); continue; } } }
internal override void RunPage(Pages pgs, Row row) { Report rpt = pgs.Report; if (IsHidden(pgs.Report, row)) return; _ChartMatrix.RunReset(rpt); Rows _Data = GetFilteredData(rpt, row); SetMyData(rpt, _Data); SetPagePositionBegin(pgs); if (!AnyRowsPage(pgs, _Data)) // if no rows return return; // nothing left to do // Build the Chart bitmap, along with data regions Page p = pgs.CurrentPage; ChartBase cb=null; try { cb = RunChartBuild(rpt, row); // Build the chart if (!_isHYNEsWonderfulVector.EvaluateBoolean(rpt,row)) //AJM GJL 14082008 'Classic' Rendering { System.Drawing.Image im = cb.Image(rpt); // Grab the image int height = im.Height; // save height and width int width = im.Width; MemoryStream ostrm = new MemoryStream(); /* The following is a new image saving logic which will allow for higher * quality images using JPEG with 100% quality * 06122007AJM */ System.Drawing.Imaging.ImageCodecInfo[] info; info = ImageCodecInfo.GetImageEncoders(); EncoderParameters encoderParameters; encoderParameters = new EncoderParameters(1); // 20022008 AJM GJL - Centralised class with global encoder settings encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, ImageQualityManager.ChartImageQuality); System.Drawing.Imaging.ImageCodecInfo codec = null; for (int i = 0; i < info.Length; i++) { if (info[i].FormatDescription == "JPEG") { codec = info[i]; break; } } im.Save(ostrm, codec, encoderParameters); // 06122007AJM The follow has been replaced with the code above //im.Save(ostrm, info); // generate a jpeg TODO: get png to work with pdf byte[] ba = ostrm.ToArray(); ostrm.Close(); PageImage pi = new PageImage(IMAGEFORMAT, ba, width, height); // Create an image RunPageRegionBegin(pgs); SetPagePositionAndStyle(rpt, pi, row); pi.SI.BackgroundImage = null; // chart already has the background image if (pgs.CurrentPage.YOffset + pi.Y + pi.H >= pgs.BottomOfPage && !pgs.CurrentPage.IsEmpty()) { // force page break if it doesn't fit on the page pgs.NextOrNew(); pgs.CurrentPage.YOffset = OwnerReport.TopOfPage; if (this.YParents != null) pi.Y = 0; } p = pgs.CurrentPage; p.AddObject(pi); // Put image onto the current page RunPageRegionEnd(pgs); if (!this.PageBreakAtEnd && !IsTableOrMatrixCell(rpt)) { float newY = pi.Y + pi.H; p.YOffset += newY; // bump the y location } SetPagePositionEnd(pgs, pi.Y + pi.H); } else //Ultimate Rendering - Vector //AJM GJL 14082008 { System.Drawing.Imaging.Metafile im = cb.Image(rpt); // Grab the image //im could still be saved to a bitmap at this point //if we were to offer a choice of raster or vector, it would probably //be easiest to draw the chart to the EMF and then save as bitmap if needed int height = im.Height; // save height and width int width = im.Width; byte[] ba = cb._aStream.ToArray(); cb._aStream.Close(); PageImage pi = new PageImage(ImageFormat.Wmf, ba, width, height); RunPageRegionBegin(pgs); SetPagePositionAndStyle(rpt, pi, row); pi.SI.BackgroundImage = null; // chart already has the background image if (pgs.CurrentPage.YOffset + pi.Y + pi.H >= pgs.BottomOfPage && !pgs.CurrentPage.IsEmpty()) { // force page break if it doesn't fit on the page pgs.NextOrNew(); pgs.CurrentPage.YOffset = OwnerReport.TopOfPage; if (this.YParents != null) pi.Y = 0; } p = pgs.CurrentPage; //GJL 25072008 - Charts now draw in EMFplus format and not in bitmap. Still using the "PageImage" for the positioning //paging etc, but we don't add it to the page. // ****************************************************************************************************************** // New EMF Processing... we want to add the EMF Components to the page and not the actual EMF... EMF emf = new EMF(pi.X, pi.Y, width, height); emf.ProcessEMF(ba); //Process takes the bytearray of EMFplus data and breaks it down into lines,ellipses,text,rectangles //etc... There are still a lot of GDI+ functions I haven't got to (and some I have no intention of getting to!). foreach (PageItem emfItem in emf.PageItems) { p.AddObject(emfItem); } // ****************************************************************************************************************** //p.AddObject(pi); RunPageRegionEnd(pgs); pi.Y += p.YOffset; if (!this.PageBreakAtEnd && !IsTableOrMatrixCell(rpt)) { float newY = pi.Y + pi.H; p.YOffset += newY; // bump the y location } SetPagePositionEnd(pgs, pi.Y + pi.H); //our emf size seems to be bigger than the jpeg... } } catch (Exception ex) { rpt.rl.LogError(8, string.Format("Exception in Chart handling.\n{0}\n{1}", ex.Message, ex.StackTrace)); } finally { if (cb != null) cb.Dispose(); } return; }
internal void RunPage(Pages pgs, Row row) { // Start each row in the same location // e.g. if there are two embedded tables in cells they both start at same location Page savepg = pgs.CurrentPage; float savey = savepg.YOffset; Page maxpg = savepg; float maxy = savey; foreach (TableCell tc in _Items) { tc.RunPage(pgs, row); if (maxpg != pgs.CurrentPage) { // a page break if (maxpg.PageNumber < pgs.CurrentPage.PageNumber) { maxpg = pgs.CurrentPage; maxy = maxpg.YOffset; } } else if (maxy > pgs.CurrentPage.YOffset) { // maxy = maxy; TODO what was this meant to do } // restore the beginning start of the row pgs.CurrentPage = savepg; savepg.YOffset = savey; } pgs.CurrentPage = maxpg; savepg.YOffset = maxy; return ; }
public void RunPages(Pages pgs) { }