public DownloadContactsForm() { InitializeComponent(); if (int.Parse(GeneralSetForm.data.RadioId) / 10000 > 0) { this.txtIDStart.Text = (int.Parse(GeneralSetForm.data.RadioId) / 10000).ToString(); } string url = IniFileUtils.getProfileStringWithDefault("Setup", "DownloadContactsURL", ""); if (url == "") { url = "http://ham-digital.org/user_by_lh.php"; } this.txtDownloadURL.Text = url; }
public DownloadContactsForm() { InitializeComponent(); this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); // Roger Clark. Added correct icon on main form! if (int.Parse(GeneralSetForm.data.RadioId) / 10000 > 0) { this.txtIDStart.Text = (int.Parse(GeneralSetForm.data.RadioId) / 10000).ToString(); } string url = IniFileUtils.getProfileStringWithDefault("Setup", "DownloadContactsURL", ""); if (url == "") { url = "http://ham-digital.org/user_by_lh.php"; } this.txtDownloadURL.Text = url; }
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 downloadStringCompletedCallback(object sender, DownloadStringCompletedEventArgs ev) { if (ev.Cancelled) { MessageBox.Show(StringsDict["DownloadCancelled"], StringsDict["Timeout"], MessageBoxButtons.OK, MessageBoxIcon.Error); SetLoadingState(false); this.progressBarDwnl.Visible = false; return; } else if (ev.Error != null) { MessageBox.Show(ev.Error.Message, StringsDict["Error"], MessageBoxButtons.OK, MessageBoxIcon.Error); SetLoadingState(false); this.progressBarDwnl.Visible = false; return; } String result = ev.Result; this.progressBarDwnl.Visible = false; FirmwareLoaderReleasesList flrl = new FirmwareLoaderReleasesList(result); if (DialogResult.Cancel != flrl.ShowDialog()) { if (_saveDownloadedFile) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "firmware files|*.sgl"; saveFileDialog.InitialDirectory = IniFileUtils.getProfileStringWithDefault("Setup", "LastFirmwareLocation", null); saveFileDialog.FileName = FirmwareLoader.getModelSaveFileString(FirmwareLoader.outputType) + "_" + flrl.SelectedVersion + ".sgl"; if (saveFileDialog.ShowDialog() == DialogResult.OK && saveFileDialog.FileName != null) { tempFile = saveFileDialog.FileName; } else { MessageBox.Show(StringsDict["No_file_location_specified"]); SetLoadingState(false); IsLoading = false; return; } } else { tempFile = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".sgl"; } // Download the firmware binary to a temporary file try { Application.DoEvents(); this.progressBarDwnl.Value = 0; this.progressBarDwnl.Visible = true; wc.DownloadFileAsync(new Uri(flrl.SelectedURL), tempFile); } catch (Exception ex) { MessageBox.Show(StringsDict["Error"] + ": " + ex.Message, StringsDict["Error"], MessageBoxButtons.OK, MessageBoxIcon.Error); if (File.Exists(tempFile)) { File.Delete(tempFile); } SetLoadingState(false); this.progressBarDwnl.Visible = false; return; } } else { SetLoadingState(false); } return; }