private void Form1_Load(object sender, EventArgs e) { if (filePaths.Length > 0) { bStart.Enabled = false; bChooseXML.Enabled = false; foreach (string file in filePaths) { string[] fileTemp = file.Split('.'); if (fileTemp.Length > 1) { if (!fileTemp[fileTemp.Length - 1].ToLower().Equals("xml")) { MessageBox.Show("File selected is not a .XML"); System.Windows.Forms.Application.Exit(); return; } } else { MessageBox.Show("File selected is not a .XML"); System.Windows.Forms.Application.Exit(); return; } tbXML.Text = file; CreateExcelFile c; LoadXML l; LoadTemplate t; runParser = new Thread(delegate() { try { t = new LoadTemplate(this); l = new LoadXML(this, t, tbXML.Text); c = new CreateExcelFile(this, l, t); } finally { GC.Collect(); GC.WaitForPendingFinalizers(); string[] temp = file.Split('\\'); WriteToConsole("EBOM created using " + temp[temp.Length - 1]); Thread.Sleep(1500); System.Windows.Forms.Application.Exit(); } }); runParser.Name = "CreateEBOM"; runParser.Start(); } } //createDataTable(); //dataGrid.Dock = DockStyle.Top; //this.dataGrid.Paint += new PaintEventHandler(dataGrid_Paint); //this.dataGridView1.Scroll += new ScrollEventHandler(dataGridView1_Scroll); //this.dataGridView1.CellPainting += // new DataGridViewCellPaintingEventHandler(dataGridView1_CellPainting); }
private void bStart_Click(object sender, EventArgs e) { string[] fileTemp = tbXML.Text.Split('.'); if (fileTemp.Length > 1) { if (!fileTemp[fileTemp.Length - 1].ToLower().Equals("xml")) { MessageBox.Show("File selected is not a .XML"); System.Windows.Forms.Application.Exit(); return; } } else { MessageBox.Show("File selected is not a .XML"); System.Windows.Forms.Application.Exit(); return; } bStart.Enabled = false; bChooseXML.Enabled = false; CreateExcelFile c; LoadXML l; LoadTemplate t; runParser = new Thread(delegate() { try { t = new LoadTemplate(this); l = new LoadXML(this, t, tbXML.Text); c = new CreateExcelFile(this, l, t); } finally { GC.Collect(); GC.WaitForPendingFinalizers(); if (end) { System.Windows.Forms.Application.Exit(); } Action myACtion = () => { bStart.Enabled = true; bChooseXML.Enabled = true; }; getpMainFrame(myACtion); } }); runParser.Name = "CreateEBOM"; runParser.Start(); }