mirror of
https://github.com/Tichau/FileConverter.git
synced 2026-11-22 18:41:48 +01:00
Add categories in output type drop down.
This commit is contained in:
1 parent
68ba31632a
commit
8ebddd9f0c
6 files changed
+124
-23
No files matched your search
@@ -128,6 +128,7 @@
|
||||
<Compile Include="Upgrade\UpgradeVersionDescription.cs" />
|
||||
<Compile Include="ValueConverters\ApplicationVersionToApplicationName.cs" />
|
||||
<Compile Include="ConversionPreset\ConversionPreset.cs" />
|
||||
<Compile Include="ValueConverters\OutputTypeEnumToViewModel.cs" />
|
||||
<Compile Include="ValueConverters\BitrateToString.cs" />
|
||||
<Compile Include="ValueConverters\FileNameConverter.cs" />
|
||||
<Compile Include="ValueConverters\Generic\ObjectToLocalizedString.cs" />
|
||||
@@ -155,6 +156,7 @@
|
||||
<Compile Include="Windows\ConversionSettingsTemplateSelector.cs" />
|
||||
<Compile Include="Windows\InputExtension.cs" />
|
||||
<Compile Include="Windows\InputExtensionCategory.cs" />
|
||||
<Compile Include="Windows\OutputTypeViewModel.cs" />
|
||||
<Compile Include="Windows\SettingsWindow.xaml.cs">
|
||||
<DependentUpon>SettingsWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// <copyright file="BitrateToString.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// <copyright file="OutputFileType.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
WindowStartupLocation="CenterScreen" Icon="/FileConverter;component/Resources/ApplicationIcon.ico"
|
||||
Closing="SettingsWindow_OnClosing">
|
||||
<Window.Resources>
|
||||
|
||||
<!-- Donation button style -->
|
||||
|
||||
<Style x:Key="DonateFocusVisual">
|
||||
@@ -89,6 +90,7 @@
|
||||
<valueConverters:FileNameConverter x:Key="FileNameConverter"/>
|
||||
<generic:CollectionContainsElementToBool x:Key="CollectionContainsElementToBool"/>
|
||||
<generic:FormatStringConverter x:Key="FormatStringConverter"/>
|
||||
<valueConverters:OutputTypeEnumToViewModel x:Key="OutputTypeEnumToClass"/>
|
||||
|
||||
<generic:ValueConverterGroup x:Key="ConversionSettingsToEnum">
|
||||
<valueConverters:ConversionSettingsToString/>
|
||||
@@ -790,7 +792,24 @@
|
||||
|
||||
<GroupBox Header="{x:Static project:Resources.OutputFormat}" Grid.Row="1" Grid.Column="1" Margin="5">
|
||||
<StackPanel>
|
||||
<ComboBox x:Name="OutputFormats" Margin="5" Height="25" VerticalAlignment="Top" SelectedItem="{Binding SelectedPreset.OutputType, ElementName=window, Mode=TwoWay}"/>
|
||||
<ComboBox x:Name="OutputFormats" Margin="5" Height="29" VerticalAlignment="Top"
|
||||
SelectedItem="{Binding SelectedPreset.OutputType, Converter={StaticResource OutputTypeEnumToClass}, ElementName=window, Mode=TwoWay}">
|
||||
<ComboBox.GroupStyle>
|
||||
<GroupStyle>
|
||||
<GroupStyle.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Foreground="#004B82" Background="#86C8F6" FontWeight="Bold" Padding="5,5,5,5"
|
||||
Text="{Binding Name, Converter={StaticResource ObjectToLocalizedString}}"/>
|
||||
</DataTemplate>
|
||||
</GroupStyle.HeaderTemplate>
|
||||
</GroupStyle>
|
||||
</ComboBox.GroupStyle>
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate DataType="windows:OutputTypeViewModel">
|
||||
<TextBlock Text="{Binding Type}" Padding="10,2,2,2"/>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<ContentControl ContentTemplateSelector="{StaticResource ResourceKey=ConversionSettingsSelector}"
|
||||
Content="{Binding SelectedPreset.OutputType, ElementName=window, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
@@ -10,8 +10,10 @@ namespace FileConverter
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
|
||||
using FileConverter.Windows;
|
||||
using FileConverter.Annotations;
|
||||
using FileConverter.Commands;
|
||||
using FileConverter.ConversionJobs;
|
||||
@@ -42,28 +44,12 @@ namespace FileConverter
|
||||
Application application = Application.Current as Application;
|
||||
this.ApplicationSettings = application.Settings;
|
||||
this.PresetList.ItemsSource = this.settings.ConversionPresets;
|
||||
|
||||
OutputType[] outputTypes = new[]
|
||||
{
|
||||
OutputType.Ogg,
|
||||
OutputType.Mp3,
|
||||
OutputType.Aac,
|
||||
OutputType.Flac,
|
||||
OutputType.Wav,
|
||||
OutputType.Mkv,
|
||||
OutputType.Mp4,
|
||||
OutputType.Ogv,
|
||||
OutputType.Webm,
|
||||
OutputType.Avi,
|
||||
OutputType.Ico,
|
||||
OutputType.Jpg,
|
||||
OutputType.Png,
|
||||
OutputType.Gif,
|
||||
OutputType.Pdf,
|
||||
};
|
||||
|
||||
this.OutputFormats.ItemsSource = outputTypes;
|
||||
|
||||
ListCollectionView collectionView = new ListCollectionView(new List<OutputTypeViewModel>(SettingsWindow.OutputTypeViewModels));
|
||||
collectionView.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
|
||||
|
||||
this.OutputFormats.ItemsSource = collectionView;
|
||||
|
||||
this.InitializeCompatibleInputExtensions();
|
||||
}
|
||||
|
||||
@@ -119,7 +105,7 @@ namespace FileConverter
|
||||
}
|
||||
|
||||
this.OnPropertyChanged();
|
||||
this.OnPropertyChanged("InputCategories");
|
||||
this.OnPropertyChanged(nameof(this.InputCategories));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +149,25 @@ namespace FileConverter
|
||||
set;
|
||||
}
|
||||
|
||||
public static OutputTypeViewModel[] OutputTypeViewModels => new[]
|
||||
{
|
||||
new OutputTypeViewModel(OutputType.Ogg),
|
||||
new OutputTypeViewModel(OutputType.Mp3),
|
||||
new OutputTypeViewModel(OutputType.Aac),
|
||||
new OutputTypeViewModel(OutputType.Flac),
|
||||
new OutputTypeViewModel(OutputType.Wav),
|
||||
new OutputTypeViewModel(OutputType.Mkv),
|
||||
new OutputTypeViewModel(OutputType.Mp4),
|
||||
new OutputTypeViewModel(OutputType.Ogv),
|
||||
new OutputTypeViewModel(OutputType.Webm),
|
||||
new OutputTypeViewModel(OutputType.Avi),
|
||||
new OutputTypeViewModel(OutputType.Png),
|
||||
new OutputTypeViewModel(OutputType.Jpg),
|
||||
new OutputTypeViewModel(OutputType.Ico),
|
||||
new OutputTypeViewModel(OutputType.Gif),
|
||||
new OutputTypeViewModel(OutputType.Pdf),
|
||||
};
|
||||
|
||||
public InputPostConversionAction[] InputPostConversionActions => new[]
|
||||
{
|
||||
InputPostConversionAction.None,
|
||||
|
||||
Reference in new issue
Block a user