diff --git a/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs b/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs index 9034fc6e..82a611bd 100644 --- a/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs +++ b/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs @@ -15,6 +15,20 @@ namespace VEPROMS { public partial class DlgPrintProcedure : DevComponents.DotNetBar.Office2007Form { + private bool _Automatic; + public bool Automatic + { + get { return _Automatic; } + set { _Automatic = value; } + } + private void RunAutomatic() + { + cbxDebugPagination.Checked = true; + cbxDebugText.Checked = true; + Application.DoEvents(); + CreatePDFs(); + this.Close(); + } private DocVersionInfo _DocVersionInfo = null; private bool _AllProcedures; private DocVersionConfig _DocVersionConfig; @@ -47,8 +61,23 @@ namespace VEPROMS get { return txbPdfLocationS.Text; } set { txbPdfLocationS.Text = value; } } + public DlgPrintProcedure(DocVersionInfo dvi, bool automatic) + { + _Automatic = automatic; + InitializeComponent(); + _AllProcedures = true; + _DocVersionConfig = dvi.DocVersionConfig; + _DocVersionInfo = dvi; + _MyProcedure = dvi.Procedures[0].MyProcedure; + btnCreatePDF.Text = "Create PDFs"; + HandleDocVersionSettings(); + PrepForAllOrOne(false); + // don't open all PDFs if doing All Procedures + //cbxOpenAfterCreate2.Checked = dvi.DocVersionConfig.Print_AlwaysViewPDFAfterCreate; + } public DlgPrintProcedure(DocVersionInfo dvi) { + _Automatic = false; InitializeComponent(); _AllProcedures = true; _DocVersionConfig = dvi.DocVersionConfig; @@ -98,11 +127,13 @@ namespace VEPROMS // If yes, the Change bar tab is the selected tab. if (_DocVersionConfig.Print_ChangeBar == PrintChangeBar.SelectBeforePrinting) { - DialogResult dr = MessageBox.Show("Do you want change bars?", "Change Bars", MessageBoxButtons.YesNo); + DialogResult dr = DialogResult.Yes; + if(!Automatic) + dr = MessageBox.Show("Do you want change bars?", "Change Bars", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { btnChgBarOn.PerformClick(); - tabControl1.SelectedTab = tbChangeBars; + if(!Automatic) tabControl1.SelectedTab = tbChangeBars; rbFormatDefault.PerformClick(); rbFormatDefault.Checked = true; // default to 'Format Default' } @@ -158,8 +189,18 @@ namespace VEPROMS private void DlgPrintProcedure_Load(object sender, EventArgs e) { SetupForProcedure(); + _MyTimer = new Timer(); + _MyTimer.Tick += new EventHandler(_MyTimer_Tick); + _MyTimer.Interval = 100; + _MyTimer.Enabled = true; } - + void _MyTimer_Tick(object sender, EventArgs e) + { + _MyTimer.Enabled = false; + BringToFront(); + if (Automatic) RunAutomatic(); + } + private Timer _MyTimer; private void SetupForProcedure() { this.Text = "Create PDF for " + ProcNum; @@ -343,13 +384,14 @@ namespace VEPROMS { SetupForProcedure(); this.Text = string.Format("Create PDF for {0} ({1} of {2})", myProc.DisplayNumber, ++i, n); - frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNum, RevDate, pw.ToString(), cbxDebug.Checked, cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked, PDFPath, cbd, txbPDFName.Text); + frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNum, RevDate, pw.ToString(), cbxDebug.Checked, cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked, PDFPath, cbd, txbPDFName.Text, new Point(Left,Bottom)); frmStatus.CloseWhenDone = true; + Application.DoEvents(); frmStatus.ShowDialog(); } } - this.Close(); - ShowDebugFiles(); + if(!Automatic) + ShowDebugFiles(); } private void CreateDebugFiles() { @@ -375,7 +417,7 @@ namespace VEPROMS // Determine change bar settings. First get from config & then see if override from dialog. // Also check that format allows override. ChangeBarDefinition cbd = DetermineChangeBarSettings(); - frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNum, RevDate, pw.ToString(), cbxDebug.Checked, cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked,PDFPath, cbd, txbPDFName.Text); + frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNum, RevDate, pw.ToString(), cbxDebug.Checked, cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked,PDFPath, cbd, txbPDFName.Text,new Point(Left,Bottom)); frmStatus.ShowDialog(); this.Close(); ShowDebugFiles(); @@ -442,6 +484,7 @@ namespace VEPROMS , TimeSpan.FromTicks(DateTime.Now.Ticks - dtStart.Ticks).TotalMinutes), "Printing Duration", MessageBoxButtons.OK, MessageBoxIcon.Information); } + this.Close(); } else CreatePDF(); diff --git a/PROMS/VEPROMS User Interface/frmPDFStatusForm.cs b/PROMS/VEPROMS User Interface/frmPDFStatusForm.cs index 795b6fdd..0c09c8bf 100644 --- a/PROMS/VEPROMS User Interface/frmPDFStatusForm.cs +++ b/PROMS/VEPROMS User Interface/frmPDFStatusForm.cs @@ -40,14 +40,15 @@ namespace VEPROMS get { return _OpenPDF; } set { _OpenPDF = value; } } - public frmPDFStatusForm(ItemInfo myItem, string rev, string revDate, string watermark, bool debugOutput, bool openPDF, bool overWrite, string pdfPath, ChangeBarDefinition cbd,string pdfFile) + private Point _NewLocation; + public frmPDFStatusForm(ItemInfo myItem, string rev, string revDate, string watermark, bool debugOutput, bool openPDF, bool overWrite, string pdfPath, ChangeBarDefinition cbd,string pdfFile, Point newLocation) { OpenPDF = openPDF; InitializeComponent(); MyPromsPrinter = new PromsPrinter(myItem, rev, revDate, watermark, debugOutput, pdfPath + @"\\Compare", false, overWrite, cbd, pdfFile);//openPDF); PDFPath = pdfPath; this.Text = "Creating PDF of " + myItem.DisplayNumber; - + _NewLocation = newLocation; } void pp_StatusChanged(object sender, PromsPrintStatusArgs args) { @@ -71,6 +72,7 @@ namespace VEPROMS private void frmPDFStatusForm_Load(object sender, EventArgs e) { + Location = _NewLocation; tmrRun.Enabled = true; } diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index 6b9d171b..355647cc 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -342,7 +342,38 @@ namespace VEPROMS if (VlnSettings.DemoMode) StepRTB.MyFontFamily = GetFamily("Bookman Old Style"); displaySearch1.Enter += new EventHandler(displaySearch1_Enter); ctrlAnnotationDetails.Enter += new EventHandler(ctrlAnnotationDetails_Enter); + RunAutomatic(); } + private void RunAutomatic() + { + string[] parameters = System.Environment.CommandLine.Split(" ".ToCharArray()); + bool ranAuto = false; + foreach (string parameter in parameters) + { + if(parameter.StartsWith("/P=")) + { + string[] dvstrs = parameter.Substring(3).Split(",".ToCharArray()); + foreach (string dvstr in dvstrs) + { + DocVersionInfo dvi = DocVersionInfo.Get(int.Parse(dvstr)); + if (dvi != null) + { + DlgPrintProcedure prnDlg = new DlgPrintProcedure(dvi,true); + prnDlg.ShowDialog(); + //prnDlg.FormClosed += new FormClosedEventHandler(prnDlg_FormClosed); + //while (!_RunNext) Application.DoEvents(); + ranAuto = true; + } + } + } + } + if(ranAuto) this.Close(); + } + private bool _RunNext = false; + //void prnDlg_FormClosed(object sender, FormClosedEventArgs e) + //{ + // _RunNext = true; + //} private FontFamily GetFamily(string name) { foreach (FontFamily ff in FontFamily.Families)