diff options
Diffstat (limited to 'win/CS/HandBrakeWPF')
7 files changed, 137 insertions, 34 deletions
diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs index 58f88cf3b..9a09c8cc1 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs @@ -79,6 +79,15 @@ namespace HandBrakeWPF.Properties { }
/// <summary>
+ /// Looks up a localized string similar to -- Add New Category --.
+ /// </summary>
+ public static string AddPresetView_AddNewCategory {
+ get {
+ return ResourceManager.GetString("AddPresetView_AddNewCategory", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Add Preset.
/// </summary>
public static string AddPresetView_AddPreset {
@@ -88,6 +97,15 @@ namespace HandBrakeWPF.Properties { }
/// <summary>
+ /// Looks up a localized string similar to Category.
+ /// </summary>
+ public static string AddPresetView_Category {
+ get {
+ return ResourceManager.GetString("AddPresetView_Category", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Description:.
/// </summary>
public static string AddPresetView_Description {
diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx index 8efdc2de5..3546ddbf5 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx +++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx @@ -983,4 +983,10 @@ This will not affect your current settings in the Subtitle tab.</value> <data name="Preset_Official" xml:space="preserve">
<value>Official</value>
</data>
+ <data name="AddPresetView_Category" xml:space="preserve">
+ <value>Category</value>
+ </data>
+ <data name="AddPresetView_AddNewCategory" xml:space="preserve">
+ <value>-- Add New Category --</value>
+ </data>
</root>
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs index f75c054c5..079d9424a 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs @@ -9,6 +9,7 @@ namespace HandBrakeWPF.Services.Presets.Interfaces
{
+ using System.Collections.Generic;
using System.Collections.ObjectModel;
using HandBrake.ApplicationServices.Model;
@@ -46,6 +47,14 @@ namespace HandBrakeWPF.Services.Presets.Interfaces void LoadCategoryStates();
/// <summary>
+ /// Get a list of preset categories.
+ /// </summary>
+ /// <returns>
+ /// String list.
+ /// </returns>
+ IList<PresetDisplayCategory> GetPresetCategories(bool userCategoriesOnly);
+
+ /// <summary>
/// Add a new preset to the system
/// </summary>
/// <param name="preset">
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Model/PresetDisplayCategory.cs b/win/CS/HandBrakeWPF/Services/Presets/Model/PresetDisplayCategory.cs index f70fd4680..1712f4756 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/Model/PresetDisplayCategory.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/Model/PresetDisplayCategory.cs @@ -18,16 +18,17 @@ namespace HandBrakeWPF.Services.Presets.Model private bool isSelected; private bool isExpanded; - public PresetDisplayCategory(string category, BindingList<Preset> presets) + public PresetDisplayCategory(string category, bool isBuildIn, BindingList<Preset> presets) { + this.IsBuiltIn = isBuildIn; this.Category = category; this.Presets = presets; } public string Category { get; private set; } public BindingList<Preset> Presets { get; private set; } - public string Description => this.Category; + public bool IsBuiltIn { get; } public bool IsExpanded { diff --git a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs index f4057dbc3..c021c12ac 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs @@ -144,7 +144,7 @@ namespace HandBrakeWPF.Services.Presets else if (!string.IsNullOrEmpty(preset.Category))
{
// Otherwise, if we have category but it doesn't exist, create it.
- this.presets.Add(new PresetDisplayCategory(preset.Category, new BindingList<Preset> { preset }));
+ this.presets.Add(new PresetDisplayCategory(preset.Category, preset.IsBuildIn, new BindingList<Preset> { preset }));
}
else
{
@@ -576,6 +576,28 @@ namespace HandBrakeWPF.Services.Presets }
}
+ public IList<PresetDisplayCategory> GetPresetCategories(bool userCategoriesOnly)
+ {
+ List<PresetDisplayCategory> categoriesList = new List<PresetDisplayCategory>();
+
+ foreach (var item in this.Presets)
+ {
+ PresetDisplayCategory category = item as PresetDisplayCategory;
+ if (category != null)
+ {
+ if (userCategoriesOnly && category.IsBuiltIn)
+ {
+ continue;
+ }
+
+ categoriesList.Add(category);
+
+ }
+ }
+
+ return categoriesList;
+ }
+
#endregion
#region Private Helpers
diff --git a/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs index f8974a0c4..398fff3c8 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs @@ -10,6 +10,7 @@ namespace HandBrakeWPF.ViewModels
{
using System.Collections.Generic;
+ using System.Linq;
using System.Windows;
using Caliburn.Micro;
@@ -35,39 +36,20 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public class AddPresetViewModel : ViewModelBase, IAddPresetViewModel
{
- /// <summary>
- /// Backing field for the Preset Service
- /// </summary>
private readonly IPresetService presetService;
-
- /// <summary>
- /// Backing field for the error service
- /// </summary>
private readonly IErrorService errorService;
-
- /// <summary>
- /// The window manager.
- /// </summary>
private readonly IWindowManager windowManager;
-
- /// <summary>
- /// Backing fields for Selected Picture settings mode.
- /// </summary>
private PresetPictureSettingsMode selectedPictureSettingMode;
-
- /// <summary>
- /// Backging field for show custom inputs
- /// </summary>
private bool showCustomInputs;
-
- /// <summary>
- /// The source.
- /// </summary>
private Title selectedTitle;
private IAudioDefaultsViewModel audioDefaultsViewModel;
private ISubtitlesDefaultsViewModel subtitlesDefaultsViewModel;
+ private PresetDisplayCategory selectedPresetCategory;
+ private readonly PresetDisplayCategory addNewCategory = new PresetDisplayCategory(ResourcesUI.AddPresetView_AddNewCategory, true, null);
+ private bool canAddNewPresetCategory;
+
/// <summary>
/// Initializes a new instance of the <see cref="AddPresetViewModel"/> class.
/// </summary>
@@ -85,9 +67,11 @@ namespace HandBrakeWPF.ViewModels this.presetService = presetService;
this.errorService = errorService;
this.windowManager = windowManager;
- this.Title = "Add Preset";
+ this.Title = ResourcesUI.AddPresetView_AddPreset;
this.Preset = new Preset { IsBuildIn = false, IsDefault = false, Category = PresetService.UserPresetCatgoryName };
this.PictureSettingsModes = EnumHelper<PresetPictureSettingsMode>.GetEnumList();
+ this.PresetCategories = presetService.GetPresetCategories(true).Union(new List<PresetDisplayCategory> { addNewCategory }).ToList();
+ this.SelectedPresetCategory = this.PresetCategories.FirstOrDefault(n => n.Category == PresetService.UserPresetCatgoryName);
}
/// <summary>
@@ -126,6 +110,58 @@ namespace HandBrakeWPF.ViewModels }
}
+ public List<PresetDisplayCategory> PresetCategories { get; set; }
+
+ public PresetDisplayCategory SelectedPresetCategory
+ {
+ get
+ {
+ return this.selectedPresetCategory;
+ }
+ set
+ {
+ this.selectedPresetCategory = value;
+ this.CanAddNewPresetCategory = Equals(value, this.addNewCategory);
+
+ if (this.selectedPresetCategory != null
+ && !object.Equals(this.selectedPresetCategory, this.addNewCategory))
+ {
+ this.PresetCategory = this.selectedPresetCategory.Category;
+ }
+ else
+ {
+ this.PresetCategory = PresetService.UserPresetCatgoryName;
+ }
+ }
+ }
+
+ public string PresetCategory
+ {
+ get
+ {
+ return this.Preset.Category;
+ }
+ set
+ {
+ this.Preset.Category = value;
+ this.NotifyOfPropertyChange(() => this.PresetCategory);
+ }
+ }
+
+ public bool CanAddNewPresetCategory
+ {
+ get
+ {
+ return this.canAddNewPresetCategory;
+ }
+ set
+ {
+ if (value == this.canAddNewPresetCategory) return;
+ this.canAddNewPresetCategory = value;
+ this.NotifyOfPropertyChange();
+ }
+ }
+
/// <summary>
/// Gets or sets SelectedPictureSettingMode.
/// </summary>
diff --git a/win/CS/HandBrakeWPF/Views/AddPresetView.xaml b/win/CS/HandBrakeWPF/Views/AddPresetView.xaml index f47beb6cf..8f956d35a 100644 --- a/win/CS/HandBrakeWPF/Views/AddPresetView.xaml +++ b/win/CS/HandBrakeWPF/Views/AddPresetView.xaml @@ -50,6 +50,7 @@ <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
@@ -72,14 +73,24 @@ Text="{Binding Preset.Description, UpdateSourceTrigger=PropertyChanged}" />
+ <TextBlock Grid.Row="3"
+ Grid.Column="0" Margin="0,10,0,0"
+ Text="{x:Static Properties:ResourcesUI.AddPresetView_Category}" />
+ <StackPanel Grid.Row="3" Grid.Column="1" Orientation="Vertical" Margin="0,10,0,0">
+
+ <ComboBox ItemsSource="{Binding PresetCategories}" SelectedItem="{Binding SelectedPresetCategory}" DisplayMemberPath="Category" />
+ <TextBox Text="{Binding PresetCategory, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding CanAddNewPresetCategory, Converter={StaticResource boolToVisConverter}}" />
+ </StackPanel>
+
+
<!-- Settings -->
- <TextBlock Grid.Row="3" Margin="0,10,10,0"
+ <TextBlock Grid.Row="4" Margin="0,10,10,0"
Grid.Column="0"
Style="{StaticResource LongToolTipHolder}"
VerticalAlignment="Center"
ToolTip="{x:Static Properties:Resources.AddPreset_PictureSizeMode}"
Text="{x:Static Properties:ResourcesUI.AddPresetView_SavePictureSize}" />
- <ComboBox Grid.Row="3" Margin="0,10,0,0"
+ <ComboBox Grid.Row="4" Margin="0,10,0,0"
Grid.Column="1"
Width="125"
HorizontalAlignment="Left" VerticalAlignment="Center"
@@ -90,7 +101,7 @@ SelectedItem="{Binding SelectedPictureSettingMode,
Converter={StaticResource enumComboConverter}}" />
- <StackPanel Grid.Row="4"
+ <StackPanel Grid.Row="5"
Grid.Column="1"
Margin="0,10,0,0"
Orientation="Horizontal"
@@ -105,12 +116,12 @@ AllowEmpty="True" />
</StackPanel>
- <TextBlock Text="Audio:" Grid.Row="5" />
- <Button Content="Edit Defaults..." Grid.Row="5" Grid.Column="1" HorizontalAlignment="Left" Margin="0,5,0,0" Padding="8,2"
+ <TextBlock Text="Audio:" Grid.Row="6" />
+ <Button Content="Edit Defaults..." Grid.Row="6" Grid.Column="1" HorizontalAlignment="Left" Margin="0,5,0,0" Padding="8,2"
cal:Message.Attach="[Event Click] = [Action EditAudioDefaults]" />
- <TextBlock Text="Subtitles:" Grid.Row="6" />
- <Button Content="Edit Defaults..." Grid.Row="6" Grid.Column="1" HorizontalAlignment="Left" Margin="0,5,0,0" Padding="8,2"
+ <TextBlock Text="Subtitles:" Grid.Row="7" />
+ <Button Content="Edit Defaults..." Grid.Row="7" Grid.Column="1" HorizontalAlignment="Left" Margin="0,5,0,0" Padding="8,2"
cal:Message.Attach="[Event Click] = [Action EditSubtitleDefaults]" />
</Grid>
|