121 lines
3.9 KiB
C#
121 lines
3.9 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 VEPROMS.CSLA.Library;
|
|
using System.IO;
|
|
using Volian.Svg.Library;
|
|
|
|
namespace PrintMSWord
|
|
{
|
|
public partial class frmPrintMSWord : Form
|
|
{
|
|
public frmPrintMSWord()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
public string MyStatus
|
|
{
|
|
get { return tsslStatus.Text; }
|
|
set { tsslStatus.Text = value; Application.DoEvents(); }
|
|
}
|
|
private frmAnalyze _MyAnalyze;
|
|
public frmAnalyze MyAnalyze
|
|
{
|
|
get
|
|
{
|
|
if (_MyAnalyze == null)
|
|
_MyAnalyze = new frmAnalyze();
|
|
return _MyAnalyze;
|
|
}
|
|
set { _MyAnalyze = value; }
|
|
}
|
|
private void analyzeToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
MyAnalyze.Show();
|
|
}
|
|
private void frmPrintMSWord_Load(object sender, EventArgs e)
|
|
{
|
|
FileInfo xmlFile = new FileInfo("Proms2010Print.xml");
|
|
if (xmlFile.Exists)
|
|
_MyProms2010Print = SvgSerializer<Proms2010Print>.ReadFile(xmlFile.FullName);
|
|
DocVersionInfo docVersion = GetDocVersionWithContent();
|
|
lbProcs.DataSource = docVersion.Procedures;
|
|
}
|
|
Proms2010Print _MyProms2010Print;
|
|
private DocVersionInfo GetDocVersionWithContent()
|
|
{
|
|
DocVersionInfoList dvList = DocVersionInfoList.Get();
|
|
foreach (DocVersionInfo docVersion in dvList)
|
|
if (docVersion.Procedures != null)
|
|
if (docVersion.Procedures[0].ItemID != 0)
|
|
return docVersion;
|
|
return null;
|
|
}
|
|
public ProcedureInfo MyProcedure
|
|
{
|
|
get { return lbProcs.SelectedValue as ProcedureInfo; }
|
|
}
|
|
private void lbProcs_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
CreatePDF();
|
|
}
|
|
|
|
private void CreatePDF()
|
|
{
|
|
tbTimings.Text = "";
|
|
Cursor saveCursor = this.Cursor;
|
|
this.Cursor = Cursors.WaitCursor;
|
|
Proms2010Procedure prProc = _MyProms2010Print.GetProcedure(MyProcedure);
|
|
PromsPrinter pp = new PromsPrinter(MyProcedure, prProc.Rev, prProc.RevDate, cbWatermark.Text);
|
|
pp.StatusChanged += new PromsPrinterStatusEvent(pp_StatusChanged);
|
|
_ElapsedTime = new Dictionary<PromsPrinterStatusType, TimeSpan>();
|
|
DateTime tStart = DateTime.Now;
|
|
string pdfFile = pp.Print(@"C:\TEMP\32Bit", _MyProms2010Print, null, this);
|
|
_ElapsedTime.Add(PromsPrinterStatusType.Total, DateTime.Now - tStart);
|
|
MyStatus = pdfFile + " created.";
|
|
this.Cursor = saveCursor;
|
|
ShowElapsedTime();
|
|
}
|
|
private void ShowElapsedTime()
|
|
{
|
|
foreach (PromsPrinterStatusType type in _ElapsedTime.Keys)
|
|
tbTimings.Text += "\r\n" + string.Format("'{0}',{1:0.}", type, _ElapsedTime[type].TotalMilliseconds);
|
|
}
|
|
private Dictionary<PromsPrinterStatusType, TimeSpan> _ElapsedTime;
|
|
private DateTime _LastTime=DateTime.Now;
|
|
private DateTime _StartTime = DateTime.Now;
|
|
void pp_StatusChanged(object sender, PromsPrintStatusArgs args)
|
|
{
|
|
if (args.Type == PromsPrinterStatusType.Start) _LastTime = _StartTime = args.When;
|
|
MyStatus = args.MyStatus;
|
|
TimeSpan delta = TimeSpan.FromTicks(args.When.Ticks - _LastTime.Ticks);
|
|
if (_ElapsedTime.ContainsKey(args.Type))
|
|
_ElapsedTime[args.Type] += delta;
|
|
else
|
|
_ElapsedTime.Add(args.Type, delta);
|
|
//if (tbTimings.Text != "") tbTimings.Text += "\r\n";
|
|
//tbTimings.Text += string.Format("{0},{1},'{2}','{3}'", TimeSpan.FromTicks(args.When.Ticks -_StartTime.Ticks).TotalSeconds, delta.TotalMilliseconds, args.Type, args.MyStatus);
|
|
_LastTime = args.When;
|
|
}
|
|
private void lbProcs_SelectedValueChanged(object sender, EventArgs e)
|
|
{
|
|
//ProcedureInfo proc = lbProcs.SelectedValue as ProcedureInfo;
|
|
if (MyProcedure == null) return;
|
|
if (_MyProms2010Print == null) return;
|
|
Proms2010Procedure prProc = _MyProms2010Print.GetProcedure(MyProcedure);
|
|
tbRev.Text = prProc == null ? "" : prProc.Rev;
|
|
tbRevDate.Text = prProc == null ? "" : prProc.RevDate;
|
|
tbPageCount.Text = prProc == null ? "" : prProc.PageCount.ToString();
|
|
}
|
|
|
|
private void pDFToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
CreatePDF();
|
|
}
|
|
|
|
}
|
|
} |