diff --git a/Application/FileConverter/Settings.cs b/Application/FileConverter/Settings.cs index 393210d..fca6d8d 100644 --- a/Application/FileConverter/Settings.cs +++ b/Application/FileConverter/Settings.cs @@ -4,6 +4,7 @@ namespace FileConverter { using System; using System.Collections.Generic; + using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Reflection; @@ -20,7 +21,7 @@ namespace FileConverter { private const char PresetSeparator = ';'; - private List conversionPresets = new List(); + private ObservableCollection conversionPresets = new ObservableCollection(); public event PropertyChangedEventHandler PropertyChanged; @@ -32,7 +33,7 @@ namespace FileConverter } } - public List ConversionPresets + public ObservableCollection ConversionPresets { get { return this.conversionPresets; } set { this.conversionPresets = value; } @@ -47,13 +48,13 @@ namespace FileConverter public void Load() { - List conversionPresets = this.ConversionPresets; - conversionPresets.Clear(); + ICollection presets = this.ConversionPresets; + presets.Clear(); string userFilePath = Settings.GetUserSettingsFilePath(); if (File.Exists(userFilePath)) { - XmlHelpers.LoadFromFile("Settings", userFilePath, ref conversionPresets); + XmlHelpers.LoadFromFile("Settings", userFilePath, ref presets); } else { @@ -61,7 +62,7 @@ namespace FileConverter string defaultFilePath = Settings.GetDefaultSettingsFilePath(); if (File.Exists(defaultFilePath)) { - XmlHelpers.LoadFromFile("Settings", defaultFilePath, ref conversionPresets); + XmlHelpers.LoadFromFile("Settings", defaultFilePath, ref presets); } else { @@ -75,7 +76,7 @@ namespace FileConverter // Save the settings in a temporary files (we'll write the settings file when we'll succeed to write the registry keys). string temporaryFilePath = Settings.GetUserSettingsTemporaryFilePath(); XmlHelpers.SaveToFile("Settings", temporaryFilePath, this.ConversionPresets); - + // Compute the registry entries data from settings. Dictionary> registryEntries = Settings.ComputeRegistryEntriesFromConvertionPresets(this.ConversionPresets); @@ -121,7 +122,7 @@ namespace FileConverter return; } - List conversionPresets = new List(); + ICollection conversionPresets = new ObservableCollection(); XmlHelpers.LoadFromFile("Settings", temporaryFilePath, ref conversionPresets); RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software\FileConverter"); @@ -211,12 +212,12 @@ namespace FileConverter return true; } - private static Dictionary> ComputeRegistryEntriesFromConvertionPresets(List conversionPresets) + private static Dictionary> ComputeRegistryEntriesFromConvertionPresets(ICollection conversionPresets) { Dictionary> registryEntries = new Dictionary>(); - for (int index = 0; index < conversionPresets.Count; index++) + + foreach (ConversionPreset conversionPreset in conversionPresets) { - ConversionPreset conversionPreset = conversionPresets[index]; List inputTypes = conversionPreset.InputTypes; for (int inputIndex = 0; inputIndex < inputTypes.Count; inputIndex++) { diff --git a/Application/FileConverter/SettingsWindow.xaml b/Application/FileConverter/SettingsWindow.xaml index c734f2b..9b0fbf8 100644 --- a/Application/FileConverter/SettingsWindow.xaml +++ b/Application/FileConverter/SettingsWindow.xaml @@ -64,7 +64,7 @@