diff --git a/Application/FileConverter/FileConverter.csproj b/Application/FileConverter/FileConverter.csproj index 339dd73..138a8fe 100644 --- a/Application/FileConverter/FileConverter.csproj +++ b/Application/FileConverter/FileConverter.csproj @@ -103,7 +103,6 @@ - diff --git a/Application/FileConverter/ValueConverters/IsOutputTypeCompatibleWithCategoryConverter.cs b/Application/FileConverter/ValueConverters/IsOutputTypeCompatibleWithCategoryConverter.cs deleted file mode 100644 index 66e86e9..0000000 --- a/Application/FileConverter/ValueConverters/IsOutputTypeCompatibleWithCategoryConverter.cs +++ /dev/null @@ -1,56 +0,0 @@ -// License: http://www.gnu.org/licenses/gpl.html GPL version 3. - -namespace FileConverter.ValueConverters -{ - using System; - using System.Globalization; - using System.Windows.Data; - - public class IsOutputTypeCompatibleWithCategoryConverter : IMultiValueConverter - { - public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) - { - if (values == null || values.Length != 2) - { - throw new ArgumentException("The values must contains the collection of elements and the researched element."); - } - - if (!(values[0] is OutputType)) - { - return false; - } - - OutputType outputType = (OutputType)values[0]; - - string category = null; - - string input = values[1] as string; - if (input == null) - { - return false; - } - - string stringParameter = parameter as string; - if (stringParameter != null && stringParameter == "InputType") - { - category = PathHelpers.GetExtensionCategory(input); - } - else if (stringParameter != null && stringParameter == "Category") - { - category = input; - } - - if (category == null) - { - return false; - } - - return PathHelpers.IsOutputTypeCompatibleWithCategory(outputType, category); - } - - public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} diff --git a/Application/FileConverter/Windows/SettingsWindow.xaml b/Application/FileConverter/Windows/SettingsWindow.xaml index d19861f..a8edc22 100644 --- a/Application/FileConverter/Windows/SettingsWindow.xaml +++ b/Application/FileConverter/Windows/SettingsWindow.xaml @@ -17,7 +17,6 @@ - @@ -248,12 +247,6 @@ - - - - - - @@ -264,12 +257,6 @@ - - - - - - @@ -281,14 +268,7 @@ diff --git a/Application/FileConverter/Windows/SettingsWindow.xaml.cs b/Application/FileConverter/Windows/SettingsWindow.xaml.cs index 590d02c..3d2ec3b 100644 --- a/Application/FileConverter/Windows/SettingsWindow.xaml.cs +++ b/Application/FileConverter/Windows/SettingsWindow.xaml.cs @@ -1,5 +1,7 @@ // License: http://www.gnu.org/licenses/gpl.html GPL version 3. +using System.Linq; + namespace FileConverter { using System; @@ -69,22 +71,48 @@ namespace FileConverter set { + if (this.selectedPreset != null) + { + this.selectedPreset.PropertyChanged -= this.SelectedPresetPropertyChanged; + } + this.selectedPreset = value; + + if (this.selectedPreset != null) + { + this.selectedPreset.PropertyChanged += this.SelectedPresetPropertyChanged; + } + this.OnPropertyChanged(); + this.OnPropertyChanged("InputCategories"); } } - public InputExtensionCategory[] InputCategories + private void SelectedPresetPropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == "OutputType") + { + this.OnPropertyChanged("InputCategories"); + } + } + + public IEnumerable InputCategories { get { - return this.inputCategories; - } + if (this.inputCategories == null) + { + yield break; + } - set - { - this.inputCategories = value; - this.OnPropertyChanged(); + for (int index = 0; index < this.inputCategories.Length; index++) + { + InputExtensionCategory category = this.inputCategories[index]; + if (this.SelectedPreset == null || PathHelpers.IsOutputTypeCompatibleWithCategory(this.SelectedPreset.OutputType, category.Name)) + { + yield return category; + } + } } } @@ -102,6 +130,11 @@ namespace FileConverter } CheckBox checkBox = sender as System.Windows.Controls.CheckBox; + if (!checkBox.IsVisible) + { + return; + } + string inputFormat = (checkBox.Content as string).ToLowerInvariant(); this.selectedPreset.AddInputType(inputFormat); @@ -115,6 +148,11 @@ namespace FileConverter } CheckBox checkBox = sender as System.Windows.Controls.CheckBox; + if (!checkBox.IsVisible) + { + return; + } + string inputFormat = (checkBox.Content as string).ToLowerInvariant(); this.selectedPreset.RemoveInputType(inputFormat); @@ -278,7 +316,8 @@ namespace FileConverter category.AddExtension(compatibleInputExtension); } - this.InputCategories = categories.ToArray(); + this.inputCategories = categories.ToArray(); + this.OnPropertyChanged("InputCategories"); } } }