예제 #1
0
        private void btnOpenFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter           = "firmware files (*.sgl)|*.sgl|binary files (*.bin)|*.bin|All files (*.*)|*.*";
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    enableUI(false);
                    FrmProgress frmProgress = new FrmProgress();
                    frmProgress.SetLabel("");
                    frmProgress.SetProgressPercentage(0);
                    frmProgress.FormBorderStyle = FormBorderStyle.FixedSingle;
                    frmProgress.MaximizeBox     = false;
                    frmProgress.Show();
                    FirmwareLoader.UploadFirmware(openFileDialog1.FileName, frmProgress);
                    frmProgress.Close();
                }
                catch (Exception)
                {
                }
                enableUI(true);
            }
        }
예제 #2
0
        private void downloadFileCompletedCallback(object sender, AsyncCompletedEventArgs ev)
        {
            this.progressBar.Visible = false;
            this.progressBar.Value   = 0;

            // Now flash the downloaded firmware
            try
            {
                FrmProgress frmProgress = new FrmProgress();
                frmProgress.SetLabel("");
                frmProgress.SetProgressPercentage(0);
                frmProgress.FormBorderStyle = FormBorderStyle.FixedSingle;
                frmProgress.MaximizeBox     = false;
                frmProgress.Show();

                if (FirmwareLoader.UploadFirmware(tempFile, frmProgress) != 0)
                {
                    MessageBox.Show("Error: Unable to upload the firmware to the " + FirmwareLoader.getModelName(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                frmProgress.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // Cleanup
            if (File.Exists(tempFile))
            {
                File.Delete(tempFile);
            }

            enableUI(true);
        }
예제 #3
0
파일: MainForm.cs 프로젝트: phdlee/OpenGD77
        private void btnOpenFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter           = "binary files (*.bin)|*.bin|firmware files (*.sgl)|*.sgl|All files (*.*)|*.*";
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    FrmProgress frmProgress = new FrmProgress();
                    frmProgress.SetLabel("");
                    frmProgress.SetProgressPercentage(0);
                    frmProgress.Show();
                    FirmwareLoader.UploadFirmware(openFileDialog1.FileName, frmProgress);
                    frmProgress.Close();
                }
                catch (Exception)
                {
                }
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            int exitCode = 0;

            /* Testing only
             * args = new string[2];
             * args[0] = "test.bin";
             * args[1] = "GUI";
             */
            if (args.Length == 0)
            {
                FirmwareLoader.outputType = FirmwareLoader.probeModel();

                if ((FirmwareLoader.outputType < FirmwareLoader.OutputType.OutputType_GD77) || (FirmwareLoader.outputType > FirmwareLoader.OutputType.OutputType_DM1801))
                {
                    Console.WriteLine("Unable to detect HT model, using GD-77 as fallback.");
                    FirmwareLoader.outputType = FirmwareLoader.OutputType.OutputType_GD77;
                }
                else
                {
                    Console.WriteLine(String.Format("Detected mode: {0}", FirmwareLoader.getModelName()));
                }

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
            }
            else
            {
                if (args.Contains("--help") || args.Contains("-h") || args.Contains("/h"))
                {
                    //FirmwareLoader.OutputType[] models = new FirmwareLoader.OutputType[] { FirmwareLoader.OutputType.OutputType_GD77, FirmwareLoader.OutputType.OutputType_GD77S, FirmwareLoader.OutputType.OutputType_DM1801 };
                    String[] modelsString =
                    {
                        FirmwareLoader.getModelString(FirmwareLoader.OutputType.OutputType_GD77),
                        FirmwareLoader.getModelString(FirmwareLoader.OutputType.OutputType_GD77S),
                        FirmwareLoader.getModelString(FirmwareLoader.OutputType.OutputType_DM1801)
                    };
                    String allModels = String.Join(" | ", modelsString);

                    Console.WriteLine(String.Format("\nUsage: GD77_FirmwareLoader [GUI] [{0}] [filename]\n\n", allModels));
                    Environment.Exit(exitCode);
                }

                int idxGD77   = Array.IndexOf(args, "GD-77");
                int idxDM1801 = Array.IndexOf(args, "DM-1801");
                int idxGD77S  = Array.IndexOf(args, "GD-77S");

                if (idxGD77 >= 0)
                {
                    FirmwareLoader.outputType = FirmwareLoader.OutputType.OutputType_GD77;
                    args = RemoveArgAt(args, idxGD77);
                }
                else if (idxGD77S >= 0)
                {
                    FirmwareLoader.outputType = FirmwareLoader.OutputType.OutputType_GD77S;
                    args = RemoveArgAt(args, idxGD77S);
                }
                else if (idxDM1801 >= 0)
                {
                    FirmwareLoader.outputType = FirmwareLoader.OutputType.OutputType_DM1801;
                    args = RemoveArgAt(args, idxDM1801);
                }
                else
                {
                    FirmwareLoader.outputType = FirmwareLoader.probeModel();
                    Console.WriteLine(String.Format(" - Detected model: {0}", FirmwareLoader.getModelName()));
                }

                if (args.Length == 0)
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new MainForm());
                }

                int idx = Array.IndexOf(args, "GUI");
                if (idx >= 0)
                {
                    args = RemoveArgAt(args, idx);

                    if (args.Length <= 0)
                    {
                        Console.WriteLine("ERROR: No filename specified.");
                        Environment.Exit(-1);
                    }

                    FrmProgress frmProgress = new FrmProgress();
                    frmProgress.SetLabel("");
                    frmProgress.SetProgressPercentage(0);
                    frmProgress.Show();

                    exitCode = FirmwareLoader.UploadFirmware(args[0], frmProgress);
                    frmProgress.Close();
                }
                else
                {
                    if (args.Length <= 0)
                    {
                        Console.WriteLine("ERROR: No filename specified.");
                        Environment.Exit(-1);
                    }

                    exitCode = FirmwareLoader.UploadFirmware(args[0]);
                }
            }
            //	Console.WriteLine("Usage GD77_FirmwareLoader filename");

            Environment.Exit(exitCode);
        }
예제 #5
0
        static void Main(string[] args)
        {
            int exitCode = 0;

            /* Testing only
             * args = new string[2];
             * args[0] = "test.bin";
             * args[1] = "GUI";
             */
            if (args.Length == 0)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
            }
            else
            {
                int idx = Array.IndexOf(args, "DM-1801");

                FirmwareLoader.outputType = ((idx >= 0) ? FirmwareLoader.OutputType.OutputType_DM1801 : FirmwareLoader.OutputType.OutputType_GD77);

                if (idx >= 0)
                {
                    args = RemoveArgAt(args, idx);
                }

                if (args.Contains("--help") || args.Contains("-h") || args.Contains("/h"))
                {
                    Console.WriteLine("\nUsage: GD77_FirmwareLoader [GUI] [DM-1801] [filename]\n\n");
                    Environment.Exit(exitCode);
                }

                if (args.Length == 0)
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new MainForm());
                }

                idx = Array.IndexOf(args, "GUI");
                if (idx >= 0)
                {
                    args = RemoveArgAt(args, idx);

                    if (args.Length <= 0)
                    {
                        Console.WriteLine("ERROR: No filename specified.");
                        Environment.Exit(-1);
                    }

                    FrmProgress frmProgress = new FrmProgress();
                    frmProgress.SetLabel("");
                    frmProgress.SetProgressPercentage(0);
                    frmProgress.Show();

                    exitCode = FirmwareLoader.UploadFirmware(args[0], frmProgress);
                    frmProgress.Close();
                }
                else
                {
                    if (args.Length <= 0)
                    {
                        Console.WriteLine("ERROR: No filename specified.");
                        Environment.Exit(-1);
                    }

                    exitCode = FirmwareLoader.UploadFirmware(args[0]);
                }
            }
            //	Console.WriteLine("Usage GD77_FirmwareLoader filename");

            Environment.Exit(exitCode);
        }