- Cleanup output folders before processing

- New GenMac code
- Anchors on form design
- Exclude list to eliminate unsupported formats
- Added namespace to svg element
- Added black stroke attribute to line element
Added Checkoffs
Changed ChangeBar structures
This commit is contained in:
Rich 2010-05-25 16:07:41 +00:00
parent 699b412bcd
commit f2c571b113
4 changed files with 143 additions and 86 deletions

View File

@ -105,26 +105,27 @@ namespace fmtxml
//
// btnCvtPagDoc
//
this.btnCvtPagDoc.Location = new System.Drawing.Point(217, 63);
this.btnCvtPagDoc.Location = new System.Drawing.Point(181, 55);
this.btnCvtPagDoc.Name = "btnCvtPagDoc";
this.btnCvtPagDoc.Size = new System.Drawing.Size(201, 51);
this.btnCvtPagDoc.Size = new System.Drawing.Size(167, 44);
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(12, 237);
this.label1.Location = new System.Drawing.Point(10, 205);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(200, 18);
this.label1.Size = new System.Drawing.Size(167, 16);
this.label1.TabIndex = 1;
this.label1.Text = "Converted:";
//
// btnExit
//
this.btnExit.Location = new System.Drawing.Point(634, 224);
this.btnExit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnExit.Location = new System.Drawing.Point(572, 194);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(76, 28);
this.btnExit.Size = new System.Drawing.Size(52, 24);
this.btnExit.TabIndex = 2;
this.btnExit.Text = "Exit";
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
@ -132,20 +133,19 @@ namespace fmtxml
// listBox1
//
this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listBox1.ItemHeight = 16;
this.listBox1.Location = new System.Drawing.Point(10, 258);
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listBox1.Location = new System.Drawing.Point(8, 224);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(704, 260);
this.listBox1.Size = new System.Drawing.Size(616, 277);
this.listBox1.TabIndex = 3;
//
// btnCvtGenmac
//
this.btnCvtGenmac.Enabled = false;
this.btnCvtGenmac.Location = new System.Drawing.Point(10, 172);
this.btnCvtGenmac.Location = new System.Drawing.Point(8, 149);
this.btnCvtGenmac.Name = "btnCvtGenmac";
this.btnCvtGenmac.Size = new System.Drawing.Size(183, 46);
this.btnCvtGenmac.Size = new System.Drawing.Size(153, 40);
this.btnCvtGenmac.TabIndex = 4;
this.btnCvtGenmac.Text = "Convert genmac files to XML (Genmac Step 1)";
this.btnCvtGenmac.Click += new System.EventHandler(this.btnCvtGenmac_Click);
@ -153,18 +153,18 @@ namespace fmtxml
// btnCvtXmlToSVG
//
this.btnCvtXmlToSVG.Enabled = false;
this.btnCvtXmlToSVG.Location = new System.Drawing.Point(199, 170);
this.btnCvtXmlToSVG.Location = new System.Drawing.Point(166, 147);
this.btnCvtXmlToSVG.Name = "btnCvtXmlToSVG";
this.btnCvtXmlToSVG.Size = new System.Drawing.Size(183, 50);
this.btnCvtXmlToSVG.Size = new System.Drawing.Size(152, 44);
this.btnCvtXmlToSVG.TabIndex = 5;
this.btnCvtXmlToSVG.Text = "Convert Genmac_XML to SVG (Genmac Step 2)";
this.btnCvtXmlToSVG.Click += new System.EventHandler(this.btnCvtXmlToSVG_Click);
//
// btnCvtFormat
//
this.btnCvtFormat.Location = new System.Drawing.Point(10, 63);
this.btnCvtFormat.Location = new System.Drawing.Point(8, 55);
this.btnCvtFormat.Name = "btnCvtFormat";
this.btnCvtFormat.Size = new System.Drawing.Size(201, 51);
this.btnCvtFormat.Size = new System.Drawing.Size(168, 44);
this.btnCvtFormat.TabIndex = 8;
this.btnCvtFormat.Text = "Convert Format in format directory (Step 1)";
this.btnCvtFormat.UseVisualStyleBackColor = true;
@ -172,9 +172,9 @@ namespace fmtxml
//
// btnMergeFmtPagDoc
//
this.btnMergeFmtPagDoc.Location = new System.Drawing.Point(424, 63);
this.btnMergeFmtPagDoc.Location = new System.Drawing.Point(353, 55);
this.btnMergeFmtPagDoc.Name = "btnMergeFmtPagDoc";
this.btnMergeFmtPagDoc.Size = new System.Drawing.Size(201, 51);
this.btnMergeFmtPagDoc.Size = new System.Drawing.Size(168, 44);
this.btnMergeFmtPagDoc.TabIndex = 9;
this.btnMergeFmtPagDoc.Text = "Integrate Fmt, Doc & Pag to single xml (Step 3)";
this.btnMergeFmtPagDoc.UseVisualStyleBackColor = true;
@ -183,17 +183,18 @@ namespace fmtxml
// lblPathFmt
//
this.lblPathFmt.AutoSize = true;
this.lblPathFmt.Location = new System.Drawing.Point(7, 42);
this.lblPathFmt.Location = new System.Drawing.Point(6, 36);
this.lblPathFmt.Name = "lblPathFmt";
this.lblPathFmt.Size = new System.Drawing.Size(139, 17);
this.lblPathFmt.Size = new System.Drawing.Size(104, 13);
this.lblPathFmt.TabIndex = 10;
this.lblPathFmt.Text = "Path To Format Files";
//
// btnBrowseFmt
//
this.btnBrowseFmt.Location = new System.Drawing.Point(528, 36);
this.btnBrowseFmt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnBrowseFmt.Location = new System.Drawing.Point(502, 31);
this.btnBrowseFmt.Name = "btnBrowseFmt";
this.btnBrowseFmt.Size = new System.Drawing.Size(152, 23);
this.btnBrowseFmt.Size = new System.Drawing.Size(127, 20);
this.btnBrowseFmt.TabIndex = 11;
this.btnBrowseFmt.Text = "Browse (Format)";
this.btnBrowseFmt.UseVisualStyleBackColor = true;
@ -201,25 +202,30 @@ namespace fmtxml
//
// tbFmtPath
//
this.tbFmtPath.Location = new System.Drawing.Point(155, 37);
this.tbFmtPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbFmtPath.Location = new System.Drawing.Point(129, 32);
this.tbFmtPath.Name = "tbFmtPath";
this.tbFmtPath.Size = new System.Drawing.Size(355, 22);
this.tbFmtPath.Size = new System.Drawing.Size(358, 20);
this.tbFmtPath.TabIndex = 12;
//
// tbGenmacPath
//
this.tbGenmacPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbGenmacPath.Enabled = false;
this.tbGenmacPath.Location = new System.Drawing.Point(155, 144);
this.tbGenmacPath.Location = new System.Drawing.Point(129, 125);
this.tbGenmacPath.Name = "tbGenmacPath";
this.tbGenmacPath.Size = new System.Drawing.Size(355, 22);
this.tbGenmacPath.Size = new System.Drawing.Size(358, 20);
this.tbGenmacPath.TabIndex = 15;
//
// btnBrowseGenmac
//
this.btnBrowseGenmac.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnBrowseGenmac.Enabled = false;
this.btnBrowseGenmac.Location = new System.Drawing.Point(528, 143);
this.btnBrowseGenmac.Location = new System.Drawing.Point(502, 124);
this.btnBrowseGenmac.Name = "btnBrowseGenmac";
this.btnBrowseGenmac.Size = new System.Drawing.Size(152, 23);
this.btnBrowseGenmac.Size = new System.Drawing.Size(127, 20);
this.btnBrowseGenmac.TabIndex = 14;
this.btnBrowseGenmac.Text = "Browse (Genmac)";
this.btnBrowseGenmac.UseVisualStyleBackColor = true;
@ -229,33 +235,36 @@ namespace fmtxml
//
this.lblPathGenmac.AutoSize = true;
this.lblPathGenmac.Enabled = false;
this.lblPathGenmac.Location = new System.Drawing.Point(7, 149);
this.lblPathGenmac.Location = new System.Drawing.Point(6, 129);
this.lblPathGenmac.Name = "lblPathGenmac";
this.lblPathGenmac.Size = new System.Drawing.Size(148, 17);
this.lblPathGenmac.Size = new System.Drawing.Size(112, 13);
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.Location = new System.Drawing.Point(13, 9);
this.lblResult.Name = "lblResult";
this.lblResult.Size = new System.Drawing.Size(163, 17);
this.lblResult.Size = new System.Drawing.Size(123, 13);
this.lblResult.TabIndex = 16;
this.lblResult.Text = "Path To Result Directory";
//
// tbResultPath
//
this.tbResultPath.Location = new System.Drawing.Point(185, 8);
this.tbResultPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbResultPath.Location = new System.Drawing.Point(154, 7);
this.tbResultPath.Name = "tbResultPath";
this.tbResultPath.Size = new System.Drawing.Size(325, 22);
this.tbResultPath.Size = new System.Drawing.Size(333, 20);
this.tbResultPath.TabIndex = 17;
//
// btnBrowseResult
//
this.btnBrowseResult.Location = new System.Drawing.Point(528, 3);
this.btnBrowseResult.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnBrowseResult.Location = new System.Drawing.Point(502, 3);
this.btnBrowseResult.Name = "btnBrowseResult";
this.btnBrowseResult.Size = new System.Drawing.Size(152, 24);
this.btnBrowseResult.Size = new System.Drawing.Size(127, 20);
this.btnBrowseResult.TabIndex = 18;
this.btnBrowseResult.Text = "Browse (Result)";
this.btnBrowseResult.UseVisualStyleBackColor = true;
@ -265,31 +274,31 @@ namespace fmtxml
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsslStatus});
this.statusStrip1.Location = new System.Drawing.Point(0, 545);
this.statusStrip1.Location = new System.Drawing.Point(0, 548);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(722, 25);
this.statusStrip1.Size = new System.Drawing.Size(631, 22);
this.statusStrip1.TabIndex = 19;
this.statusStrip1.Text = "statusStrip1";
//
// tsslStatus
//
this.tsslStatus.Name = "tsslStatus";
this.tsslStatus.Size = new System.Drawing.Size(50, 20);
this.tsslStatus.Size = new System.Drawing.Size(39, 17);
this.tsslStatus.Text = "Ready";
//
// btnRtfToSvg
//
this.btnRtfToSvg.Location = new System.Drawing.Point(473, 167);
this.btnRtfToSvg.Location = new System.Drawing.Point(353, 145);
this.btnRtfToSvg.Name = "btnRtfToSvg";
this.btnRtfToSvg.Size = new System.Drawing.Size(182, 51);
this.btnRtfToSvg.Size = new System.Drawing.Size(152, 44);
this.btnRtfToSvg.TabIndex = 20;
this.btnRtfToSvg.Text = "Convert Genmac RTF to SVG (GenMac One Step)";
this.btnRtfToSvg.Click += new System.EventHandler(this.btnRtfToSvg_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
this.ClientSize = new System.Drawing.Size(722, 570);
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(631, 570);
this.Controls.Add(this.btnRtfToSvg);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.btnBrowseResult);
@ -327,25 +336,40 @@ namespace fmtxml
{
Application.Run(new Form1());
}
private static string[] _ExcludeList = "ANO,ATA,ATLAS,LPL,MYA,NAE,NAI,NAS,PAC,RBN,SCE,SRS,SUM,VCS,VP,WPF,YAE".Split(",".ToCharArray());
public static bool Excluded(FileInfo fi)
{
foreach (string prefix in _ExcludeList)
if (fi.Name.ToUpper().StartsWith(prefix)) return true;
return false;
}
private void btnCvtPagDoc_Click(object sender, System.EventArgs e)
{
CleanupDestinationFolder("*p.xml");
CleanupDestinationFolder("*d.xml");
// get all of the files in the e:\ve-proms\format directory.
DirectoryInfo di = new DirectoryInfo(tbFmtPath.Text); // "C:\\16bit\\ve-proms\\format");
FileInfo[] fis = di.GetFiles("*.pag");
ClearListBox();
foreach (FileInfo fi in fis)
{
string fn = fi.Name.Substring(0,fi.Name.Length-4);
AddFileToListBox(fi);
FmtToXml fx = new FmtToXml(fn, tbFmtPath.Text);
if (!Excluded(fi))
{
string fn = fi.Name.Substring(0, fi.Name.Length - 4);
AddFileToListBox(fi);
FmtToXml fx = new FmtToXml(fn, tbFmtPath.Text);
}
}
fis = di.GetFiles("*.y*");
foreach (FileInfo fi in fis)
{
if (!Excluded(fi))
{
AddFileToListBox(fi);
FmtToXml fx = new FmtToXml(fi.Name, tbFmtPath.Text);
}
}
fis = di.GetFiles("*.y*");
foreach (FileInfo fi in fis)
{
AddFileToListBox(fi);
FmtToXml fx = new FmtToXml(fi.Name, tbFmtPath.Text);
}
MessageBox.Show("DONE Converting Page and Document Styles to XML");
}
@ -381,8 +405,11 @@ namespace fmtxml
foreach (FileInfo fi in fis)
{
// results go to e:\\proms.net\\genmac.xml\\convert
AddFileToListBox(fi);
GenToXml gn = new GenToXml(fi.Name, tbGenmacPath.Text, tbResultPath.Text);
if (!Excluded(fi))
{
AddFileToListBox(fi);
GenToXml gn = new GenToXml(fi.Name, tbGenmacPath.Text, tbResultPath.Text);
}
}
MessageBox.Show("DONE Converting genmacs to XML - Results are in " + tbResultPath.Text + @"\genmacall\convert");
}
@ -405,36 +432,47 @@ namespace fmtxml
MessageBox.Show("DONE Converting genmacs.xmls to drawing svg - Results are in " + tbResultPath.Text + @"\genmacall");
}
private void btnCvtFormat_Click(object sender, EventArgs e)
{
DateTime tStart = DateTime.Now;
// first convert base format - for now use genfmt.
MyStatus = "Processing 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(tbFmtPath.Text); // "C:\\16bit\\ve-proms\\format");
//DirectoryInfo di = new DirectoryInfo("E:\\proms.net\\exe\\fmtxml");
// This excludes Background format files *.BFM which use a different structure
FileInfo[] fis = di.GetFiles("*.fmt");
ClearListBox();
foreach (FileInfo fi in fis)
{
string fn = fi.Name.Substring(0, fi.Name.Length - 4);
if (fn.ToLower() != "base")
private void btnCvtFormat_Click(object sender, EventArgs e)
{
CleanupDestinationFolder("*f.xml");
DateTime tStart = DateTime.Now;
// first convert base format - for now use genfmt.
MyStatus = "Processing Base";
FmtFileToXml gx = new FmtFileToXml(null, "BASE", "GEN", tbFmtPath.Text); // Create BASE from GEN format
// get all of the format files in the e:\ve-proms\format directory.
DirectoryInfo di = new DirectoryInfo(tbFmtPath.Text); // "C:\\16bit\\ve-proms\\format");
//DirectoryInfo di = new DirectoryInfo("E:\\proms.net\\exe\\fmtxml");
// This excludes Background format files *.BFM which use a different structure
FileInfo[] fis = di.GetFiles("*.fmt");
ClearListBox();
foreach (FileInfo fi in fis)
{
if (!Excluded(fi))
{
AddFileToListBox(fi);
FmtFileToXml fx = new FmtFileToXml(gx, fn, tbFmtPath.Text);
string fn = fi.Name.Substring(0, fi.Name.Length - 4);
if (fn.ToLower() != "base")
{
AddFileToListBox(fi);
FmtFileToXml fx = new FmtFileToXml(gx, fn, fn, tbFmtPath.Text);
}
}
}
MyStatus = string.Format("DONE Converting Formats to XML {0:F3} seconds",TimeSpan.FromTicks(DateTime.Now.Ticks - tStart.Ticks).TotalSeconds) ;
MessageBox.Show("DONE Converting Formats to XML");
}
MyStatus = string.Format("DONE Converting Formats to XML {0:F3} seconds", TimeSpan.FromTicks(DateTime.Now.Ticks - tStart.Ticks).TotalSeconds);
MessageBox.Show("DONE Converting Formats to XML");
}
}
private void CleanupDestinationFolder(string pattern)
{
DirectoryInfo di = new DirectoryInfo("fmt_xml");
FileInfo[] fis = di.GetFiles(pattern);
foreach (FileInfo fi in fis) fi.Delete();
}
private void btnMergeFmtPagDoc_Click(object sender, EventArgs e)
{
ClearResults(tbResultPath.Text);
DateTime tStart = DateTime.Now;
MyStatus = "Merging...";
// get all of the generated xml format files in the fmt_xml directory and merge
@ -458,9 +496,18 @@ namespace fmtxml
Console.WriteLine("For {0}, page or document file does not exist.", fi.Name);
}
MyStatus = string.Format("DONE Merging Formats {0:F3} seconds", TimeSpan.FromTicks(DateTime.Now.Ticks - tStart.Ticks).TotalSeconds);
MessageBox.Show("DONE Merging Formats - Results are in " + tbResultPath.Text + @"\fmtall'");
MessageBox.Show("DONE Merging Formats - Results are in " + tbResultPath.Text + @"fmtall'");
}
private void ClearResults(string path)
{
DirectoryInfo di = new DirectoryInfo(path);
if (di.Exists == false) return;
di = di.GetDirectories("fmtall")[0];
FileInfo[] fis = di.GetFiles("*.xml");
foreach (FileInfo fi in fis)
fi.Delete();
}
private void btnBrowseFmt_Click(object sender, EventArgs e)
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
@ -503,11 +550,15 @@ namespace fmtxml
ClearListBox();
foreach (FileInfo fi in fis)
{
// results go to e:\proms.net\genmac.xml
AddFileToListBox(fi);
RtfToSvg myConvert = new RtfToSvg(fi);
if(myConvert.IsGenMac)
myConvert.Save(tbResultPath.Text + @"genmacall\" + fi.Name.ToLower().Replace(".rtf", ".svg"));
if (!Excluded(fi))
{
// results go to e:\proms.net\genmac.xml
AddFileToListBox(fi);
RtfToSvg myConvert = new RtfToSvg(fi);
if (myConvert.IsGenMac)
myConvert.Save(tbResultPath.Text + @"genmacall\" + fi.Name.ToLower().Replace(".rtf", ".svg"));
}
}
MessageBox.Show("DONE converting GenMac RTF files to drawing svg - Results are in " + tbResultPath.Text + @"genmacall");
}

View File

@ -146,7 +146,7 @@ namespace fmtxml
private static bool AddSvgPrefix(FileInfo file, StringBuilder sb, bool svg)
{
sb.Append("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n");
sb.Append("<svg width=\"8in\" height=\"10in\" viewBox=\"0 0 576 720\">\r\n");
sb.Append("<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"8in\" height=\"10in\" viewBox=\"0 0 576 720\">\r\n");
sb.Append(string.Format(" <desc>{0}</desc>\r\n", file.Name.ToLower().Replace(".rtf", "")));
svg = true;
return svg;
@ -265,7 +265,7 @@ namespace fmtxml
private static void AddLine(StringBuilder sb, string text)
{
Match lineMatch = regLine.Match(text);
sb.Append(string.Format(" <line x1=\"{0}\" y1=\"{1}\" x2=\"{2}\" y2=\"{3}\" stroke-width=\"{4}\" />\r\n",
sb.Append(string.Format(" <line x1=\"{0}\" y1=\"{1}\" x2=\"{2}\" y2=\"{3}\" stroke=\"black\" stroke-width=\"{4}\" />\r\n",
TwipsToPoints(lineMatch.Groups[1].Value),
TwipsToPoints(lineMatch.Groups[2].Value),
TwipsToPoints(lineMatch.Groups[3].Value) + TwipsToPoints(lineMatch.Groups[1].Value),

View File

@ -18,6 +18,7 @@
<xsl:apply-templates select="Index"/>
<xsl:apply-templates select="numberingsequence"/>
<xsl:apply-templates select="IsStepSection"/>
<xsl:apply-templates select="UseCheckOffs"/>
<xsl:apply-templates select="oldtonew"/>
<xsl:apply-templates select="pagestyle"/>
<xsl:apply-templates select="dstyle|DocStructStyle|PTopRow|ContStyle|EndStyle|FinalMsg"/>
@ -30,6 +31,11 @@
<xsl:attribute name="IsStepSection"><xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
<xsl:template match="UseCheckOffs">
<xsl:attribute name="UseCheckOffs">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
<xsl:template match="oldtonew">
<xsl:attribute name="OldToNew"><xsl:value-of select="."/></xsl:attribute>
</xsl:template>

Binary file not shown.