diff --git a/Application/FileConverter/ConversionPreset/ConversionPreset.cs b/Application/FileConverter/ConversionPreset/ConversionPreset.cs index dda2109..59a4c6e 100644 --- a/Application/FileConverter/ConversionPreset/ConversionPreset.cs +++ b/Application/FileConverter/ConversionPreset/ConversionPreset.cs @@ -127,10 +127,7 @@ namespace FileConverter [XmlAttribute] public OutputType OutputType { - get - { - return this.outputType; - } + get => this.outputType; set { @@ -254,10 +251,7 @@ namespace FileConverter [XmlIgnore] public IConversionSettings Settings { - get - { - return this.settings; - } + get => this.settings; set { diff --git a/Application/FileConverter/FileConverter.csproj b/Application/FileConverter/FileConverter.csproj index 5242b88..0e77bd1 100644 --- a/Application/FileConverter/FileConverter.csproj +++ b/Application/FileConverter/FileConverter.csproj @@ -201,6 +201,7 @@ + @@ -236,7 +237,6 @@ DiagnosticsWindow.xaml - diff --git a/Application/FileConverter/ValueConverters/ConversionSettingsRelevant.cs b/Application/FileConverter/ValueConverters/ConversionSettingsRelevant.cs new file mode 100644 index 0000000..a0b7a27 --- /dev/null +++ b/Application/FileConverter/ValueConverters/ConversionSettingsRelevant.cs @@ -0,0 +1,39 @@ +// 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 ConversionSettingsRelevant : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + { + return null; + } + + if (!(value is IConversionSettings)) + { + throw new ArgumentException("The value must be a conversion preset array."); + } + + IConversionSettings settings = (IConversionSettings)value; + + string key = parameter as string; + if (key == null) + { + throw new ArgumentException("The parameter must be a string value."); + } + + return settings.ContainsKey(key); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new Exception(); + } + } +} diff --git a/Application/FileConverter/Views/ConversionSettingsTemplateSelector.cs b/Application/FileConverter/Views/ConversionSettingsTemplateSelector.cs deleted file mode 100644 index 946d062..0000000 --- a/Application/FileConverter/Views/ConversionSettingsTemplateSelector.cs +++ /dev/null @@ -1,157 +0,0 @@ -// License: http://www.gnu.org/licenses/gpl.html GPL version 3. - -namespace FileConverter.Views -{ - using System.Windows; - using System.Windows.Controls; - - public class ConversionSettingsTemplateSelector : DataTemplateSelector - { - public DataTemplate DefaultDataTemplate - { - get; - set; - } - - public DataTemplate AviSettingsDataTemplate - { - get; - set; - } - - public DataTemplate FlacSettingsDataTemplate - { - get; - set; - } - - public DataTemplate WavSettingsDataTemplate - { - get; - set; - } - - public DataTemplate Mp3SettingsDataTemplate - { - get; - set; - } - - public DataTemplate Mp4SettingsDataTemplate - { - get; - set; - } - - public DataTemplate OggSettingsDataTemplate - { - get; - set; - } - - public DataTemplate OgvSettingsDataTemplate - { - get; - set; - } - - public DataTemplate AacSettingsDataTemplate - { - get; - set; - } - - public DataTemplate GifSettingsDataTemplate - { - get; - set; - } - - public DataTemplate JpgSettingsDataTemplate - { - get; - set; - } - - public DataTemplate PngSettingsDataTemplate - { - get; - set; - } - - public DataTemplate MkvSettingsDataTemplate - { - get; - set; - } - - public DataTemplate WebmSettingsDataTemplate - { - get; - set; - } - - public DataTemplate WebpSettingsDataTemplate - { - get; - set; - } - - public override DataTemplate SelectTemplate(object item, DependencyObject container) - { - if (item == null) - { - return this.DefaultDataTemplate; - } - - ConversionPreset conversionPreset = (ConversionPreset)item; - - switch (conversionPreset.OutputType) - { - case OutputType.Aac: - return this.AacSettingsDataTemplate; - - case OutputType.Avi: - return this.AviSettingsDataTemplate; - - case OutputType.Flac: - return this.FlacSettingsDataTemplate; - - case OutputType.Gif: - return this.GifSettingsDataTemplate; - - case OutputType.Jpg: - return this.JpgSettingsDataTemplate; - - case OutputType.Mkv: - return this.MkvSettingsDataTemplate; - - case OutputType.Mp3: - return this.Mp3SettingsDataTemplate; - - case OutputType.Mp4: - return this.Mp4SettingsDataTemplate; - - case OutputType.Ogg: - return this.OggSettingsDataTemplate; - - case OutputType.Ogv: - return this.OgvSettingsDataTemplate; - - case OutputType.Png: - return this.PngSettingsDataTemplate; - - case OutputType.Wav: - return this.WavSettingsDataTemplate; - - case OutputType.Webm: - return this.WebmSettingsDataTemplate; - - case OutputType.Webp: - return this.WebpSettingsDataTemplate; - } - - return this.DefaultDataTemplate; - } - } -} diff --git a/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml b/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml index 502ec63..b66111d 100644 --- a/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml +++ b/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml @@ -19,6 +19,7 @@ + @@ -298,109 +299,82 @@ - - - - + @@ -640,22 +614,99 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Application/FileConverter/Views/SettingsWindow.xaml b/Application/FileConverter/Views/SettingsWindow.xaml index f0ee062..63bf555 100644 --- a/Application/FileConverter/Views/SettingsWindow.xaml +++ b/Application/FileConverter/Views/SettingsWindow.xaml @@ -277,14 +277,16 @@ - + - + + +