private void CmdUploadRom_Click(object sender, EventArgs e)  //TODO: move out of gui.
        {
            if (String.IsNullOrWhiteSpace(txtEepromPath.Text))
            {
                return;
            }
            if (String.IsNullOrWhiteSpace(cmbBasic2SerialPort.Text))
            {
                MessageBox.Show("You must have a serial connection in order to upload the eeprom.", "Warning");
                return;
            }

            string msg = "Only perform this operation if you are 100% certain you know the implications." + Environment.NewLine;

            msg += "Make sure you PMC-8 is plugged in.";
            DialogResult r = MessageBox.Show(msg, "Warning - Use Carefully", MessageBoxButtons.OKCancel);

            if (r == DialogResult.Cancel)
            {
                return;
            }

            MessageBox.Show("This may take a few moments.  Press OK to start", "Information");
            DumpLine("Attempting to upload ROM");

            RomFlasher flasher = new RomFlasher();

            string result = "";
            string file   = Environment.CurrentDirectory + "\\Propellent.exe ";
            string args   = txtEepromPath.Text;

            DumpLine("Path to Propellent.exe:" + flasher.GetQuotedString(file));
            DumpLine("Path to EEPROM: " + flasher.GetQuotedString(args));
            try
            {
                result = flasher.FlashRom(file, args);
            }
            catch (Exception ex)
            {
                DumpLine("An Error Occured" + ex?.ToString());
            }
            DumpLine(result);
            //string file = Environment.CurrentDirectory + "\\Propellent.exe ";
            //string args = "\"" + txtEepromPath.Text + "\"" + " /eeprom";
            //try
            //{
            //    Console.WriteLine("Tryiny to ececute: " + file + " " + args);
            //    ProcessStartInfo procStartInfo = new ProcessStartInfo(file, args);
            //    procStartInfo.RedirectStandardOutput = true;
            //    procStartInfo.UseShellExecute = false;
            //    procStartInfo.CreateNoWindow = true;

            //    // wrap IDisposable into using (in order to release hProcess)
            //    using (Process process = new Process())
            //    {
            //        process.StartInfo = procStartInfo;
            //        process.Start();

            //        // Add this: wait until process does its work
            //        process.WaitForExit();

            //        // and only then read the result
            //        string result = process.StandardOutput.ReadToEnd();
            //        DumpLine("Success - results:");
            //        DumpLine(result);
            //    }
            //}
            //catch (Exception ex)
            //{

            //    DumpLine("Could not load EEPROM.  Error Code:");
            //    DumpLine(ex?.ToString());
            //}


            //Cursor.Current = Cursors.WaitCursor;
            //try
            //{
            //    Console.WriteLine(Environment.CurrentDirectory);
            //    SetGUIMode(0);
            //    InitPropellent(this.Handle, false, null);
            //    SaveImage(true, openFileDialog.FileName, false);
            //    MessageBox.Show("ROM successfully loaded.", "Information");
            //    Dump("ROM uploaded.");
            //}
            //catch (Exception ex)
            //{
            //    Dump("Could not load ROM");
            //    string msg2 = "ROM failed to load" + Environment.NewLine + Environment.NewLine + ex?.ToString();
            //    MessageBox.Show(msg2, "Error");
            //}
            //finally
            //{ FinalizePropellent(); }
            // Cursor.Current = Cursors.Default;
        }
        private void Button3_Click(object sender, EventArgs e)  //FLash Selected
        {
            if (lsvEepromFileNames.SelectedItems.Count == 0)
            {
                return;
            }
            string fileName = lsvEepromFileNames.SelectedItems[0].Text;


            string msg = "Only perform this operation if you are 100% certain you know the implications." + Environment.NewLine;

            msg += "Make sure you PMC-8 is plugged in.";
            DialogResult r = MessageBox.Show(msg, "Warning - Use Carefully", MessageBoxButtons.OKCancel);

            if (r == DialogResult.Cancel)
            {
                return;
            }

            string file = Environment.CurrentDirectory + @"\Propellent.exe ";
            string args = desinationFolder + @"\" + fileName;

            MessageBox.Show("This may take a few moments.  Press OK to start", "Information");
            DumpLine("Attempting to upload ROM: " + fileName);

            //DOUBLE CHECK THAT FILES EXIST
            if (!File.Exists(file))
            {
                DumpLine("The program can not find Propellent.dll. Please reinstall or contact support.");
            }
            if (!File.Exists(args))
            {
                DumpLine("The program could not find the eeprom file.  Please try again or contact support");
            }

            string     result  = "";
            RomFlasher flasher = new RomFlasher();

            DumpLine("Path to Propellent.exe:" + flasher.GetQuotedString(file));
            DumpLine("Path to EEPROM: " + flasher.GetQuotedString(args));
            try
            {
                result = flasher.FlashRom(file, args);
            }
            catch (Exception ex)
            {
                DumpLine("Error Flashing EEPROM: " + ex?.ToString());;
            }
            DumpLine(result);
            //try
            //{
            //    Console.WriteLine("Tryiny to ececute: " + file + " " + args);
            //    ProcessStartInfo procStartInfo = new ProcessStartInfo(file, args);
            //    procStartInfo.RedirectStandardOutput = true;
            //    procStartInfo.UseShellExecute = false;
            //    procStartInfo.CreateNoWindow = true;

            //    // wrap IDisposable into using (in order to release hProcess)
            //    using (Process process = new Process())
            //    {
            //        process.StartInfo = procStartInfo;
            //        process.Start();

            //        // Add this: wait until process does its work
            //        process.WaitForExit();

            //        // and only then read the result
            //        string result = process.StandardOutput.ReadToEnd();
            //        DumpLine("Success - results:");
            //        DumpLine(result);
            //    }
            //}
            //catch (Exception ex)
            //{

            //    DumpLine("Could not load EEPROM.  Error Code:" + ex?.ToString());
            //    DumpLine(ex?.ToString());
            //}
        }