diff --git a/Application/FileConverter/FileConverter.csproj b/Application/FileConverter/FileConverter.csproj index 892137a..1e21dde 100644 --- a/Application/FileConverter/FileConverter.csproj +++ b/Application/FileConverter/FileConverter.csproj @@ -128,6 +128,7 @@ + @@ -155,6 +156,7 @@ + SettingsWindow.xaml diff --git a/Application/FileConverter/ValueConverters/Generic/ObjectToLocalizedString.cs b/Application/FileConverter/ValueConverters/Generic/ObjectToLocalizedString.cs index f26ff46..434a55e 100644 --- a/Application/FileConverter/ValueConverters/Generic/ObjectToLocalizedString.cs +++ b/Application/FileConverter/ValueConverters/Generic/ObjectToLocalizedString.cs @@ -19,6 +19,7 @@ namespace FileConverter.ValueConverters.Generic string typeName = value.GetType().Name; string localizationKey = $"{typeName}{stringValue}Name"; + localizationKey = localizationKey.Replace(" ", string.Empty); string resource = Properties.Resources.ResourceManager.GetString(localizationKey); if (resource == null) diff --git a/Application/FileConverter/ValueConverters/OutputTypeEnumToViewModel.cs b/Application/FileConverter/ValueConverters/OutputTypeEnumToViewModel.cs new file mode 100644 index 0000000..bc8e66e --- /dev/null +++ b/Application/FileConverter/ValueConverters/OutputTypeEnumToViewModel.cs @@ -0,0 +1,37 @@ +// License: http://www.gnu.org/licenses/gpl.html GPL version 3. + +using System.Linq; +using FileConverter.Windows; + +namespace FileConverter.ValueConverters +{ + using System; + using System.Globalization; + using System.Windows.Data; + + public class OutputTypeEnumToViewModel : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (!(value is OutputType)) + { + throw new ArgumentException("The value must be an output type value."); + } + + OutputType outputType = (OutputType)value; + + return SettingsWindow.OutputTypeViewModels.FirstOrDefault(match => match.Type == outputType); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + OutputTypeViewModel outputTypeViewModel = value as OutputTypeViewModel; + if (outputTypeViewModel == null) + { + return OutputType.None; + } + + return outputTypeViewModel.Type; + } + } +} \ No newline at end of file diff --git a/Application/FileConverter/Windows/OutputTypeViewModel.cs b/Application/FileConverter/Windows/OutputTypeViewModel.cs new file mode 100644 index 0000000..0f46b96 --- /dev/null +++ b/Application/FileConverter/Windows/OutputTypeViewModel.cs @@ -0,0 +1,37 @@ +// License: http://www.gnu.org/licenses/gpl.html GPL version 3. + +namespace FileConverter.Windows +{ + public class OutputTypeViewModel + { + public OutputTypeViewModel(OutputType type) + { + this.Type = type; + this.Category = Helpers.GetExtensionCategory(type.ToString().ToLowerInvariant()); + } + + public OutputType Type + { + get; + private set; + } + + public string Category + { + get; + set; + } + + public override bool Equals(object other) + { + OutputTypeViewModel outputTypeViewModel = other as OutputTypeViewModel; + + return outputTypeViewModel?.Type == this.Type; + } + + public override int GetHashCode() + { + return this.Type.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Application/FileConverter/Windows/SettingsWindow.xaml b/Application/FileConverter/Windows/SettingsWindow.xaml index 3a45a12..2ba8c43 100644 --- a/Application/FileConverter/Windows/SettingsWindow.xaml +++ b/Application/FileConverter/Windows/SettingsWindow.xaml @@ -13,6 +13,7 @@ WindowStartupLocation="CenterScreen" Icon="/FileConverter;component/Resources/ApplicationIcon.ico" Closing="SettingsWindow_OnClosing"> +