
Remove unused parameter from frmPDFStatusForm constructor Remove event handler for cbxCheckedChanged Set cbxCmpPRMSpfd to invisible since it is no longer needed Remove unused parameter from frmPDFStatusForm constructor Remove unused parameter from PromsPrinter constructor Rename log static field to _MyLog Set the Error Log file name to the Database name and the date of the previous Sunday - This will create a new error log file for each database each week
130 lines
3.5 KiB
C#
130 lines
3.5 KiB
C#
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;
|
|
using Volian.Base.Library;
|
|
|
|
namespace VEPROMS
|
|
{
|
|
public partial class frmPDFStatusForm : Form
|
|
{
|
|
private bool _CloseWhenDone = false;
|
|
public bool CloseWhenDone
|
|
{
|
|
get { return _CloseWhenDone; }
|
|
set { _CloseWhenDone = value; }
|
|
}
|
|
private string _PDFPath;
|
|
|
|
public string PDFPath
|
|
{
|
|
get { return _PDFPath; }
|
|
set { _PDFPath = value; }
|
|
}
|
|
private PromsPrinter _MyPromsPrinter;
|
|
|
|
public PromsPrinter MyPromsPrinter
|
|
{
|
|
get { return _MyPromsPrinter; }
|
|
set { _MyPromsPrinter = value; }
|
|
}
|
|
|
|
private bool _OpenPDF;
|
|
|
|
public bool OpenPDF
|
|
{
|
|
get { return _OpenPDF; }
|
|
set { _OpenPDF = value; }
|
|
}
|
|
private Point _NewLocation;
|
|
public frmPDFStatusForm(ItemInfo myItem, string rev, string revDate, string watermark, bool debugOutput, bool origPgBrk, bool openPDF, bool overWrite, string pdfPath, ChangeBarDefinition cbd,string pdfFile, Point newLocation)
|
|
{
|
|
OpenPDF = openPDF;
|
|
InitializeComponent();
|
|
// if the version number of PROMS is 1.0, then we are running a Demo version.
|
|
// When running a Demo version, force a "Sample" watermark when printing.
|
|
MyPromsPrinter = new PromsPrinter(myItem, rev, revDate, (VlnSettings.ReleaseMode.Equals("DEMO")) ? "Sample" : watermark, debugOutput, origPgBrk, pdfPath + @"\\Compare", false, overWrite, cbd, pdfFile);//openPDF);
|
|
PDFPath = pdfPath;
|
|
this.Text = "Creating PDF of " + myItem.DisplayNumber;
|
|
_NewLocation = newLocation;
|
|
}
|
|
public bool AllowAllWatermarks
|
|
{
|
|
get { return MyPromsPrinter.AllowAllWatermarks; }
|
|
set { MyPromsPrinter.AllowAllWatermarks = value; }
|
|
}
|
|
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)
|
|
{
|
|
Location = _NewLocation;
|
|
tmrRun.Enabled = true;
|
|
}
|
|
|
|
private string _PdfFile;
|
|
|
|
private void tmrRun_Tick(object sender, EventArgs e)
|
|
{
|
|
tmrRun.Enabled = false;
|
|
MyPromsPrinter.StatusChanged += new PromsPrinterStatusEvent(pp_StatusChanged);
|
|
DateTime tStart = DateTime.Now;
|
|
_PdfFile = MyPromsPrinter.Print(PDFPath);
|
|
if (_PdfFile == null)
|
|
{
|
|
this.Close();
|
|
return;
|
|
}
|
|
DateTime tEnd = DateTime.Now;
|
|
MyStatus = _PdfFile + " created.";
|
|
MyStatus = string.Format("{0} created in {1:0.} milliseconds", _PdfFile, (TimeSpan.FromTicks(tEnd.Ticks - tStart.Ticks).TotalMilliseconds));
|
|
if (OpenPDF)
|
|
{
|
|
System.Diagnostics.Process.Start(_PdfFile);
|
|
this.Close();
|
|
return;
|
|
}
|
|
btnOpenFolder.Visible = btnOpenPDF.Visible = true;
|
|
if (CloseWhenDone)
|
|
{
|
|
this.Close();
|
|
return;
|
|
}
|
|
}
|
|
|
|
private void btnOpenPDF_Click(object sender, EventArgs e)
|
|
{
|
|
System.Diagnostics.Process.Start(_PdfFile);
|
|
this.Close();
|
|
}
|
|
|
|
private void btnOpenFolder_Click(object sender, EventArgs e)
|
|
{
|
|
System.Diagnostics.Process.Start("Explorer", "/select," + _PdfFile);
|
|
this.Close();
|
|
}
|
|
|
|
}
|
|
} |