diff --git a/PROMS/fmtxml/EntireFormat.cs b/PROMS/fmtxml/EntireFormat.cs index 1fd1df7b..d14b6b98 100644 --- a/PROMS/fmtxml/EntireFormat.cs +++ b/PROMS/fmtxml/EntireFormat.cs @@ -8,8 +8,10 @@ namespace fmtxml { class EntireFormat { - public EntireFormat(string mxml) + private string MyPath; + public EntireFormat(string mxml, string path) { + MyPath = path; XmlDocument xmldoc = new XmlDocument(); XmlElement top = xmldoc.CreateElement("PlantFormat"); xmldoc.AppendChild(top); @@ -44,7 +46,7 @@ namespace fmtxml } XmlWriterSettings settingsout = new XmlWriterSettings(); settingsout.Encoding = Encoding.Unicode; - string outname = "e:\\fmtall\\" + mxml.Substring(mxml.IndexOf("\\")+1,mxml.Length - 13) + "all.xml"; + string outname = MyPath + @"\fmtall\" + mxml.Substring(mxml.IndexOf("\\")+1,mxml.Length - 13) + "all.xml"; XmlWriter xmlwrite = XmlWriter.Create(outname,settingsout); xmldoc.WriteContentTo(xmlwrite); xmlwrite.Close(); diff --git a/PROMS/fmtxml/FmtFileToXml.cs b/PROMS/fmtxml/FmtFileToXml.cs index f836b49d..20b63a9c 100644 --- a/PROMS/fmtxml/FmtFileToXml.cs +++ b/PROMS/fmtxml/FmtFileToXml.cs @@ -22,6 +22,8 @@ public struct FormatData { public string Name; public string PurchaseOptions; + public string PSI; + public string TPL; //public XtraFlgs XtraFlags; public VE_Font FontData; public Symbol[] Symbols; @@ -1393,8 +1395,10 @@ namespace fmtxml public FormatData BaseFormat; public bool HasBase; public FormatData MyFormat; - public FmtFileToXml(FmtFileToXml gendata, string nm) + public string MyPath; + public FmtFileToXml(FmtFileToXml gendata, string nm, string path) { + MyPath = path; if (gendata == null) HasBase = false; else @@ -1404,7 +1408,7 @@ namespace fmtxml } BuildDictionaryText(); fmtName = nm; - //if (fmtName.ToUpper() != "OHLP" && fmtName.ToUpper() != "BASE") return; + //if (fmtName.ToUpper() != "FNPDEV" && fmtName.ToUpper() != "BASE") return; try { LoadFormatFile(nm + ".fmt", ref SubXtraFlags); @@ -1953,7 +1957,7 @@ namespace fmtxml { return (i * 12); // row_in_points = input * 72/6, row = input * 12 } - public bool ReadInFmtFile(ref FormatData fmtdata, ref XtraFlgs XtraFlags) + public bool ReadInFmtFile(ref FormatData fmtdata, ref XtraFlgs XtraFlags, string fname) { int[] tmpshort3 = new int[3]; ArrayList stringoffsets = new ArrayList(); @@ -1986,7 +1990,15 @@ namespace fmtxml xtraflag[i] = brFmt.ReadInt16(); AddFlags(ref XtraFlags, i, xtraflag[i]); } - + // if this format has an associated PSI or TPL file, just read in the string & save + // it. + string otherfile = MyPath + @"\" + fname.Substring(0, fname.LastIndexOf(".")) + @".tpl"; + if (File.Exists(otherfile)) + fmtdata.TPL = File.ReadAllText(otherfile); + otherfile = MyPath + @"\" + fname.Substring(0, fname.LastIndexOf(".")) + @".ini"; + if (File.Exists(otherfile)) + fmtdata.PSI = File.ReadAllText(otherfile); + fmtdata.PurchaseOptions = ((E_PurchaseOptions)brFmt.ReadInt16()).ToString(); fmtdata.ProcData.ProcForeColor = "Black"; fmtdata.ProcData.ProcBackColor = "White"; @@ -3725,12 +3737,12 @@ namespace fmtxml string sResults = "fmt_xml\\" + lfmtname + "f.xml"; xsl.Transform(destfile, sResults); // Perform Transform - xsl.Load(Application.StartupPath + "\\removeempty.XSL"); - string sResults2 = "fmt_xml\\" + lfmtname + "xf.xml"; - xsl.Transform(sResults, sResults2); - File.Delete(sResults); - xsl.Transform(sResults2, sResults); - File.Delete(sResults2); + xsl.Load(Application.StartupPath + "\\removeempty.XSL"); + string sResults2 = "fmt_xml\\" + lfmtname + "xf.xml"; + xsl.Transform(sResults, sResults2); + File.Delete(sResults); + xsl.Transform(sResults2, sResults); + File.Delete(sResults2); } catch (Exception e) @@ -3794,9 +3806,9 @@ namespace fmtxml // read in data & put into correct place of structures. // for test string fnm = "E:\\proms.net\\exe\\fmtxml\\" + fname; - string fnm = "E:\\ve-proms\\format\\" + fname; + string fnm = MyPath + @"\" + fname; brFmt = new BinaryReader(File.Open(fnm, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite, FileShare.ReadWrite)); - bool success = ReadInFmtFile(ref fmtdata, ref BaseXtraFlags); + bool success = ReadInFmtFile(ref fmtdata, ref BaseXtraFlags, fname); if (!HasBase) InitSymbols(ref fmtdata); else fmtdata.Symbols = null; if (success) @@ -3813,17 +3825,17 @@ namespace fmtxml success = WriteOutXml(fmtdata); // For each sub-format, load the entire file & compare to parent contents - DirectoryInfo di = new DirectoryInfo("E:\\ve-proms\\format"); + DirectoryInfo di = new DirectoryInfo(MyPath); string substr = fname.Substring(0, fname.IndexOf('.')) + ".x*"; FileInfo[] fis = di.GetFiles(substr); foreach (FileInfo fi in fis) { //this.listBox1.Items.Add(fi.Name); fmtName = fi.Name; - fnm = "E:\\ve-proms\\format\\" + fi.Name; + fnm = MyPath + @"\" + fi.Name; brFmt = new BinaryReader(File.Open(fnm, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite, FileShare.ReadWrite)); FormatData subdata = new FormatData(); - success = ReadInFmtFile(ref subdata, ref SubXtraFlags); + success = ReadInFmtFile(ref subdata, ref SubXtraFlags, fi.Name); if (success) { DoStepInheritance(ref subdata.StepData); @@ -4061,7 +4073,8 @@ namespace fmtxml // Background/Deviation Documents - check for E_PurchaseOptions.(ENHANCEDBACKGROUNDS or ENHANCEDDEVIATIONS) // # - Related Caution or Note number // ~ - Linked Step Number - if ((po.IndexOf("ENHANCEDBACKGROUNDS")>-1) || (po.IndexOf("ENHANCEDDEVIATIONS")>-1)) + + if ((po.ToUpper().IndexOf("ENHANCEDBACKGROUNDS") > -1) || (po.ToUpper().IndexOf("ENHANCEDDEVIATIONS") > -1)) { wkstr = wkstr.Replace("#", "{LNK C/N Num}"); wkstr = wkstr.Replace("~", "{LNK Step Num}"); @@ -4125,6 +4138,8 @@ namespace fmtxml if (mainFmt.FontData.FontStyle == subFmt.FontData.FontStyle) subFmt.FontData.FontStyle = null; } if (mainFmt.PurchaseOptions == subFmt.PurchaseOptions) subFmt.PurchaseOptions = null; + if (mainFmt.PSI == subFmt.PSI) subFmt.PSI = null; + if (mainFmt.TPL == subFmt.TPL) subFmt.TPL = null; if (mainFmt.EditData.EMode == subFmt.EditData.EMode) subFmt.EditData.EMode = null; if (mainFmt.EditData.PromptForCautionType != null && mainFmt.EditData.PromptForCautionType == subFmt.EditData.PromptForCautionType) subFmt.EditData.PromptForCautionType = "null"; if (mainFmt.SectData.StepSectionData.TopRow == subFmt.SectData.StepSectionData.TopRow) subFmt.SectData.StepSectionData.TopRow = 0; diff --git a/PROMS/fmtxml/FmtToXml.cs b/PROMS/fmtxml/FmtToXml.cs index abed8621..5c5f3d81 100644 --- a/PROMS/fmtxml/FmtToXml.cs +++ b/PROMS/fmtxml/FmtToXml.cs @@ -437,8 +437,10 @@ namespace fmtxml private string fmtName; private VE_Font DefBaseFont; private VE_Font DefPlantFont; - public FmtToXml(string nm) + private string MyPath; + public FmtToXml(string nm, string path) { + MyPath = path; fmtName = nm; try { @@ -542,7 +544,7 @@ namespace fmtxml string str = null; // read in title. - string fnm = "E:\\ve-proms\\format\\"+fname; + string fnm = MyPath + @"\" + fname; Console.WriteLine(fname); brFmt = new BinaryReader(File.Open(fnm,System.IO.FileMode.Open,System.IO.FileAccess.ReadWrite,FileShare.ReadWrite)); short len = brFmt.ReadInt16(); @@ -659,7 +661,7 @@ namespace fmtxml string str = null; // read in title. - string fnm = "E:\\ve-proms\\format\\"+fname; + string fnm = MyPath + @"\" + fname; Console.WriteLine(fname); brFmt = new BinaryReader(File.Open(fnm,System.IO.FileMode.Open,System.IO.FileAccess.ReadWrite,FileShare.ReadWrite)); short len = brFmt.ReadInt16(); diff --git a/PROMS/fmtxml/Form1.cs b/PROMS/fmtxml/Form1.cs index d0f8efc1..4709b952 100644 --- a/PROMS/fmtxml/Form1.cs +++ b/PROMS/fmtxml/Form1.cs @@ -13,17 +13,24 @@ namespace fmtxml /// public class Form1 : System.Windows.Forms.Form { - private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button btnCvtPagDoc; private System.Windows.Forms.Label label1; - private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button btnExit; private System.Windows.Forms.ListBox listBox1; - private System.Windows.Forms.Button button3; - private System.Windows.Forms.Button button4; - private System.Windows.Forms.Button button5; - private C1.C1Pdf.C1PdfDocument c1PdfDocument1; - private System.Windows.Forms.Button button6; - private Button button7; - private Button button8; + private System.Windows.Forms.Button btnCvtGenmac; + private System.Windows.Forms.Button btnCvtXmlToSVG; + //private C1.C1Pdf.C1PdfDocument c1PdfDocument1; + private Button btnCvtFormat; + private Button btnMergeFmtPagDoc; + private Label lblPathFmt; + private Button btnBrowseFmt; + private TextBox tbFmtPath; + private TextBox tbGenmacPath; + private Button btnBrowseGenmac; + private Label lblPathGenmac; + private Label lblResult; + private TextBox tbResultPath; + private Button btnBrowseResult; /// /// Required designer variable. /// @@ -35,7 +42,9 @@ namespace fmtxml // Required for Windows Form Designer support // InitializeComponent(); - + tbFmtPath.Text = @"c:\16bit\ve-proms\format"; + tbGenmacPath.Text = @"C:\16bit\promsnt\genmac"; + tbResultPath.Text = @"c:\development\"; // // TODO: Add any constructor code after InitializeComponent call // @@ -63,125 +72,200 @@ namespace fmtxml /// private void InitializeComponent() { - this.button1 = new System.Windows.Forms.Button(); + this.btnCvtPagDoc = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); - this.button2 = new System.Windows.Forms.Button(); + this.btnExit = new System.Windows.Forms.Button(); this.listBox1 = new System.Windows.Forms.ListBox(); - this.button3 = new System.Windows.Forms.Button(); - this.button4 = new System.Windows.Forms.Button(); - this.button5 = new System.Windows.Forms.Button(); - this.c1PdfDocument1 = new C1.C1Pdf.C1PdfDocument(); - this.button6 = new System.Windows.Forms.Button(); - this.button7 = new System.Windows.Forms.Button(); - this.button8 = new System.Windows.Forms.Button(); + this.btnCvtGenmac = new System.Windows.Forms.Button(); + this.btnCvtXmlToSVG = new System.Windows.Forms.Button(); + this.btnCvtFormat = new System.Windows.Forms.Button(); + this.btnMergeFmtPagDoc = new System.Windows.Forms.Button(); + this.lblPathFmt = new System.Windows.Forms.Label(); + this.btnBrowseFmt = new System.Windows.Forms.Button(); + this.tbFmtPath = new System.Windows.Forms.TextBox(); + this.tbGenmacPath = new System.Windows.Forms.TextBox(); + this.btnBrowseGenmac = new System.Windows.Forms.Button(); + this.lblPathGenmac = new System.Windows.Forms.Label(); + this.lblResult = new System.Windows.Forms.Label(); + this.tbResultPath = new System.Windows.Forms.TextBox(); + this.btnBrowseResult = new System.Windows.Forms.Button(); this.SuspendLayout(); // - // button1 + // btnCvtPagDoc // - this.button1.Location = new System.Drawing.Point(8, 8); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(144, 48); - this.button1.TabIndex = 0; - this.button1.Text = "Convert Page and Doc Styles in format directory (Step 2)"; - this.button1.Click += new System.EventHandler(this.button1_Click); + this.btnCvtPagDoc.Location = new System.Drawing.Point(217, 64); + this.btnCvtPagDoc.Name = "btnCvtPagDoc"; + this.btnCvtPagDoc.Size = new System.Drawing.Size(201, 50); + this.btnCvtPagDoc.TabIndex = 0; + this.btnCvtPagDoc.Text = "Convert Page and Doc Styles in format directory (Step 2)"; + this.btnCvtPagDoc.Click += new System.EventHandler(this.btnCvtPagDoc_Click); // // label1 // - this.label1.Location = new System.Drawing.Point(8, 144); + this.label1.Location = new System.Drawing.Point(12, 236); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(168, 16); + this.label1.Size = new System.Drawing.Size(201, 19); this.label1.TabIndex = 1; this.label1.Text = "Converted:"; // - // button2 + // btnExit // - this.button2.Location = new System.Drawing.Point(512, 24); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(64, 24); - this.button2.TabIndex = 2; - this.button2.Text = "Exit"; - this.button2.Click += new System.EventHandler(this.button2_Click); + this.btnExit.Location = new System.Drawing.Point(610, 215); + this.btnExit.Name = "btnExit"; + this.btnExit.Size = new System.Drawing.Size(77, 27); + this.btnExit.TabIndex = 2; + this.btnExit.Text = "Exit"; + this.btnExit.Click += new System.EventHandler(this.btnExit_Click); // // listBox1 // - this.listBox1.Location = new System.Drawing.Point(8, 168); + this.listBox1.ItemHeight = 16; + this.listBox1.Location = new System.Drawing.Point(10, 258); this.listBox1.Name = "listBox1"; - this.listBox1.Size = new System.Drawing.Size(584, 407); + this.listBox1.Size = new System.Drawing.Size(700, 388); this.listBox1.TabIndex = 3; // - // button3 + // btnCvtGenmac // - this.button3.Location = new System.Drawing.Point(168, 8); - this.button3.Name = "button3"; - this.button3.Size = new System.Drawing.Size(128, 48); - this.button3.TabIndex = 4; - this.button3.Text = "Convert genmac files to XML"; - this.button3.Click += new System.EventHandler(this.button3_Click); + this.btnCvtGenmac.Location = new System.Drawing.Point(10, 172); + this.btnCvtGenmac.Name = "btnCvtGenmac"; + this.btnCvtGenmac.Size = new System.Drawing.Size(183, 46); + this.btnCvtGenmac.TabIndex = 4; + this.btnCvtGenmac.Text = "Convert genmac files to XML (Genmac Step 1)"; + this.btnCvtGenmac.Click += new System.EventHandler(this.btnCvtGenmac_Click); // - // button4 + // btnCvtXmlToSVG // - this.button4.Location = new System.Drawing.Point(320, 8); - this.button4.Name = "button4"; - this.button4.Size = new System.Drawing.Size(112, 48); - this.button4.TabIndex = 5; - this.button4.Text = "Convert Genmac_XML to SVG"; - this.button4.Click += new System.EventHandler(this.button4_Click); + this.btnCvtXmlToSVG.Location = new System.Drawing.Point(199, 170); + this.btnCvtXmlToSVG.Name = "btnCvtXmlToSVG"; + this.btnCvtXmlToSVG.Size = new System.Drawing.Size(183, 50); + this.btnCvtXmlToSVG.TabIndex = 5; + this.btnCvtXmlToSVG.Text = "Convert Genmac_XML to SVG (Genmac Step 2)"; + this.btnCvtXmlToSVG.Click += new System.EventHandler(this.btnCvtXmlToSVG_Click); // - // button5 + // btnCvtFormat // - this.button5.Location = new System.Drawing.Point(320, 97); - this.button5.Name = "button5"; - this.button5.Size = new System.Drawing.Size(128, 48); - this.button5.TabIndex = 6; - this.button5.Text = "Convert Drawing Items XML to PDF"; - this.button5.Click += new System.EventHandler(this.button5_Click); + this.btnCvtFormat.Location = new System.Drawing.Point(10, 64); + this.btnCvtFormat.Name = "btnCvtFormat"; + this.btnCvtFormat.Size = new System.Drawing.Size(201, 50); + this.btnCvtFormat.TabIndex = 8; + this.btnCvtFormat.Text = "Convert Format in format directory (Step 1)"; + this.btnCvtFormat.UseVisualStyleBackColor = true; + this.btnCvtFormat.Click += new System.EventHandler(this.btnCvtFormat_Click); // - // button6 + // btnMergeFmtPagDoc // - this.button6.Location = new System.Drawing.Point(464, 97); - this.button6.Name = "button6"; - this.button6.Size = new System.Drawing.Size(112, 48); - this.button6.TabIndex = 7; - this.button6.Text = "Convert SVG Xml to PDF"; - this.button6.Click += new System.EventHandler(this.button6_Click); + this.btnMergeFmtPagDoc.Location = new System.Drawing.Point(424, 64); + this.btnMergeFmtPagDoc.Name = "btnMergeFmtPagDoc"; + this.btnMergeFmtPagDoc.Size = new System.Drawing.Size(201, 50); + this.btnMergeFmtPagDoc.TabIndex = 9; + this.btnMergeFmtPagDoc.Text = "Integrate Fmt, Doc & Pag to single xml (Step 3)"; + this.btnMergeFmtPagDoc.UseVisualStyleBackColor = true; + this.btnMergeFmtPagDoc.Click += new System.EventHandler(this.btnMergeFmtPagDoc_Click); // - // button7 + // lblPathFmt // - this.button7.Location = new System.Drawing.Point(11, 69); - this.button7.Name = "button7"; - this.button7.Size = new System.Drawing.Size(140, 51); - this.button7.TabIndex = 8; - this.button7.Text = "Convert Format in format directory (step 1)"; - this.button7.UseVisualStyleBackColor = true; - this.button7.Click += new System.EventHandler(this.button7_Click); + this.lblPathFmt.AutoSize = true; + this.lblPathFmt.Location = new System.Drawing.Point(7, 42); + this.lblPathFmt.Name = "lblPathFmt"; + this.lblPathFmt.Size = new System.Drawing.Size(139, 17); + this.lblPathFmt.TabIndex = 10; + this.lblPathFmt.Text = "Path To Format Files"; // - // button8 + // btnBrowseFmt // - this.button8.Location = new System.Drawing.Point(172, 70); - this.button8.Name = "button8"; - this.button8.Size = new System.Drawing.Size(106, 49); - this.button8.TabIndex = 9; - this.button8.Text = "Integrate Fmt, Doc & Pag (step 3)"; - this.button8.UseVisualStyleBackColor = true; - this.button8.Click += new System.EventHandler(this.button8_Click); + this.btnBrowseFmt.Location = new System.Drawing.Point(528, 36); + this.btnBrowseFmt.Name = "btnBrowseFmt"; + this.btnBrowseFmt.Size = new System.Drawing.Size(152, 23); + this.btnBrowseFmt.TabIndex = 11; + this.btnBrowseFmt.Text = "Browse (Format)"; + this.btnBrowseFmt.UseVisualStyleBackColor = true; + this.btnBrowseFmt.Click += new System.EventHandler(this.btnBrowseFmt_Click); + // + // tbFmtPath + // + this.tbFmtPath.Location = new System.Drawing.Point(155, 37); + this.tbFmtPath.Name = "tbFmtPath"; + this.tbFmtPath.Size = new System.Drawing.Size(355, 22); + this.tbFmtPath.TabIndex = 12; + // + // tbGenmacPath + // + this.tbGenmacPath.Location = new System.Drawing.Point(155, 144); + this.tbGenmacPath.Name = "tbGenmacPath"; + this.tbGenmacPath.Size = new System.Drawing.Size(355, 22); + this.tbGenmacPath.TabIndex = 15; + // + // btnBrowseGenmac + // + this.btnBrowseGenmac.Location = new System.Drawing.Point(528, 143); + this.btnBrowseGenmac.Name = "btnBrowseGenmac"; + this.btnBrowseGenmac.Size = new System.Drawing.Size(152, 23); + this.btnBrowseGenmac.TabIndex = 14; + this.btnBrowseGenmac.Text = "Browse (Genmac)"; + this.btnBrowseGenmac.UseVisualStyleBackColor = true; + this.btnBrowseGenmac.Click += new System.EventHandler(this.btnBrowseGenmac_Click); + // + // lblPathGenmac + // + this.lblPathGenmac.AutoSize = true; + this.lblPathGenmac.Location = new System.Drawing.Point(7, 149); + this.lblPathGenmac.Name = "lblPathGenmac"; + this.lblPathGenmac.Size = new System.Drawing.Size(148, 17); + this.lblPathGenmac.TabIndex = 13; + this.lblPathGenmac.Text = "Path To Genmac Files"; + // + // lblResult + // + this.lblResult.AutoSize = true; + this.lblResult.Location = new System.Drawing.Point(16, 10); + this.lblResult.Name = "lblResult"; + this.lblResult.Size = new System.Drawing.Size(163, 17); + this.lblResult.TabIndex = 16; + this.lblResult.Text = "Path To Result Directory"; + // + // tbResultPath + // + this.tbResultPath.Location = new System.Drawing.Point(185, 8); + this.tbResultPath.Name = "tbResultPath"; + this.tbResultPath.Size = new System.Drawing.Size(325, 22); + this.tbResultPath.TabIndex = 17; + // + // btnBrowseResult + // + this.btnBrowseResult.Location = new System.Drawing.Point(528, 4); + this.btnBrowseResult.Name = "btnBrowseResult"; + this.btnBrowseResult.Size = new System.Drawing.Size(152, 23); + this.btnBrowseResult.TabIndex = 18; + this.btnBrowseResult.Text = "Browse (Result)"; + this.btnBrowseResult.UseVisualStyleBackColor = true; + this.btnBrowseResult.Click += new System.EventHandler(this.btnBrowseResult_Click); // // Form1 // - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(712, 590); - this.Controls.Add(this.button8); - this.Controls.Add(this.button7); - this.Controls.Add(this.button6); - this.Controls.Add(this.button5); - this.Controls.Add(this.button4); - this.Controls.Add(this.button3); + this.AutoScaleBaseSize = new System.Drawing.Size(6, 15); + this.ClientSize = new System.Drawing.Size(712, 629); + this.Controls.Add(this.btnBrowseResult); + this.Controls.Add(this.tbResultPath); + this.Controls.Add(this.lblResult); + this.Controls.Add(this.tbGenmacPath); + this.Controls.Add(this.btnBrowseGenmac); + this.Controls.Add(this.lblPathGenmac); + this.Controls.Add(this.tbFmtPath); + this.Controls.Add(this.btnBrowseFmt); + this.Controls.Add(this.lblPathFmt); + this.Controls.Add(this.btnMergeFmtPagDoc); + this.Controls.Add(this.btnCvtFormat); + this.Controls.Add(this.btnCvtXmlToSVG); + this.Controls.Add(this.btnCvtGenmac); this.Controls.Add(this.listBox1); - this.Controls.Add(this.button2); + this.Controls.Add(this.btnExit); this.Controls.Add(this.label1); - this.Controls.Add(this.button1); + this.Controls.Add(this.btnCvtPagDoc); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); + this.PerformLayout(); } #endregion @@ -195,33 +279,33 @@ namespace fmtxml Application.Run(new Form1()); } - private void button1_Click(object sender, System.EventArgs e) + private void btnCvtPagDoc_Click(object sender, System.EventArgs e) { // get all of the files in the e:\ve-proms\format directory. - DirectoryInfo di = new DirectoryInfo("E:\\ve-proms\\format"); + DirectoryInfo di = new DirectoryInfo(tbFmtPath.Text); // "C:\\16bit\\ve-proms\\format"); FileInfo[] fis = di.GetFiles("*.pag"); listBox1.Items.Clear(); foreach (FileInfo fi in fis) { string fn = fi.Name.Substring(0,fi.Name.Length-4); this.listBox1.Items.Add(fi.Name); - FmtToXml fx = new FmtToXml(fn); + FmtToXml fx = new FmtToXml(fn, tbFmtPath.Text); } fis = di.GetFiles("*.y*"); foreach (FileInfo fi in fis) { this.listBox1.Items.Add(fi.Name); - FmtToXml fx = new FmtToXml(fi.Name); + FmtToXml fx = new FmtToXml(fi.Name, tbFmtPath.Text); } MessageBox.Show("DONE Converting Page and Document Styles to XML"); } - private void button2_Click(object sender, System.EventArgs e) + private void btnExit_Click(object sender, System.EventArgs e) { Application.Exit(); } - private void button3_Click(object sender, System.EventArgs e) + private void btnCvtGenmac_Click(object sender, System.EventArgs e) { // before doing the genmac change, use cpp -DRTF file after genmac.h // has been emptied out on files in \promsnt\genmac. This creates @@ -229,70 +313,44 @@ namespace fmtxml // This conversion is done 1 time. After 32-bit print is done, the xml // files will be used rather than the genmac. - DirectoryInfo di = new DirectoryInfo("E:\\promsnt\\genmac\\preproc"); + DirectoryInfo di = new DirectoryInfo(tbGenmacPath.Text + @"\preproc"); // "C:\\16bit\\promsnt\\genmac\\preproc"); FileInfo[] fis = di.GetFiles("*.i"); listBox1.Items.Clear(); foreach (FileInfo fi in fis) { // results go to e:\\proms.net\\genmac.xml\\convert this.listBox1.Items.Add(fi.Name); - GenToXml gn = new GenToXml(fi.Name); + GenToXml gn = new GenToXml(fi.Name, tbGenmacPath.Text, tbResultPath.Text); } - MessageBox.Show("DONE Converting genmacs to XML"); + MessageBox.Show("DONE Converting genmacs to XML - Results are in " + tbResultPath.Text + @"\genmacall\convert"); } - private void button4_Click(object sender, System.EventArgs e) + private void btnCvtXmlToSVG_Click(object sender, System.EventArgs e) { // delete current svg's - DirectoryInfo disvg = new DirectoryInfo("E:\\proms.net\\genmac.xml"); + DirectoryInfo disvg = new DirectoryInfo(tbResultPath.Text + @"\genmacall"); //(@"C:\development\proms.net\genmac.xml"); FileInfo[] fissvg = disvg.GetFiles("*.svg"); foreach (FileInfo fi in fissvg)fi.Delete(); - DirectoryInfo di = new DirectoryInfo("E:\\proms.net\\genmac.xml\\convert"); + DirectoryInfo di = new DirectoryInfo(tbResultPath.Text + @"\genmacall\convert"); FileInfo[] fis = di.GetFiles("*.xml"); listBox1.Items.Clear(); foreach (FileInfo fi in fis) { // results go to e:\proms.net\genmac.xml this.listBox1.Items.Add(fi.Name); - GenXmlToSvg gn = new GenXmlToSvg(fi.Name); + GenXmlToSvg gn = new GenXmlToSvg(fi.Name, tbResultPath.Text); } - MessageBox.Show("DONE Converting genmacs.xmls to drawing object.xmls"); + MessageBox.Show("DONE Converting genmacs.xmls to drawing svg - Results are in " + tbResultPath.Text + @"\genmacall"); } - private void button5_Click(object sender, System.EventArgs e) - { - - DirectoryInfo di = new DirectoryInfo("E:\\ve-proms.net\\genmac.xml"); - FileInfo[] fis = di.GetFiles("*.xml"); - listBox1.Items.Clear(); - foreach (FileInfo fi in fis) - { - this.listBox1.Items.Add(fi.Name); - XmlToPdf pdf = new XmlToPdf("E:\\ve-proms.net\\genmac.xml",fi.Name); - } - MessageBox.Show("DONE generating PDF files from XML"); - } - - private void button6_Click(object sender, System.EventArgs e) - { - DirectoryInfo di = new DirectoryInfo("E:\\proms.net\\genmac.xml"); - FileInfo[] fis = di.GetFiles("*.svg"); - listBox1.Items.Clear(); - foreach (FileInfo fi in fis) - { - this.listBox1.Items.Add(fi.Name); - SvgToPdf pdf = new SvgToPdf("E:\\proms.net\\genmac.xml",fi.Name); - } - MessageBox.Show("DONE generating PDF files from SVG"); - } - - private void button7_Click(object sender, EventArgs e) + + private void btnCvtFormat_Click(object sender, EventArgs e) { // first convert base format - for now use genfmt. - FmtFileToXml gx = new FmtFileToXml(null,"BASE"); + FmtFileToXml gx = new FmtFileToXml(null,"BASE", tbFmtPath.Text); // get all of the format files in the e:\ve-proms\format directory. - DirectoryInfo di = new DirectoryInfo("E:\\ve-proms\\format"); + DirectoryInfo di = new DirectoryInfo(tbFmtPath.Text); // "C:\\16bit\\ve-proms\\format"); //DirectoryInfo di = new DirectoryInfo("E:\\proms.net\\exe\\fmtxml"); FileInfo[] fis = di.GetFiles("*.fmt"); listBox1.Items.Clear(); @@ -303,13 +361,13 @@ namespace fmtxml { this.listBox1.Items.Add(fi.Name); this.listBox1.Refresh(); - FmtFileToXml fx = new FmtFileToXml(gx, fn); + FmtFileToXml fx = new FmtFileToXml(gx, fn, tbFmtPath.Text); } } MessageBox.Show("DONE Converting Formats to XML"); } - private void button8_Click(object sender, EventArgs e) + private void btnMergeFmtPagDoc_Click(object sender, EventArgs e) { // get all of the generated xml format files in the fmt_xml directory and merge // the fmt/doc/pag & subformats into one file. @@ -326,12 +384,72 @@ namespace fmtxml if (File.Exists(docname) && File.Exists(pagname)) { this.listBox1.Items.Add(fi.Name); - EntireFormat ef = new EntireFormat("fmt_xml\\" + fi.Name); + EntireFormat ef = new EntireFormat("fmt_xml\\" + fi.Name, tbResultPath.Text); } else Console.WriteLine("For {0}, page or document file does not exist.", fi.Name); } - MessageBox.Show("DONE Converting Formats to XML"); + MessageBox.Show("DONE Converting Formats to XML - Results are in " + tbResultPath.Text + @"\fmtall'"); } + + private void btnBrowseFmt_Click(object sender, EventArgs e) + { + FolderBrowserDialog fbd = new FolderBrowserDialog(); + + fbd.SelectedPath = tbFmtPath.Text; + if (fbd.ShowDialog() == DialogResult.OK) + if (Directory.Exists(fbd.SelectedPath)) tbFmtPath.Text = fbd.SelectedPath; + } + + private void btnBrowseGenmac_Click(object sender, EventArgs e) + { + FolderBrowserDialog fbd = new FolderBrowserDialog(); + + fbd.SelectedPath = tbFmtPath.Text; + if (fbd.ShowDialog() == DialogResult.OK) + { + if (Directory.Exists(fbd.SelectedPath)) tbGenmacPath.Text = fbd.SelectedPath; + } + } + + private void btnBrowseResult_Click(object sender, EventArgs e) + { + FolderBrowserDialog fbd = new FolderBrowserDialog(); + + fbd.SelectedPath = tbResultPath.Text; + if (fbd.ShowDialog() == DialogResult.OK) + { + if (Directory.Exists(fbd.SelectedPath)) tbResultPath.Text = fbd.SelectedPath; + } + } + + // old code: + //private void button5_Click(object sender, System.EventArgs e) + //{ + + // DirectoryInfo di = new DirectoryInfo("C:\\16bit\\ve-proms.net\\genmac.xml"); + // FileInfo[] fis = di.GetFiles("*.xml"); + // listBox1.Items.Clear(); + // foreach (FileInfo fi in fis) + // { + // this.listBox1.Items.Add(fi.Name); + // //XmlToPdf pdf = new XmlToPdf("C:\\16bit\\ve-proms.net\\genmac.xml",fi.Name); + // } + // MessageBox.Show("DONE generating PDF files from XML"); + //} + + //private void button6_Click(object sender, System.EventArgs e) + //{ + // DirectoryInfo di = new DirectoryInfo("C:\\16bit\\proms.net\\genmac.xml"); + // FileInfo[] fis = di.GetFiles("*.svg"); + // listBox1.Items.Clear(); + // foreach (FileInfo fi in fis) + // { + // this.listBox1.Items.Add(fi.Name); + // //SvgToPdf pdf = new SvgToPdf("C:\\16bit\\proms.net\\genmac.xml", fi.Name); + // } + // MessageBox.Show("DONE generating PDF files from SVG"); + //} + } } diff --git a/PROMS/fmtxml/Form1.resx b/PROMS/fmtxml/Form1.resx index 6236cf48..19dc0dd8 100644 --- a/PROMS/fmtxml/Form1.resx +++ b/PROMS/fmtxml/Form1.resx @@ -117,7 +117,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - \ No newline at end of file diff --git a/PROMS/fmtxml/GenToXml.cs b/PROMS/fmtxml/GenToXml.cs index f0bf73cc..da68c6ca 100644 --- a/PROMS/fmtxml/GenToXml.cs +++ b/PROMS/fmtxml/GenToXml.cs @@ -15,8 +15,12 @@ namespace fmtxml private StreamWriter strGenXml; private string genName; - public GenToXml(string nm) + private string MyPath; + private string MyResPath; + public GenToXml(string nm, string path, string resPath) { + MyPath = path; + MyResPath = resPath; genName = nm; try { @@ -32,9 +36,9 @@ namespace fmtxml public void OpenFiles() { - if (!Directory.Exists("E:\\proms.net\\genmac.xml\\convert")) - Directory.CreateDirectory("E:\\proms.net\\genmac.xml\\convert"); - string fnm = "E:\\proms.net\\genmac.xml\\convert\\" + genName; + if (!Directory.Exists(MyResPath + @"\genmacall\convert")) + Directory.CreateDirectory(MyResPath + @"\genmacall\convert"); + string fnm = MyResPath + @"\genmacall\convert" + @"\" + genName; string outnm = fnm.Substring(0,fnm.LastIndexOf(".")) + ".xml"; strGenXml = new StreamWriter(outnm,false,System.Text.Encoding.ASCII); } @@ -50,7 +54,7 @@ namespace fmtxml try { // use regular expressions to read in the genmac C file and convert to XML. - StreamReader sr = new StreamReader("E:\\promsnt\\genmac\\preproc\\"+genName); + StreamReader sr = new StreamReader(MyPath + @"\preproc\"+genName); linein = sr.ReadToEnd(); sr.Close(); } diff --git a/PROMS/fmtxml/GenXmlToSvg.cs b/PROMS/fmtxml/GenXmlToSvg.cs index 0c7a5bcf..751add24 100644 --- a/PROMS/fmtxml/GenXmlToSvg.cs +++ b/PROMS/fmtxml/GenXmlToSvg.cs @@ -164,8 +164,11 @@ namespace fmtxml private static int UNDERLINE = 0x02; private static int ITALICS = 0x04; - public GenXmlToSvg(string nm) + private string MyResultPath; + + public GenXmlToSvg(string nm, string resPath) { + MyResultPath = resPath; genName = nm; try { @@ -198,7 +201,7 @@ namespace fmtxml private void WriteXml() { - string path = "E:\\proms.net\\genmac.xml\\" + genName.Substring(0,genName.LastIndexOf(".")) + ".svg"; + string path = MyResultPath + @"\genmacall\" + genName.Substring(0, genName.LastIndexOf(".")) + ".svg"; XmlTextWriter writer = new XmlTextWriter(path,System.Text.Encoding.Unicode); writer.Formatting=System.Xml.Formatting.Indented; xmlOutDoc.Save(writer); @@ -206,7 +209,7 @@ namespace fmtxml private void ReadXml() { - string fnm = "E:\\proms.net\\genmac.xml\\convert\\" + genName; + string fnm = MyResultPath + @"\genmacall\convert\" + genName; xmlDoc = new XmlDocument(); XmlTextReader reader = new XmlTextReader(fnm); xmlDoc.Load(reader); diff --git a/PROMS/fmtxml/SvgToPdf.cs b/PROMS/fmtxml/SvgToPdf.cs index 8b0c5448..f78a2b04 100644 --- a/PROMS/fmtxml/SvgToPdf.cs +++ b/PROMS/fmtxml/SvgToPdf.cs @@ -3,7 +3,7 @@ using System.Text; using System.Xml; using System.Drawing; using System.Windows.Forms; -using C1.C1Pdf; +//using C1.C1Pdf; namespace fmtxml { @@ -16,7 +16,7 @@ namespace fmtxml private XmlDocument xmlDoc; private string FileName; private string FilePath; - private C1.C1Pdf.C1PdfDocument _c1pdf; + //private C1.C1Pdf.C1PdfDocument _c1pdf; private string [] FontChoice = {"Times New Roman", @@ -59,23 +59,23 @@ namespace fmtxml private void GeneratePDFForFile() { - _c1pdf = new C1.C1Pdf.C1PdfDocument(); - string rootname = FileName.Substring(0,FileName.Length-4); - // create a pdf file with a page for each macro (i.e. macro element in xml tree), - // put it into the pdf file. - XmlNode topnode = xmlDoc.LastChild; - XmlNodeList ndlist = topnode.SelectNodes("/g"); - for (int i=0;i