2008-08-26 13:55:41 +00:00

338 lines
11 KiB
C#

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
namespace fmtxml
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button2;
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;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.button2 = 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.SuspendLayout();
//
// button1
//
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);
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 144);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(168, 16);
this.label1.TabIndex = 1;
this.label1.Text = "Converted:";
//
// button2
//
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);
//
// listBox1
//
this.listBox1.Location = new System.Drawing.Point(8, 168);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(584, 407);
this.listBox1.TabIndex = 3;
//
// button3
//
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);
//
// button4
//
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);
//
// button5
//
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);
//
// button6
//
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);
//
// button7
//
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);
//
// button8
//
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);
//
// 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.Controls.Add(this.listBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_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");
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);
}
fis = di.GetFiles("*.y*");
foreach (FileInfo fi in fis)
{
this.listBox1.Items.Add(fi.Name);
FmtToXml fx = new FmtToXml(fi.Name);
}
MessageBox.Show("DONE Converting Page and Document Styles to XML");
}
private void button2_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void button3_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
// precompiled files only, i.e. gets rid of some of the junk in the files.
// 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");
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);
}
MessageBox.Show("DONE Converting genmacs to XML");
}
private void button4_Click(object sender, System.EventArgs e)
{
// delete current svg's
DirectoryInfo disvg = new DirectoryInfo("E:\\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");
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);
}
MessageBox.Show("DONE Converting genmacs.xmls to drawing object.xmls");
}
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)
{
// first convert base format - for now use genfmt.
FmtFileToXml gx = new FmtFileToXml(null,"BASE");
// 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("E:\\proms.net\\exe\\fmtxml");
FileInfo[] fis = di.GetFiles("*.fmt");
listBox1.Items.Clear();
foreach (FileInfo fi in fis)
{
string fn = fi.Name.Substring(0, fi.Name.Length - 4);
if (fn.ToLower() != "base")
{
this.listBox1.Items.Add(fi.Name);
this.listBox1.Refresh();
FmtFileToXml fx = new FmtFileToXml(gx, fn);
}
}
MessageBox.Show("DONE Converting Formats to XML");
}
private void button8_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.
DirectoryInfo di = new DirectoryInfo("fmt_xml");
//testDirectoryInfo di = new DirectoryInfo("E:\\proms.net\\exe\\fmtxml");
FileInfo[] fis = di.GetFiles("*f.xml");
listBox1.Items.Clear();
foreach (FileInfo fi in fis)
{
// see if all three, format, doc & pag exist - if not, print error,
// if so, process
string docname = "fmt_xml\\" + fi.Name.Substring(0, fi.Name.Length - 5) + "p.xml";
string pagname = "fmt_xml\\" + fi.Name.Substring(0, fi.Name.Length - 5) + "d.xml";
if (File.Exists(docname) && File.Exists(pagname))
{
this.listBox1.Items.Add(fi.Name);
EntireFormat ef = new EntireFormat("fmt_xml\\" + fi.Name);
}
else
Console.WriteLine("For {0}, page or document file does not exist.", fi.Name);
}
MessageBox.Show("DONE Converting Formats to XML");
}
}
}