private void btnPresetAdd_Click(object sender, EventArgs e) { using (FormPreset dialog = new FormPreset(preferences)) { if (dialog.ShowDialog(this) == DialogResult.OK) { Preset preset = dialog.Preset; Logger.Instance.Fine(nameof(FormPreferences), "Opening preset customizer..."); using (FormAddDownload presetDialog = new FormAddDownload(preferences, downloadManager, null, preset, true)) { if (presetDialog.ShowDialog(this) == DialogResult.OK) { preset.State = presetDialog.GetState(); Logger.Instance.Fine(nameof(FormPreferences), "Setting preset state."); } } UpdatePresets(preset); preferences.Presets.Add(preset); LbxPresets_SelectedIndexChanged(this, new EventArgs()); Logger.Instance.Fine(nameof(FormPreferences), "Added preset."); } } }
private void ShowAddDownloadDialog(string url = null, bool silent = false) { using (FormAddDownload dialog = new FormAddDownload(PreferencesManager.Preferences, url, null, false, silent)) { if (dialog.ShowDialog(this) == DialogResult.OK) { AddDownload(dialog.Download); } } }
private void btnGo_Click(object sender, EventArgs e) { DialogResult = DialogResult.None; if (SeparateOptions) { foreach (string url in urlsToAdd) { bool isSilent = AllowPresets && Preset.HasValidPreset(prefs.Presets, url); using (FormAddDownload dialog = new FormAddDownload(prefs, url, null, false, isSilent)) { if (dialog.ShowDialog(this) == DialogResult.OK) { callback(dialog.Download); } } } DialogResult = DialogResult.OK; } else if (urlsToAdd.Count > 0) { using (FormAddDownload dialog = new FormAddDownload(prefs, "sharedsettings.", null, false, false)) { if (dialog.ShowDialog(this) == DialogResult.OK) { foreach (string url in urlsToAdd) { bool isSilent = AllowPresets && Preset.HasValidPreset(prefs.Presets, url); if (isSilent) // Auto add { using (FormAddDownload dialog2 = new FormAddDownload(prefs, url, null, false, true)) { if (dialog2.ShowDialog(this) == DialogResult.OK) { callback(dialog2.Download); } } } else { Download download = dialog.CreateDownload(url); callback(download); } } DialogResult = DialogResult.OK; } } } }
private void btnPresetEdit_Click(object sender, EventArgs e) { Preset preset = lbxPresets.SelectedItem as Preset; if (preset == null) { return; } using (FormPreset dialog = new FormPreset(preferences, preset)) { if (dialog.ShowDialog(this) == DialogResult.OK) { if (dialog.RequestRemoval) { Logger.Instance.Fine(nameof(FormPreferences), "Removing preset."); preferences.Presets.Remove(preset); UpdatePresets(null); } else { Preset prs = dialog.Preset; Logger.Instance.Fine(nameof(FormPreferences), "Opening preset customizer..."); using (FormAddDownload presetDialog = new FormAddDownload(preferences, downloadManager, null, prs, true)) { if (presetDialog.ShowDialog(this) == DialogResult.OK) { prs.State = presetDialog.GetState(); Logger.Instance.Fine(nameof(FormPreferences), "Setting preset state."); } } preferences.Presets.Replace(preset, prs); UpdatePresets(prs); } } } }