// gets a preview image of the style public Image GetPreview(bool forceUpdate) { if (_preview == null || forceUpdate) { // draw style preview Bitmap bmp = new Bitmap(150, 105); StringFormat sf = StringFormat.GenericTypographic; using (Graphics g = Graphics.FromImage(bmp)) { // highest quality we can get g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; g.SmoothingMode = SmoothingMode.HighQuality; // white background Rectangle rc = new Rectangle(0, 0, bmp.Width, bmp.Height); g.FillRectangle(Brushes.White, rc); // content //rc.Inflate(-3, -3); rc.Height = 30; int height = ReportHeader.Render(g, Name, rc);//"Title", rc); rc.Offset(0, height - 1); height = PageHeader.Render(g, "Page Header", rc); rc.Offset(0, height - 1); height = GroupHeader.Render(g, "Group Header", rc); rc.Offset(0, height - 1); height = Detail.Render(g, " Detail", rc); rc.Offset(0, height - 1); using (Brush br = new SolidBrush(Detail.AlternateColor)) { g.FillRectangle(br, rc); } } // draw style preview into template Bitmap bmpTemplate = StyleSelector.BitmapFromStream("styleTemplate.bmp", Color.Red); using (Graphics g = Graphics.FromImage(bmpTemplate)) { Rectangle rc = new Rectangle(0, 71, bmp.Width, bmp.Height); rc.Offset(+2, +2); g.FillRectangle(Brushes.DarkGray, rc); rc.Offset(-2, -2); g.DrawImageUnscaled(bmp, rc); g.DrawRectangle(Pens.Black, rc); } // save image for next time _preview = bmpTemplate; } // return the value that was asked for return(_preview); }
private void NewPage(object previousRow, object row) { if (previousRow != null && PageFooter != null) { PageFooter.Render(previousRow, renderEngine, xOffset, PageLength - PageFooter.Height - BottomMargin, DefaultStyle); } renderEngine.NewPage(); yOffset = TopMargin; pagenumber++; if (previousRow == null && ReportHeader != null) { double growth = ReportHeader.Render(row, renderEngine, xOffset, yOffset, DefaultStyle); yOffset += ReportHeader.Height + growth; } if (PageHeader != null) { double growth = PageHeader.Render(row, renderEngine, xOffset, yOffset, DefaultStyle); yOffset += PageHeader.Height + growth; } if (ShowGrid) { Pen gridPen = new Pen(Color.LightGray, 0.5f); for (int i = 0; i < PrintableAreaWidth; i += 25) { ReportObjectLine l = new ReportObjectLine() { XLeft = i, XRight = i, YTop = 0, YBottom = PrintableAreaLength, Pen = gridPen }; l.Render(null, renderEngine, xOffset, yOffset, DefaultStyle, null); } for (int i = 0; i < PrintableAreaLength; i += 25) { ReportObjectLine l = new ReportObjectLine() { XLeft = 0, XRight = PrintableAreaWidth, YTop = i, YBottom = i, Pen = gridPen }; l.Render(null, renderEngine, xOffset, yOffset, DefaultStyle, null); } } }