override public void RunPage(Pages pgs, Row row) { Report r = pgs.Report; if (IsHidden(r, row)) { return; } TableWorkClass wc = GetValue(r); if (_IsGrid) { wc.Data = Rows.CreateOneRow(r); } else { wc.Data = GetFilteredData(r, row); } SetPagePositionBegin(pgs); if (!AnyRowsPage(pgs, wc.Data)) // if no rows return { return; // nothing left to do } RunPrep(r, row, wc); RunPageRegionBegin(pgs); Page p = pgs.CurrentPage; p.YOffset += this.RelativeY(r); // Calculate the xpositions of the columns TableColumns.CalculateXPositions(r, GetOffsetCalc(r) + LeftCalc(r), row); RunPageHeader(pgs, wc.Data.Data[0], true, null); if (wc.RecursiveGroup != null) { RunRecursiveGroupsPage(pgs, wc); } else { RunGroupsPage(pgs, wc, wc.Groups, wc.Data.Data.Count - 1, 0); } // Footer if (_Footer != null) { Row lrow = wc.Data.Data.Count > 0? wc.Data.Data[wc.Data.Data.Count - 1]: null; p = pgs.CurrentPage; // make sure the footer fits on the page if (p.YOffset + _Footer.HeightOfRows(pgs, lrow) > pgs.BottomOfPage) { p = RunPageNew(pgs, p); RunPageHeader(pgs, row, false, null); } _Footer.RunPage(pgs, lrow); } RunPageRegionEnd(pgs); SetPagePositionEnd(pgs, pgs.CurrentPage.YOffset); RemoveValue(r); }
override public void Run(IPresent ip, Row row) { Report r = ip.Report(); TableWorkClass wc = GetValue(r); if (_IsGrid) { wc.Data = Rows.CreateOneRow(r); } else { wc.Data = GetFilteredData(r, row); } if (!AnyRows(ip, wc.Data)) // if no rows return { return; // nothing left to do } RunPrep(r, row, wc); if (!ip.TableStart(this, row)) { return; // render doesn't want to continue } if (_TableColumns != null) { _TableColumns.Run(ip, row); } // Header if (_Header != null) { ip.TableHeaderStart(_Header, row); Row frow = wc.Data.Data.Count > 0? wc.Data.Data[0]: null; _Header.Run(ip, frow); ip.TableHeaderEnd(_Header, row); } // Body ip.TableBodyStart(this, row); if (wc.RecursiveGroup != null) { RunRecursiveGroups(ip, wc); } else { RunGroups(ip, wc.Groups, wc); } ip.TableBodyEnd(this, row); // Footer if (_Footer != null) { ip.TableFooterStart(_Footer, row); Row lrow = wc.Data.Data.Count > 0? wc.Data.Data[wc.Data.Data.Count - 1]: null; _Footer.Run(ip, lrow); ip.TableFooterEnd(_Footer, row); } ip.TableEnd(this, row); RemoveValue(r); }
// return an IEnumerable that represents the scope of the data protected RowEnumerable GetDataScope(Report rpt, Row row, out bool bSave) { bSave = true; RowEnumerable re = null; if (this._Scope != null) { Type t = this._Scope.GetType(); //150208AJM GJL Trying - And Succeeding!!! to get data from chart if (t == typeof(Chart)) { Chart c = (Chart)this._Scope; this._Scope = c.ChartMatrix; t = this._Scope.GetType(); } if (t == typeof(Grouping)) { bSave = false; Grouping g = (Grouping)(this._Scope); if (g.InMatrix) { Rows rows = g.GetRows(rpt); if (rows == null) { return(null); } re = new RowEnumerable(0, rows.Data.Count - 1, rows.Data, _LevelCheck); } else { if (row == null || row.R.CurrentGroups == null) // currentGroups can be null when reference Textbox in header/footer that has a scoped aggr function reference (TODO: this is a problem!) { return(null); } GroupEntry ge = row.R.CurrentGroups[g.GetIndex(rpt)]; re = new RowEnumerable(ge.StartRow, ge.EndRow, row.R.Data, _LevelCheck); } } else if (t == typeof(Matrix)) { bSave = false; Matrix m = (Matrix)(this._Scope); Rows mData = m.GetMyData(rpt); re = new RowEnumerable(0, mData.Data.Count - 1, mData.Data, false); } else if (t == typeof(string)) { // happens on page header/footer scope if (row != null) { re = new RowEnumerable(0, row.R.Data.Count - 1, row.R.Data, false); } bSave = false; } else if (row != null) { re = new RowEnumerable(0, row.R.Data.Count - 1, row.R.Data, false); } else { DataSetDefn ds = this._Scope as DataSetDefn; if (ds != null && ds.Query != null) { Rows rows = ds.Query.GetMyData(rpt); if (rows != null) { re = new RowEnumerable(0, rows.Data.Count - 1, rows.Data, false); } } } } else if (row != null) { re = new RowEnumerable(0, row.R.Data.Count - 1, row.R.Data, false); } return(re); }
void DrawPlotAreaDoughnut(Report rpt, Graphics g) { // Draw Plot area data int widthPie = Layout.PlotArea.Width; int maxHeight = Layout.PlotArea.Height; int maxPieSize = Math.Min(widthPie, maxHeight); int doughWidth = maxPieSize / 4 / CategoryCount; if (doughWidth < 2) { doughWidth = 2; // enforce minimum width } float startAngle; float endAngle; int pieLocX; int pieLocY; int pieSize; // Go and draw the pies int left = Layout.PlotArea.Left + (maxPieSize == widthPie? 0: (widthPie - maxPieSize) / 2); int top = Layout.PlotArea.Top + (maxPieSize == maxHeight? 0: (maxHeight - maxPieSize) / 2); for (int iRow = 1; iRow <= CategoryCount; iRow++) { pieLocX = left + ((iRow - 1) * doughWidth); pieLocY = top + ((iRow - 1) * doughWidth); double total = 0; // sum up for this category for (int iCol = 1; iCol <= SeriesCount; iCol++) { total += this.GetDataValue(rpt, iRow, iCol); } // Pie size decreases as we go in startAngle = 0.0f; pieSize = maxPieSize - ((iRow - 1) * doughWidth * 2); for (int iCol = 1; iCol <= SeriesCount; iCol++) { double v = this.GetDataValue(rpt, iRow, iCol); endAngle = (float)(startAngle + v / total * 360); DrawPie(g, rpt, GetSeriesBrush(rpt, iRow, iCol), new System.Drawing.Rectangle(pieLocX, pieLocY, pieSize, pieSize), iRow, iCol, startAngle, endAngle); startAngle = endAngle; } } // Now draw the center hole with the plot area style if (ChartDefn.PlotArea == null || ChartDefn.PlotArea.Style == null) { return; } pieLocX = left + (CategoryCount * doughWidth); pieLocY = top + (CategoryCount * doughWidth); pieSize = maxPieSize - (CategoryCount * doughWidth * 2); System.Drawing.Rectangle rect = new System.Drawing.Rectangle(pieLocX, pieLocY, pieSize, pieSize); Style s = ChartDefn.PlotArea.Style; Rows cData = ChartDefn.ChartMatrix.GetMyData(rpt); Row r = cData.Data[0]; s.DrawBackgroundCircle(rpt, g, r, rect); }
override public 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; }