예제 #1
0
        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.");
                }
            }
        }
예제 #2
0
        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);
                    }
                }
            }
        }