using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Volian.Print.Library; using VEPROMS.CSLA.Library; namespace VEPROMS { public partial class frmPDFStatusForm : Form { private string _PDFPath; public string PDFPath { get { return _PDFPath; } set { _PDFPath = value; } } private PromsPrinter _MyPromsPrinter; public PromsPrinter MyPromsPrinter { get { return _MyPromsPrinter; } set { _MyPromsPrinter = value; } } public frmPDFStatusForm(ItemInfo myItem, string rev, string revDate, string watermark, bool debugOutput, string backgroundFolder, bool openPDF, string pdfPath) { InitializeComponent(); MyPromsPrinter = new PromsPrinter(myItem, rev, revDate, watermark, debugOutput, backgroundFolder, openPDF); PDFPath = pdfPath; this.Text = "Creating PDF of " + myItem.DisplayNumber; } void pp_StatusChanged(object sender, PromsPrintStatusArgs args) { if (args.Type == PromsPrinterStatusType.ProgressSetup) pb.Maximum = args.Progress; else if (args.Type == PromsPrinterStatusType.Progress) { pb.Value = args.Progress; if (args.Progress == pb.Maximum) pb.Text = args.MyStatus; else pb.Text = string.Format("Processing {0} ({1} of {2})", args.MyStatus, args.Progress + 1, pb.Maximum); } MyStatus = args.MyStatus; } public string MyStatus { get { return lblStatus.Text; } set { lblStatus.Text = value; Application.DoEvents(); } } private void frmPDFStatusForm_Load(object sender, EventArgs e) { tmrRun.Enabled = true; } private void tmrRun_Tick(object sender, EventArgs e) { tmrRun.Enabled = false; MyPromsPrinter.StatusChanged += new PromsPrinterStatusEvent(pp_StatusChanged); DateTime tStart = DateTime.Now; string pdfFile = MyPromsPrinter.Print(PDFPath); DateTime tEnd = DateTime.Now; MyStatus = pdfFile + " created."; MyStatus = string.Format("{0} created in {1:0.} milliseconds", pdfFile, (TimeSpan.FromTicks(tEnd.Ticks - tStart.Ticks).TotalMilliseconds)); } } }