public void PreviewReport(MetaFile nmetafile) { if (MetaFileControl == null) { fmetapr = new PreviewMetaFile(); MetaFileControl.Parent = PParent; MetaFileControl.BackColor = System.Drawing.SystemColors.AppWorkspace; MetaFileControl.Dock = System.Windows.Forms.DockStyle.Fill; } MetaFileControl.MetaFile = nmetafile; // nform.KeyDown += new KeyEventHandler(ExecuteKeyDown); }
private void PreviewWinForms_Closed(object sender, System.EventArgs e) { if (fmetapr != null) { if (fmetapr.MetaFile != null) { fmetapr.MetaFile.OnWorkProgress -= eventprogress; fmetapr.OnPageDrawn -= eventdrawn; fmetapr.MetaFile.StopWork(); } } fmetapr = null; }
private void PreviewWinForms2_FormClosed(object sender, FormClosedEventArgs e) { if (fmetapr != null) { try { fmetapr.Dispose(); } finally { fmetapr = null; } } }
/// <summary> /// Preview a MetaFile, it will show the form on screen /// </summary> public void PreviewReport(PreviewMetaFile metapreview) { metapr = metapreview; metapr.Parent = PParent; metapr.BackColor = System.Drawing.SystemColors.AppWorkspace; metapr.Dock = System.Windows.Forms.DockStyle.Fill; if (ModalWindow) { this.ShowDialog(); } else { this.Show(); } }
public void DoDispose() { if (fmetapr != null) { try { fmetapr.Dispose(); fmetapr = null; } finally { fmetapr = null; } } }
public override void Dispose() { #if REPMAN_DOTNET2 if (FPreviewWindow == null) { FPreviewWindow.Dispose(); FPreviewWindow = null; } if (previewmetafile != null) { previewmetafile.Dispose(); previewmetafile = null; } #else previewwindow.Dispose(); #endif base.Dispose(); }
private void PageDrawn(PreviewMetaFile prm) { RefreshPage(); }
/// <summary> /// Process a MetaFile, printing or previewing /// </summary> /// <param name="meta">MetaFile to print</param> override public bool Print(MetaFile meta) { overridedriver = null; DrawFound = (FPreview && (!SystemPreview)); if (!FPreview) { // Get printer data so it can be a dot matrix print option string drivername = PrinterConfig.GetDriverName(meta.PrinterSelect); if (drivername.Length > 0) { using (PrintOutText ntextdriver = new PrintOutText()) { ntextdriver.ForceDriverName = drivername; overridedriver = ntextdriver; if (PreparePrint(meta)) { bool doprint = true; if (ShowPrintDialog) { using (PrintDialog pdia = new PrintDialog()) { pdia.ShowHelp = true; pdia.ShowNetwork = true; pdia.AllowSomePages = true; // bug from Microsoft not showing dialog pdia.UseEXDialog = true; pdia.Document = doc; DialogResult aresult = pdia.ShowDialog(); doprint = aresult == DialogResult.OK; } } if (doprint) { ntextdriver.Print(meta); NewDocument(meta); string atext = ntextdriver.PrintResult.ToString(); //MessageBox.Show("Blank lines:"+ntextdriver.blanklines.ToString()); if (atext.Length > 0) { FBlackLines = FBlackLines + ntextdriver.blacklines; FWhiteLines = FWhiteLines + ntextdriver.whitelines; RawPrinterHelper.SendStringToPrinter(doc.PrinterSettings.PrinterName, atext); return(true); } EndDocument(meta); } else { return(false); } } } } } bool nresult = false; WMFOptimization oldoptimization = OptimizeWMF; try { DisableForwardOnly = false; if (!Preview) { OptimizeWMF = WMFOptimization.None; } else { // For preview, the metafile must save all pages if (!SystemPreview) { DisableForwardOnly = true; } } if (PreparePrint(meta)) { bool doprint = true; if (ShowPrintDialog) { using (PrintDialog pdia = new PrintDialog()) { // Bug from microsft not showing dialog in 64bit machines pdia.UseEXDialog = true; pdia.ShowHelp = true; pdia.ShowNetwork = true; pdia.AllowSomePages = true; pdia.Document = doc; DialogResult aresult = pdia.ShowDialog(); doprint = aresult == DialogResult.OK; } } if (doprint) { if (!Preview) { meta.ForwardOnly = true; try { doc.Print(); } catch (Exception E) { string printername = doc.PrinterSettings.PrinterName; throw new Exception("Printer error: " + printername + " " + E.Message); } } else { #if REPMAN_NOPREVIEW throw new Exception("Feature PrintPreviewDialog not supported"); #else if (SystemPreview) { using (PrintPreviewDialog previewdia = new PrintPreviewDialog()) { previewdia.Document = doc; previewdia.ShowDialog(); } } else { if (previewmetafile != null) { previewmetafile.Dispose(); previewmetafile = null; } previewmetafile = new PreviewMetaFile(); SetReportEvents(); previewmetafile.OptimizeWMF = OptimizeWMF; previewmetafile.MetaFile = meta; previewmetafile.SetDriver(this); PreviewWindow.WindowMode = WindowMode; PreviewWindow.ShowInTaskbar = ShowInTaskbar; PreviewWindow.LargeButtons = LargeButtons; PreviewWindow.PreviewReport(previewmetafile); } #endif } nresult = true; } } } finally { OptimizeWMF = oldoptimization; } return(nresult); }
/// <summary> /// Preview a MetaFile, it will show the form on screen /// </summary> public void PreviewReport(PreviewMetaFile metapreview) { try { Form nform = null; switch (WindowMode) { case PreviewWindowMode.ModalForm: using (nform = new Form()) { this.WindowForm = nform; MetaFileControl = metapreview; MetaFileControl.Parent = PParent; MetaFileControl.BringToFront(); MetaFileControl.BackColor = System.Drawing.SystemColors.AppWorkspace; MetaFileControl.Dock = System.Windows.Forms.DockStyle.Fill; nform.Width = 800; nform.Height = 600; nform.ShowIcon = false; nform.ShowInTaskbar = false; nform.Controls.Add(this); try { nform.KeyDown += new KeyEventHandler(ExecuteKeyDown); nform.KeyPreview = true; nform.ShowDialog(); } finally { this.WindowForm = null; nform.Controls.Remove(this); nform.Dispose(); } } break; case PreviewWindowMode.Form: nform = new Form(); MetaFileControl = metapreview; MetaFileControl.BringToFront(); MetaFileControl.BackColor = System.Drawing.SystemColors.AppWorkspace; MetaFileControl.Dock = System.Windows.Forms.DockStyle.Fill; MetaFileControl.Parent = PParent; this.WindowForm = nform; nform.Width = 800; nform.Height = 600; nform.ShowIcon = false; nform.ShowInTaskbar = false; nform.Controls.Add(this); nform.Show(); break; case PreviewWindowMode.Window: MetaFileControl = metapreview; break; } } finally { if (WindowMode == PreviewWindowMode.ModalForm) { PParent.Controls.Remove(MetaFileControl); } } }