internal float RunTextCalcHeight(Report rpt, Graphics g, Row row, PageTextHtml pth) { // normally only called when CanGrow is true Size s = Size.Empty; if (IsHidden(rpt, row)) { return(0); } object o = _Value.Evaluate(rpt, row); TypeCode tc = _Value.GetTypeCode(); int width = this.WidthCalc(rpt, g); if (this.Style != null) { width -= (Style.EvalPaddingLeftPx(rpt, row) + Style.EvalPaddingRightPx(rpt, row)); if (this.IsHtml(rpt, row)) { if (pth == null) { pth = new PageTextHtml(o == null? "": o.ToString()); SetPagePositionAndStyle(rpt, pth, row); } pth.Build(g); s.Height = RSize.PixelsFromPoints(pth.TotalHeight); } else { s = Style.MeasureString(rpt, g, o, tc, row, width); } } else // call the class static method { s = Style.MeasureStringDefaults(rpt, g, o, tc, row, width); } TextboxRuntime tbr = TextboxRuntime.GetTextboxRuntime(rpt, this); tbr.RunHeight = RSize.PointsFromPixels(g, s.Height); if (Style != null) { tbr.RunHeight += (Style.EvalPaddingBottom(rpt, row) + Style.EvalPaddingTop(rpt, row)); } return(tbr.RunHeight); }
internal int WidthCalc(Report rpt, Graphics g) { WorkClass wc = GetWC(rpt); int width; if (this._TC != null) { // must be part of a table Table t = _TC.OwnerTable; int colindex = _TC.ColIndex; // Calculate width: add up all columns within the column span width = 0; TableColumn tc; for (int ci = colindex; ci < colindex + _TC.ColSpan; ci++) { tc = (TableColumn)(t.TableColumns.Items[ci]); width += tc.Width.PixelsX; } } else if (wc.MC != null) { // must be part of a matrix width = g == null?RSize.PixelsFromPoints(wc.MC.Width) : RSize.PixelsFromPoints(g, wc.MC.Width); } else { // not part of a table or matrix if (Width != null) { width = Width.PixelsX; } else { width = RSize.PixelsFromPoints(WidthOrOwnerWidth(rpt)); } } return(width); }
override internal 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; }