protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; if (FReport != null && FReport.Pages.Count > 0 && FReport.Pages[0] is ReportPage) { ReportPage page = FReport.Pages[0] as ReportPage; float zoom = FZoom; if (FullPagePreview) { float pageWidth = page.PaperWidth * Units.Millimeters; float pageHeight = page.PaperHeight * Units.Millimeters; zoom = Math.Min((Width - 20) / pageWidth, (Height - 20) / pageHeight); } FRPaintEventArgs args = new FRPaintEventArgs(g, zoom, zoom, FReport.GraphicCache); g.TranslateTransform(10, 10); page.Draw(args); g.TranslateTransform(-10, -10); } // draw control frame using (Pen p = new Pen(Color.FromArgb(127, 157, 185))) { g.DrawRectangle(p, 0, 0, Width - 1, Height - 1); } }
private void DrawPages(Graphics g) { if (Disabled) { return; } // draw visible pages int firstVisible = PreviewPages.FindFirstVisiblePage(Offset.Y); int lastVisible = PreviewPages.FindLastVisiblePage(Offset.Y + ClientSize.Height); for (int i = firstVisible; i <= lastVisible; i++) { Rectangle pageBounds = PreviewPages.GetPageBounds(i); pageBounds.Offset(-Offset.X, -Offset.Y); ReportPage page = PreparedPages.GetCachedPage(i); // draw shadow around page ShadowPaintInfo pi = new ShadowPaintInfo(); pi.Graphics = g; pi.Rectangle = new Rectangle(pageBounds.Left - 4, pageBounds.Top - 4, pageBounds.Width + 4, pageBounds.Height + 4); pi.Size = 5; ShadowPainter.Paint2(pi); // shift the origin because page.Draw draws at 0, 0 g.TranslateTransform((int)pageBounds.Left, (int)pageBounds.Top); FRPaintEventArgs e = new FRPaintEventArgs(g, Zoom, Zoom, GraphicCache); // draw page page.Draw(e); // draw search highlight if (SearchInfo != null && SearchInfo.Visible && SearchInfo.PageNo == i + 1) { page.DrawSearchHighlight(e, SearchInfo.ObjNo, SearchInfo.Ranges[SearchInfo.RangeNo]); } g.ResetTransform(); // draw border around active page if (i == PageNo - 1) { Pen borderPen = GraphicCache.GetPen(Preview.ActivePageBorderColor, 2, DashStyle.Solid); pageBounds.Inflate(-1, -1); g.DrawRectangle(borderPen, pageBounds); } } }
/// <inheritdoc/> protected override void ExportPage(int pageNo) { ReportPage page = GetPage(pageNo); float zoomX = ResolutionX / 96f; float zoomY = ResolutionY / 96f; int width = (int)(page.PaperWidth * Units.Millimeters * zoomX); int height = (int)(page.PaperHeight * Units.Millimeters * zoomY); int suffixDigits = Pages[Pages.Length - 1].ToString().Length; string fileSuffix = FFirstPage ? "" : (pageNo + 1).ToString("".PadLeft(suffixDigits, '0')); System.Drawing.Image image = null; if (SeparateFiles || IsMultiFrameTiff) { image = CreateImage(width, height, fileSuffix); if (IsMultiFrameTiff && FMasterTiffImage == null) { FMasterTiffImage = image; } } else { image = FBigImage; } using (Graphics g = Graphics.FromImage(image)) { if (image == FBigImage) { g.TranslateTransform(0, FCurOriginY); } g.ScaleTransform(1, zoomY / zoomX); page.Draw(new FRPaintEventArgs(g, zoomX, zoomX, Report.GraphicCache)); } if (SeparateFiles || IsMultiFrameTiff) { SaveImage(image, fileSuffix); } page.Dispose(); FCurOriginY += height; FFirstPage = false; }