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;

namespace WindowsFormsApplication2
{
    public partial class FlashFirmware : Form
    {
        public FlashFirmware()
        {
            InitializeComponent();
            comboBox1.SelectedIndex = 0;
            comboBox2.SelectedIndex = 7;
            textBox2.Text = Properties.Settings.Default.FlashMagicPath;
        }

        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            textBox1.Text = openFileDialog1.FileName;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.FileName = textBox2.Text;
            startInfo.Arguments = "COM(" + (comboBox1.SelectedIndex+1) + ",9600)";
            //HEXFILE("C:\Keil\C51\EXAMPLES\Philips LPC9xx\Measure\measure.HEX",NOCHECKSUMS,NOFILL,PROTECTISP) COM(1,9600)
           // System.Diagnostics.Process.Start(@"C:\Program Files (x86)\Flash Magic\FlashMagic.exe");
            System.Diagnostics.Process.Start(startInfo);
            //Thread.Sleep(7000);
           // System.Diagnostics.Process.Start(textBox2.Text);
            this.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            openFileDialog2.ShowDialog();
        }

        private void openFileDialog2_FileOk(object sender, CancelEventArgs e)
        {
            textBox2.Text = openFileDialog2.FileName;
            Properties.Settings.Default.FlashMagicPath = openFileDialog2.FileName;
            Properties.Settings.Default.Save();
        }
 
    }
}
