From 8ca9734298c323b2dfd62fb3f36524718746d825 Mon Sep 17 00:00:00 2001 From: Tichau Date: Tue, 24 Nov 2015 08:24:46 +0100 Subject: [PATCH] Added: Copy th currently selected preset when clicking on Add Preset. --- .../ConversionPreset/ConversionPreset.cs | 22 ++++++++++++++++++- .../Windows/SettingsWindow.xaml.cs | 19 +++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/Application/FileConverter/ConversionPreset/ConversionPreset.cs b/Application/FileConverter/ConversionPreset/ConversionPreset.cs index 85018bb..c44718d 100644 --- a/Application/FileConverter/ConversionPreset/ConversionPreset.cs +++ b/Application/FileConverter/ConversionPreset/ConversionPreset.cs @@ -36,10 +36,30 @@ namespace FileConverter List inputTypeList = new List(); inputTypeList.AddRange(inputTypes); this.InputTypes = inputTypeList; - + this.outputFileNameTemplate = "(p)(f)"; } + public ConversionPreset(string name, ConversionPreset source) + { + this.Name = name; + this.OutputType = source.outputType; + List inputTypeList = new List(); + if (source.inputTypes != null) + { + inputTypeList.AddRange(source.inputTypes); + } + + this.InputTypes = inputTypeList; + + this.outputFileNameTemplate = source.OutputFileNameTemplate; + + foreach (KeyValuePair conversionSetting in source.settings) + { + this.SetSettingsValue(conversionSetting.Key, conversionSetting.Value); + } + } + public event PropertyChangedEventHandler PropertyChanged; [XmlAttribute] diff --git a/Application/FileConverter/Windows/SettingsWindow.xaml.cs b/Application/FileConverter/Windows/SettingsWindow.xaml.cs index 30ad916..5420ac7 100644 --- a/Application/FileConverter/Windows/SettingsWindow.xaml.cs +++ b/Application/FileConverter/Windows/SettingsWindow.xaml.cs @@ -221,7 +221,24 @@ namespace FileConverter private void AddPresetButton_Click(object sender, RoutedEventArgs e) { Application application = Application.Current as Application; - ConversionPreset newPreset = new ConversionPreset("New preset", OutputType.None, new string[0]); + string presetName = "New preset"; + int index = 1; + while (application.Settings.ConversionPresets.Any(match => match.Name == presetName)) + { + index++; + presetName = string.Format("New preset ({0})", index); + } + + ConversionPreset newPreset = null; + if (this.SelectedPreset != null) + { + newPreset = new ConversionPreset(presetName, this.SelectedPreset); + } + else + { + newPreset = new ConversionPreset(presetName, OutputType.Mkv, new string[0]); + } + application.Settings.ConversionPresets.Add(newPreset); this.SelectedPreset = newPreset; this.PresetNameTextBox.Focus();