<Compile Include="Utilities\SystemInfo.cs" />\r
<Compile Include="Utilities\Win32.cs" />\r
<Compile Include="Utilities\Win7.cs" />\r
+ <Compile Include="ViewModels\Interfaces\IManagePresetViewModel.cs" />\r
+ <Compile Include="ViewModels\ManagePresetViewModel.cs" />\r
<Compile Include="ViewModels\AudioDefaultsViewModel.cs" />\r
<Compile Include="ViewModels\CountdownAlertViewModel.cs" />\r
<Compile Include="ViewModels\Interfaces\IAudioDefaultsViewModel.cs" />\r
<Compile Include="ViewModels\PopupWindowViewModel.cs" />\r
<Compile Include="ViewModels\StaticPreviewViewModel.cs" />\r
<Compile Include="ViewModels\SubtitlesDefaultsViewModel.cs" />\r
+ <Compile Include="Views\ManagePresetView.xaml.cs">\r
+ <DependentUpon>ManagePresetView.xaml</DependentUpon>\r
+ </Compile>\r
<Compile Include="Views\AudioDefaultsView.xaml.cs">\r
<DependentUpon>AudioDefaultsView.xaml</DependentUpon>\r
</Compile>\r
<Generator>MSBuild:Compile</Generator>\r
<SubType>Designer</SubType>\r
</Page>\r
+ <Page Include="Views\ManagePresetView.xaml">\r
+ <Generator>MSBuild:Compile</Generator>\r
+ <SubType>Designer</SubType>\r
+ </Page>\r
<Page Include="Views\AudioDefaultsView.xaml">\r
<Generator>MSBuild:Compile</Generator>\r
<SubType>Designer</SubType>\r
}\r
}\r
\r
+ /// <summary>\r
+ /// Looks up a localized string similar to Rename Preset.\r
+ /// </summary>\r
+ public static string MainView_PresetManage {\r
+ get {\r
+ return ResourceManager.GetString("MainView_PresetManage", resourceCulture);\r
+ }\r
+ }\r
+ \r
/// <summary>\r
/// Looks up a localized string similar to Presets.\r
/// </summary>\r
}\r
}\r
\r
+ /// <summary>\r
+ /// Looks up a localized string similar to Manage Preset.\r
+ /// </summary>\r
+ public static string ManagePresetView_ManagePreset {\r
+ get {\r
+ return ResourceManager.GetString("ManagePresetView_ManagePreset", resourceCulture);\r
+ }\r
+ }\r
+ \r
/// <summary>\r
/// Looks up a localized string similar to Meta Data.\r
/// </summary>\r
<data name="MainView_MetaDataTab" xml:space="preserve">\r
<value>Meta Data</value>\r
</data>\r
+ <data name="MainView_PresetManage" xml:space="preserve">\r
+ <value>Rename Preset</value>\r
+ </data>\r
+ <data name="ManagePresetView_ManagePreset" xml:space="preserve">\r
+ <value>Manage Preset</value>\r
+ </data>\r
</root>
\ No newline at end of file
/// <param name="name">Name of the preset</param>\r
/// <returns>True if found</returns>\r
bool CheckIfPresetExists(string name);\r
+\r
+ /// <summary>\r
+ /// Replace an existing preset with a modified one.\r
+ /// </summary>\r
+ void Replace(Preset existing, Preset replacement);\r
}\r
}
\ No newline at end of file
\r
#endregion\r
\r
+ /// <summary>\r
+ /// Initializes a new instance of the <see cref="PropertyChangedBase"/> class. \r
+ /// Creates an instance of <see cref="T:HandBrakeWPF.Utilities.PropertyChangedBase"/>.\r
+ /// </summary>\r
+ public Preset()\r
+ {\r
+ }\r
+\r
+ /// <summary>\r
+ /// Initializes a new instance of the <see cref="PropertyChangedBase"/> class. \r
+ /// Creates an instance of <see cref="T:HandBrakeWPF.Utilities.PropertyChangedBase"/>.\r
+ /// </summary>\r
+ public Preset(Preset preset)\r
+ {\r
+ this.Category = preset.Category;\r
+ this.Description = preset.Description;\r
+ this.IsBuildIn = preset.IsBuildIn;\r
+ this.Name = preset.Name;\r
+ this.PictureSettingsMode = preset.PictureSettingsMode;\r
+ this.Task = new EncodeTask(preset.Task);\r
+ this.AudioTrackBehaviours = new AudioBehaviours(preset.AudioTrackBehaviours);\r
+ this.SubtitleTrackBehaviours = new SubtitleBehaviours(preset.SubtitleTrackBehaviours);\r
+ }\r
+\r
#region Properties\r
\r
/// <summary>\r
}\r
}\r
\r
+ /// <summary>\r
+ /// Replace an existing preset with a modified one.\r
+ /// </summary>\r
+ public void Replace(Preset existing, Preset replacement)\r
+ {\r
+ this.Remove(existing);\r
+ this.Add(replacement);\r
+ }\r
+\r
/// <summary>\r
/// Remove a preset with a given name from either the built in or user preset list.\r
/// </summary>\r
this.container.Singleton<IMainViewModel, MainViewModel>();\r
this.container.Singleton<IQueueViewModel, QueueViewModel>();\r
this.container.PerRequest<IAddPresetViewModel, AddPresetViewModel>();\r
+ this.container.PerRequest<IManagePresetViewModel, ManagePresetViewModel>();\r
this.container.Singleton<ILogViewModel, LogViewModel>();\r
this.container.Singleton<IAboutViewModel, AboutViewModel>();\r
this.container.Singleton<IOptionsViewModel, OptionsViewModel>();\r
--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="IManagePresetViewModel.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// The Manage Preset View Model Interface
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.ViewModels.Interfaces
+{
+ using HandBrakeWPF.Services.Presets.Model;
+
+ /// <summary>
+ /// The Add Preset View Model
+ /// </summary>
+ public interface IManagePresetViewModel
+ {
+ /// <summary>
+ /// Prepare the Preset window
+ /// </summary>
+ void Setup(Preset preset);
+
+ /// <summary>
+ /// Get the managed preset.
+ /// </summary>
+ Preset Preset { get; }
+ }
+}
}\r
}\r
\r
+ /// <summary>\r
+ /// Manage the current Preset\r
+ /// </summary>\r
+ public void PresetManage()\r
+ {\r
+ if (this.SelectedPreset == null)\r
+ {\r
+ this.errorService.ShowMessageBox(\r
+ Resources.Main_SelectPresetForUpdate, Resources.Main_NoPresetSelected, MessageBoxButton.OK, MessageBoxImage.Warning);\r
+\r
+ return;\r
+ }\r
+\r
+ if (this.SelectedPreset.IsBuildIn)\r
+ {\r
+ this.errorService.ShowMessageBox(\r
+ Resources.Main_NoUpdateOfBuiltInPresets, Resources.Main_NoPresetSelected, MessageBoxButton.OK, MessageBoxImage.Warning);\r
+ return;\r
+ }\r
+\r
+ IManagePresetViewModel presetViewModel = IoC.Get<IManagePresetViewModel>();\r
+ presetViewModel.Setup(this.SelectedPreset);\r
+ this.windowManager.ShowDialog(presetViewModel);\r
+ Preset preset = presetViewModel.Preset;\r
+\r
+ this.SelectedPreset = preset; // Reselect the preset\r
+ }\r
+\r
/// <summary>\r
/// Remove a Preset\r
/// </summary>\r
--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="ManagePresetViewModel.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// The Add Preset View Model
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.ViewModels
+{
+ using System.Windows;
+
+ using Caliburn.Micro;
+
+ using HandBrakeWPF.Properties;
+ using HandBrakeWPF.Services.Interfaces;
+ using HandBrakeWPF.Services.Presets;
+ using HandBrakeWPF.Services.Presets.Interfaces;
+ using HandBrakeWPF.Services.Presets.Model;
+ using HandBrakeWPF.ViewModels.Interfaces;
+
+ /// <summary>
+ /// The Add Preset View Model
+ /// </summary>
+ public class ManagePresetViewModel : ViewModelBase, IManagePresetViewModel
+ {
+ private readonly IPresetService presetService;
+ private readonly IErrorService errorService;
+ private readonly IWindowManager windowManager;
+ private Preset existingPreset;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ManagePresetViewModel"/> class.
+ /// </summary>
+ /// <param name="presetService">
+ /// The Preset Service
+ /// </param>
+ /// <param name="errorService">
+ /// The Error Service
+ /// </param>
+ /// <param name="windowManager">
+ /// The window Manager.
+ /// </param>
+ public ManagePresetViewModel(IPresetService presetService, IErrorService errorService, IWindowManager windowManager)
+ {
+ this.presetService = presetService;
+ this.errorService = errorService;
+ this.windowManager = windowManager;
+ this.Title = "Manage Preset";
+ this.Preset = new Preset { IsBuildIn = false, IsDefault = false, Category = PresetService.UserPresetCatgoryName};
+ }
+
+ /// <summary>
+ /// Gets the Preset
+ /// </summary>
+ public Preset Preset { get; private set; }
+
+ /// <summary>
+ /// Prepare the Preset window to create a Preset Object later.
+ /// </summary>
+ public void Setup(Preset presetToEdit)
+ {
+ this.Preset = new Preset(presetToEdit); // Clone. We will not touch the existing object.
+ this.existingPreset = presetToEdit;
+ }
+
+ /// <summary>
+ /// Add a Preset
+ /// </summary>
+ public void Save()
+ {
+ if (string.IsNullOrEmpty(this.Preset.Name))
+ {
+ this.errorService.ShowMessageBox(
+ Resources.AddPresetViewModel_PresetMustProvideName,
+ Resources.Error,
+ MessageBoxButton.OK,
+ MessageBoxImage.Error);
+ return;
+ }
+
+ if (this.presetService.CheckIfPresetExists(this.Preset.Name))
+ {
+ MessageBoxResult result =
+ this.errorService.ShowMessageBox(
+ Resources.AddPresetViewModel_PresetWithSameNameOverwriteWarning,
+ Resources.Error,
+ MessageBoxButton.YesNo,
+ MessageBoxImage.Error);
+ if (result == MessageBoxResult.No)
+ {
+ return;
+ }
+ }
+
+ // Save the Preset
+ this.presetService.Replace(this.existingPreset, this.Preset);
+ this.Close();
+ }
+
+ /// <summary>
+ /// Cancel adding a preset
+ /// </summary>
+ public void Cancel()
+ {
+ this.Close();
+ }
+
+ /// <summary>
+ /// Close this window.
+ /// </summary>
+ public void Close()
+ {
+ this.TryClose();
+ }
+ }
+}
<MenuItem Header="{x:Static Properties:ResourcesUI.MainView_SetDefault}" cal:Message.Attach="[Event Click] = [Action PresetSetDefault]" />\r
<Separator />\r
<MenuItem Header="{x:Static Properties:ResourcesUI.MainView_UpdateSelectedPreset}" cal:Message.Attach="[Event Click] = [Action PresetUpdate]" />\r
+ <MenuItem Header="{x:Static Properties:ResourcesUI.MainView_PresetManage}" cal:Message.Attach="[Event Click] = [Action PresetManage]" />\r
<Separator />\r
<MenuItem Header="{x:Static Properties:ResourcesUI.Preset_Import}" cal:Message.Attach="[Event Click] = [Action PresetImport]" />\r
<MenuItem Header="{x:Static Properties:ResourcesUI.Preset_Export}" cal:Message.Attach="[Event Click] = [Action PresetExport]" />\r
--- /dev/null
+<Window x:Class="HandBrakeWPF.Views.ManagePresetView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:cal="http://www.caliburnproject.org"
+ xmlns:Converters="clr-namespace:HandBrakeWPF.Converters"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:Properties="clr-namespace:HandBrakeWPF.Properties" xmlns:controls="clr-namespace:HandBrakeWPF.Controls"
+ Title="{Binding Title}"
+ Width="350"
+ ResizeMode="NoResize"
+ SizeToContent="Height"
+ WindowStartupLocation="CenterScreen"
+ TextOptions.TextFormattingMode="Display"
+ mc:Ignorable="d">
+
+ <Window.Resources>
+ <Converters:BooleanToVisibilityConverter x:Key="boolToVisConverter" />
+ <Converters:EnumComboConverter x:Key="enumComboConverter" />
+
+ <Style x:Key="LongToolTipHolder" TargetType="FrameworkElement">
+ <Setter Property="ToolTipService.ShowDuration" Value="20000" />
+ <Setter Property="Margin" Value="0,2,0,2" />
+ </Style>
+ </Window.Resources>
+
+ <Grid HorizontalAlignment="Stretch"
+ VerticalAlignment="Stretch">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="*" />
+ <RowDefinition Height="Auto" />
+ </Grid.RowDefinitions>
+
+ <TextBlock Text="{x:Static Properties:ResourcesUI.ManagePresetView_ManagePreset}" FontSize="26" FontFamily="Segoe UI Light" FontWeight="Bold" Margin="10,10,10,10" Grid.Row="0" />
+
+ <!-- Header -->
+ <Grid Grid.Row="1" Margin="10,0,10,0">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="120" />
+ <ColumnDefinition Width="*" />
+ </Grid.ColumnDefinitions>
+
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="*" />
+ </Grid.RowDefinitions>
+
+ <!-- Name -->
+ <TextBlock Grid.Row="0"
+ Grid.Column="0"
+ Text="{x:Static Properties:ResourcesUI.AddPresetView_Name}" />
+ <TextBox Grid.Row="0"
+ Grid.Column="1"
+ HorizontalAlignment="Stretch"
+ Text="{Binding Preset.Name, UpdateSourceTrigger=PropertyChanged}" />
+
+
+ <!-- Description -->
+ <TextBlock Grid.Row="2"
+ Grid.Column="0" Margin="0,10,0,0"
+ Text="{x:Static Properties:ResourcesUI.AddPresetView_Description}" />
+ <TextBox Grid.Row="2"
+ Grid.Column="1" Margin="0,10,0,0"
+
+ Text="{Binding Preset.Description, UpdateSourceTrigger=PropertyChanged}" />
+
+ <!-- Settings -->
+
+ <StackPanel Grid.Row="4"
+ Grid.Column="1"
+ Margin="0,10,0,0"
+ Orientation="Horizontal"
+ Visibility="{Binding ShowCustomInputs,
+ Converter={StaticResource boolToVisConverter}}"/>
+
+ </Grid>
+
+ <!-- Controls -->
+ <Grid Grid.Row="3"
+ Margin="0,20,0,0">
+
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*" />
+ <ColumnDefinition Width="Auto" />
+ <ColumnDefinition Width="Auto" />
+ </Grid.ColumnDefinitions>
+
+ <Button Grid.Column="1"
+ Margin="0,5,10,10"
+ cal:Message.Attach="[Event Click] = [Action Cancel]"
+ Content="{x:Static Properties:ResourcesUI.Generic_Cancel}"
+ IsCancel="True"
+ Padding="8,2" />
+ <Button Grid.Column="2"
+ Margin="0,5,10,10"
+ cal:Message.Attach="[Event Click] = [Action Save]"
+ Content="{x:Static Properties:ResourcesUI.Generic_Save}"
+ IsDefault="True"
+ Padding="8,2" />
+ </Grid>
+
+ </Grid>
+</Window>
--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="ManagePresetView.xaml.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Interaction logic for ManagePresetView.xaml
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Views
+{
+ using System.Windows;
+
+ /// <summary>
+ /// Interaction logic for ManagePresetView.xaml
+ /// </summary>
+ public partial class ManagePresetView : Window
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ManagePresetView"/> class.
+ /// </summary>
+ public ManagePresetView()
+ {
+ InitializeComponent();
+ }
+ }
+}