using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Converting; using System.IO; namespace Anzeige { public partial class Form1 : Form { private String file_in = ""; private String file_out = ""; private bool encode = false; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.openFileDialog1.FileName = ""; this.openFileDialog1.Filter = "Target PCB-Pool|*.T3000|Target 3001|*.T3001"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { file_in = openFileDialog1.FileName; String filename = file_in.Substring(file_in.LastIndexOf("\\") + 1, file_in.LastIndexOf(".") - file_in.LastIndexOf("\\") - 1); if (file_in.Substring(file_in.LastIndexOf(".")).ToLower() == ".t3000") { this.saveFileDialog1.Filter = "Target 3001|*.T3001"; this.saveFileDialog1.FileName = filename + ".T3001"; label2.Text = "Decoding"; encode = false; } else { this.saveFileDialog1.Filter = "Target PCB-Pool|*.T3000"; this.saveFileDialog1.FileName = filename + ".T3000"; label2.Text = "Encoding"; encode = true; } button2.Enabled = true; } } private void button2_Click(object sender, EventArgs e) { if (saveFileDialog1.ShowDialog() == DialogResult.OK) { file_out = saveFileDialog1.FileName; FileInfo f = new FileInfo(file_in); progressBar1.Maximum = Int32.Parse(f.Length.ToString()); Conv c = new Conv(); c.OnNewPosition += c_OnNewPosition; c.OnFinish += c_OnFinish; c.ConvertFile(file_in, file_out, encode); } } void c_OnFinish(object sender, int exitcode) { if (exitcode == 1) { label2.Text = "Error!"; label2.ForeColor = Color.Red; } else { label2.Text = "Fertig!"; } } void c_OnNewPosition(object sender, int pos) { progressBar1.Value = pos; } } }