Beispiel #1
0
        private void btnUploadFirmware_Click(object sender, EventArgs e)
        {
            if (IsLoading)
            {
                return;
            }

            //if (MessageBox.Show("This feature is experimental.\nYou use it at your own risk\n\nAre you sure you want to upload firmware to the radio?","Warning", MessageBoxButtons.YesNo)==DialogResult.Yes)
            {
                Action <object> action = (object obj) =>
                {
                    IsLoading = true;
                    FirmwareLoader.UploadFirmare(_filename, this);
                    IsLoading = false;
                };
                try
                {
                    Task t1 = new Task(action, "LoaderUSB");
                    t1.Start();
                }
                catch (Exception)
                {
                    IsLoading = false;
                }
            }
        }
Beispiel #2
0
        private void downloadFileCompletedCallback(object sender, AsyncCompletedEventArgs ev)
        {
            this.progressBarDwnl.Visible = false;
            this.progressBarDwnl.Value   = 0;

            if (ev.Cancelled)
            {
                MessageBox.Show("Download has been canceled.", "Timeout", MessageBoxButtons.OK, MessageBoxIcon.Error);

                SetLoadingState(false);
                IsLoading = false;
                return;
            }
            else if (ev.Error != null)
            {
                MessageBox.Show(ev.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                SetLoadingState(false);
                IsLoading = false;
                return;
            }

            // Now flash the downloaded firmware
            Action <object> action = (object obj) =>
            {
                IsLoading = true;
                SetLoadingState(true);
                FirmwareLoader.UploadFirmare(tempFile, this);
                SetLoadingState(false);
                IsLoading = false;
                // Cleanup
                if (File.Exists(tempFile))
                {
                    File.Delete(tempFile);
                }
            };

            try
            {
                Task t1 = new Task(action, "LoaderUSB");
                t1.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                SetLoadingState(false);
                IsLoading = false;
                // Cleanup
                if (File.Exists(tempFile))
                {
                    File.Delete(tempFile);
                }
            }
        }
Beispiel #3
0
        private void btnUploadFirmware_Click(object sender, EventArgs e)
        {
            if (IsLoading)
            {
                return;
            }

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "firmware files|*.sgl";
            openFileDialog.InitialDirectory = IniFileUtils.getProfileStringWithDefault("Setup", "LastFirmwareLocation", null);

            if (openFileDialog.ShowDialog() == DialogResult.OK && openFileDialog.FileName != null)
            {
                IniFileUtils.WriteProfileString("Setup", "LastFirmwareLocation", Path.GetDirectoryName(openFileDialog.FileName));

                this.lblMessage.Text = "";

                Action <object> action = (object obj) =>
                {
                    IsLoading = true;
                    SetLoadingState(true);
                    FirmwareLoader.UploadFirmare(openFileDialog.FileName, this);
                    SetLoadingState(false);
                    IsLoading = false;
                };
                try
                {
                    Task t1 = new Task(action, "LoaderUSB");
                    t1.Start();
                }
                catch (Exception)
                {
                    IsLoading = false;
                    SetLoadingState(false);
                }
            }
        }
        private void downloadFileCompletedCallback(object sender, AsyncCompletedEventArgs ev)
        {
            this.progressBarDwnl.Visible = false;
            this.progressBarDwnl.Value   = 0;

            // Now flash the downloaded firmware
            Action <object> action = (object obj) =>
            {
                IsLoading = true;
                SetLoadingState(true);
                FirmwareLoader.UploadFirmare(tempFile, this);
                SetLoadingState(false);
                IsLoading = false;
                Console.WriteLine("IsLoading=false");
                // Cleanup
                if (File.Exists(tempFile))
                {
                    File.Delete(tempFile);
                }
            };

            try
            {
                Task t1 = new Task(action, "LoaderUSB");
                t1.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                SetLoadingState(false);
                IsLoading = false;
                // Cleanup
                if (File.Exists(tempFile))
                {
                    File.Delete(tempFile);
                }
            }
        }