Added: Copy th currently selected preset when clicking on Add Preset.

This commit is contained in:
Tichau committed 2015-11-24 08:24:46 +01:00
1 parent 866844e369
commit 8ca9734298
2 files changed
+39 -2

No files matched your search

@@ -36,10 +36,30 @@ namespace FileConverter
List<string> inputTypeList = new List<string>();
inputTypeList.AddRange(inputTypes);
this.InputTypes = inputTypeList;
this.outputFileNameTemplate = "(p)(f)";
}
public ConversionPreset(string name, ConversionPreset source)
{
this.Name = name;
this.OutputType = source.outputType;
List<string> inputTypeList = new List<string>();
if (source.inputTypes != null)
{
inputTypeList.AddRange(source.inputTypes);
}
this.InputTypes = inputTypeList;
this.outputFileNameTemplate = source.OutputFileNameTemplate;
foreach (KeyValuePair<string, string> conversionSetting in source.settings)
{
this.SetSettingsValue(conversionSetting.Key, conversionSetting.Value);
}
}
public event PropertyChangedEventHandler PropertyChanged;
[XmlAttribute]
@@ -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();