From 2efd8f264113bcd3d8c39a1f408c16cc27100aa7 Mon Sep 17 00:00:00 2001 From: sr55 Date: Thu, 1 Mar 2012 19:01:54 +0000 Subject: WinGui: (WPF) Further work wiring up the new UI. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4479 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Model/EncodeTask.cs | 90 +++++++ .../Model/Encoding/AllowedPassthru.cs | 1 + .../Model/Encoding/AudioTrack.cs | 19 ++ .../Model/Encoding/ChapterMarker.cs | 13 + .../Model/Encoding/SubtitleTrack.cs | 30 +++ .../HandBrake.ApplicationServices/Parsing/Title.cs | 2 - .../Services/ScanService.cs | 2 +- .../HandBrakeInterop/Model/Cropping.cs | 51 +++- .../HandBrakeWPF/Converters/AudioEnumConverter.cs | 83 ------- .../HandBrakeWPF/Converters/EnumComboConverter.cs | 155 ++++++++++++ .../Converters/FullPathToFileNameConverter.cs | 5 +- win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 14 +- .../HandBrakeWPF/ViewModels/AdvancedViewModel.cs | 86 +++++++ win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs | 40 +++ .../HandBrakeWPF/ViewModels/ChaptersViewModel.cs | 17 +- win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs | 10 + .../ViewModels/Interfaces/IAdvancedViewModel.cs | 19 +- .../ViewModels/Interfaces/IAudioViewModel.cs | 18 +- .../ViewModels/Interfaces/IChaptersViewModel.cs | 18 +- .../ViewModels/Interfaces/IFiltersViewModel.cs | 18 +- .../Interfaces/IPictureSettingsViewModel.cs | 18 +- .../ViewModels/Interfaces/ISubtitlesViewModel.cs | 18 +- .../ViewModels/Interfaces/ITabInterface.cs | 42 ++++ .../ViewModels/Interfaces/IVideoViewModel.cs | 18 +- win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 50 +++- .../ViewModels/PictureSettingsViewModel.cs | 230 +++++++++--------- win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs | 13 +- .../HandBrakeWPF/ViewModels/SubtitlesViewModel.cs | 11 + win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs | 263 +++++++++++--------- win/CS/HandBrakeWPF/Views/AdvancedView.xaml | 47 +++- win/CS/HandBrakeWPF/Views/AudioView.xaml | 19 +- win/CS/HandBrakeWPF/Views/ChaptersView.xaml | 3 +- win/CS/HandBrakeWPF/Views/MainView.xaml | 1 + win/CS/HandBrakeWPF/Views/QueueView.xaml | 9 +- win/CS/HandBrakeWPF/Views/SubtitlesView.xaml | 6 +- win/CS/HandBrakeWPF/Views/VideoView.xaml | 12 +- win/CS/frmMain.Designer.cs | 165 ++++++------- win/CS/frmMain.cs | 1 + .../WPFDragDrop/GongSolutions.Wpf.DragDrop.XML | 270 +++++++++++++++++++++ .../WPFDragDrop/GongSolutions.Wpf.DragDrop.dll | Bin 0 -> 29184 bytes 40 files changed, 1315 insertions(+), 572 deletions(-) delete mode 100644 win/CS/HandBrakeWPF/Converters/AudioEnumConverter.cs create mode 100644 win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/Interfaces/ITabInterface.cs create mode 100644 win/CS/libraries/WPFDragDrop/GongSolutions.Wpf.DragDrop.XML create mode 100644 win/CS/libraries/WPFDragDrop/GongSolutions.Wpf.DragDrop.dll (limited to 'win') diff --git a/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs b/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs index 6f3500d9e..16d8d1694 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs @@ -33,6 +33,96 @@ namespace HandBrake.ApplicationServices.Model } #region Source + + /// + /// Initializes a new instance of the class. + /// Copy Constructor + /// + /// + /// The task. + /// + public EncodeTask(EncodeTask task) + { + this.AdvancedEncoderOptions = task.AdvancedEncoderOptions; + this.AllowedPassthruOptions = new AllowedPassthru(task.AllowedPassthruOptions); + this.Anamorphic = task.Anamorphic; + this.Angle = task.Angle; + + this.AudioTracks = new ObservableCollection(); + foreach (AudioTrack track in task.AudioTracks) + { + this.AudioTracks.Add(new AudioTrack(track)); + } + + + this.ChapterNames = new ObservableCollection(); + foreach (ChapterMarker track in task.ChapterNames) + { + this.ChapterNames.Add(new ChapterMarker(track)); + } + + this.ChapterMarkersFilePath = task.ChapterMarkersFilePath; + this.Cropping = new Cropping(task.Cropping); + this.CustomDecomb = task.CustomDecomb; + this.CustomDeinterlace = task.CustomDeinterlace; + this.CustomDenoise = task.CustomDenoise; + this.CustomDetelecine = task.CustomDetelecine; + this.Deblock = task.Deblock; + this.Decomb = task.Decomb; + this.Deinterlace = task.Deinterlace; + this.Denoise = task.Denoise; + this.Destination = task.Destination; + this.Detelecine = task.Detelecine; + this.DisableLibDvdNav = task.DisableLibDvdNav; + this.DisplayWidth = task.DisplayWidth; + this.EndPoint = task.EndPoint; + this.Framerate = task.Framerate; + this.FramerateMode = task.FramerateMode; + this.Grayscale = task.Grayscale; + this.HasCropping = task.HasCropping; + this.Height = task.Height; + this.IncludeChapterMarkers = task.IncludeChapterMarkers; + this.IPod5GSupport = task.IPod5GSupport; + this.KeepDisplayAspect = task.KeepDisplayAspect; + this.LargeFile = task.LargeFile; + this.MaxHeight = task.MaxHeight; + this.MaxWidth = task.MaxWidth; + this.Modulus = task.Modulus; + this.OptimizeMP4 = task.OptimizeMP4; + this.OutputFormat = task.OutputFormat; + this.PixelAspectX = task.PixelAspectX; + this.PixelAspectY = task.PixelAspectY; + this.PointToPointMode = task.PointToPointMode; + this.PresetBuildNumber = task.PresetBuildNumber; + this.PresetDescription = task.PresetDescription; + this.PresetName = task.PresetName; + this.Quality = task.Quality; + this.Source = task.Source; + this.StartPoint = task.StartPoint; + + this.SubtitleTracks = new ObservableCollection(); + foreach (SubtitleTrack subtitleTrack in task.SubtitleTracks) + { + this.SubtitleTracks.Add(new SubtitleTrack(subtitleTrack)); + } + + this.Title = task.Title; + this.TurboFirstPass = task.TurboFirstPass; + this.TwoPass = task.TwoPass; + this.Type = task.Type; + this.UsesMaxPictureSettings = task.UsesMaxPictureSettings; + this.UsesPictureFilters = task.UsesPictureFilters; + this.UsesPictureSettings = task.UsesPictureSettings; + this.Verbosity = task.Verbosity; + this.VideoBitrate = task.VideoBitrate; + this.VideoEncoder = task.VideoEncoder; + this.VideoEncodeRateType = task.VideoEncodeRateType; + this.Width = task.Width; + this.x264Preset = task.x264Preset; + this.x264Profile = task.x264Profile; + this.X264Tune = task.X264Tune; + } + /// /// Gets or sets Source. /// diff --git a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AllowedPassthru.cs b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AllowedPassthru.cs index a892eb119..4b86fc9a1 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AllowedPassthru.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AllowedPassthru.cs @@ -43,6 +43,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding /// /// Initializes a new instance of the class. + /// Copy Constructor /// /// /// The initial value. diff --git a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs index 3ef786629..4d05591c5 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs @@ -83,6 +83,25 @@ namespace HandBrake.ApplicationServices.Model.Encoding this.ScannedTrack = new Audio(); } + /// + /// Initializes a new instance of the class. + /// Copy Constructor + /// + /// + /// The track. + /// + public AudioTrack(AudioTrack track) + { + this.bitrate = track.Bitrate; + this.drc = track.DRC; + this.encoder = track.Encoder; + this.gain = track.Gain; + this.mixDown = track.MixDown; + this.sampleRate = track.SampleRate; + this.scannedTrack = new Audio(); + this.trackName = track.TrackName; + } + #endregion #region Public Properties diff --git a/win/CS/HandBrake.ApplicationServices/Model/Encoding/ChapterMarker.cs b/win/CS/HandBrake.ApplicationServices/Model/Encoding/ChapterMarker.cs index 8fb1a5920..88f99008c 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/Encoding/ChapterMarker.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/Encoding/ChapterMarker.cs @@ -32,6 +32,19 @@ namespace HandBrake.ApplicationServices.Model.Encoding this.ChapterNumber = number; } + /// + /// Initializes a new instance of the class. + /// Copy Constructor + /// + /// + /// The chapter. + /// + public ChapterMarker(ChapterMarker chapter) + { + this.ChapterName = chapter.ChapterName; + this.ChapterNumber = chapter.ChapterNumber; + } + /// /// Gets or sets The number of this Chapter, in regards to it's parent Title /// diff --git a/win/CS/HandBrake.ApplicationServices/Model/Encoding/SubtitleTrack.cs b/win/CS/HandBrake.ApplicationServices/Model/Encoding/SubtitleTrack.cs index fa7dfd10e..9ad24a1f9 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/Encoding/SubtitleTrack.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/Encoding/SubtitleTrack.cs @@ -28,8 +28,38 @@ namespace HandBrake.ApplicationServices.Model.Encoding #endregion + /// + /// Initializes a new instance of the class. + /// + public SubtitleTrack() + { + } + + /// + /// Initializes a new instance of the class. + /// Copy Constructor + /// + /// + /// The subtitle. + /// + public SubtitleTrack(SubtitleTrack subtitle) + { + this.Burned = subtitle.Burned; + this.Default = subtitle.Default; + this.Forced = subtitle.Forced; + this.sourceTrack = subtitle.SourceTrack; + this.SrtCharCode = subtitle.SrtCharCode; + this.SrtFileName = subtitle.SrtFileName; + this.SrtLang = subtitle.SrtLang; + this.SrtOffset = subtitle.SrtOffset; + this.SrtPath = subtitle.SrtPath; + this.SubtitleType = subtitle.SubtitleType; + this.SourceTrack = subtitle.SourceTrack; + } + #region Public Properties + /// /// Gets or sets a value indicating whether Burned. /// diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs index 4c800f24c..51c2f11c3 100644 --- a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs +++ b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs @@ -245,8 +245,6 @@ namespace HandBrake.ApplicationServices.Parsing public TimeSpan CalculateDuration(int startPoint, int endPoint) { TimeSpan duration = TimeSpan.FromSeconds(0.0); - startPoint++; - endPoint++; if (startPoint != 0 && endPoint != 0 && endPoint <= this.Chapters.Count) { for (int i = startPoint; i <= endPoint; i++) diff --git a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs index 7c6192636..cc94a3f7d 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs @@ -259,7 +259,7 @@ namespace HandBrake.ApplicationServices.Services this.readData = new Parser(this.hbProc.StandardError.BaseStream); this.readData.OnScanProgress += this.OnScanProgress; this.SouceData = Source.Parse(this.readData); - this.SouceData.ScanPath = source; + this.SouceData.ScanPath = (string)sourcePath; // Write the Buffer out to file. using (StreamWriter scanLog = new StreamWriter(dvdInfoPath)) diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Cropping.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Cropping.cs index e13c9daff..8e6e6c1f5 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Cropping.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Cropping.cs @@ -9,7 +9,10 @@ namespace HandBrake.Interop.Model { - public class Cropping + /// + /// The Cropping Model + /// + public class Cropping { /// /// Initializes a new instance of the class. @@ -18,6 +21,21 @@ namespace HandBrake.Interop.Model { } + /// + /// Initializes a new instance of the class. + /// Copy Constructor + /// + /// + /// The croping. + /// + public Cropping(Cropping croping) + { + this.Top = croping.Top; + this.Bottom = croping.Bottom; + this.Left = croping.Left; + this.Right = croping.Right; + } + /// /// Initializes a new instance of the class. /// @@ -41,12 +59,33 @@ namespace HandBrake.Interop.Model this.Right = right; } - public int Top { get; set; } - public int Bottom { get; set; } - public int Left { get; set; } - public int Right { get; set; } + /// + /// Gets or sets Top. + /// + public int Top { get; set; } - public Cropping Clone() + /// + /// Gets or sets Bottom. + /// + public int Bottom { get; set; } + + /// + /// Gets or sets Left. + /// + public int Left { get; set; } + + /// + /// Gets or sets Right. + /// + public int Right { get; set; } + + /// + /// Clone this model + /// + /// + /// A Cloned copy + /// + public Cropping Clone() { return new Cropping { diff --git a/win/CS/HandBrakeWPF/Converters/AudioEnumConverter.cs b/win/CS/HandBrakeWPF/Converters/AudioEnumConverter.cs deleted file mode 100644 index b53637bca..000000000 --- a/win/CS/HandBrakeWPF/Converters/AudioEnumConverter.cs +++ /dev/null @@ -1,83 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. -// -// -// Defines the BooleanToVisibilityConverter type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace HandBrakeWPF.Converters -{ - using System.Collections.Generic; - using System.Globalization; - using System.Windows.Data; - using System; - - using HandBrake.ApplicationServices.Functions; - using HandBrake.Interop.Model.Encoding; - - /// - /// Boolean to Visibility Converter - /// - public sealed class AudioEnumConverter : IValueConverter - { - /// - /// Convert an Enum to it's display value (attribute) - /// - /// - /// The value. - /// - /// - /// The target type. - /// - /// - /// The parameter. (A boolean which inverts the output) - /// - /// - /// The culture. - /// - /// - /// Visibility property - /// - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - if (value is Mixdown) - { - return EnumHelper.GetEnumDisplayValues(value.GetType()); - } - else if (value is AudioEncoder) - { - return EnumHelper.GetEnumDisplayValues(value.GetType()); - } - - return new List(); - } - - /// - /// Convert Back for the IValueConverter Interface. Not used! - /// - /// - /// The value. - /// - /// - /// The target type. - /// - /// - /// The parameter. - /// - /// - /// The culture. - /// - /// - /// Nothing - /// - /// - /// This method is not used! - /// - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} diff --git a/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs b/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs new file mode 100644 index 000000000..b5ee371b6 --- /dev/null +++ b/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs @@ -0,0 +1,155 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the EnumComboConverter type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Converters +{ + using System.Collections.Generic; + using System.Globalization; + using System.Windows.Data; + using System; + + using HandBrake.ApplicationServices.Functions; + using HandBrake.Interop.Model.Encoding; + using HandBrake.Interop.Model.Encoding.x264; + + /// + /// Enum Combo Converter + /// + public sealed class EnumComboConverter : IValueConverter + { + /// + /// Convert an Enum to it's display value (attribute) + /// + /// + /// The value. + /// + /// + /// The target type. + /// + /// + /// The parameter. (A boolean which inverts the output) + /// + /// + /// The culture. + /// + /// + /// Visibility property + /// + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + // Lists + if (value is IEnumerable) + { + return EnumHelper.GetEnumDisplayValues(typeof(x264Preset)); + } + if (value is IEnumerable) + { + return EnumHelper.GetEnumDisplayValues(typeof(x264Profile)); + } + if (value is IEnumerable) + { + return EnumHelper.GetEnumDisplayValues(typeof(x264Tune)); + } + if (value is IEnumerable) + { + return EnumHelper.GetEnumDisplayValues(typeof(VideoEncoder)); + } + if (value is IEnumerable) + { + return EnumHelper.GetEnumDisplayValues(typeof(Mixdown)); + } + + if (value is IEnumerable) + { + return EnumHelper.GetEnumDisplayValues(typeof(AudioEncoder)); + } + + + + // Single Items + if (targetType == typeof(x264Preset) || value.GetType() == typeof(x264Preset)) + { + return EnumHelper.GetDisplay((x264Preset)value); + } + if (targetType == typeof(x264Profile) || value.GetType() == typeof(x264Profile)) + { + return EnumHelper.GetDisplay((x264Profile)value); + } + if (targetType == typeof(x264Tune) || value.GetType() == typeof(x264Tune)) + { + return EnumHelper.GetDisplay((x264Tune)value); + } + if (targetType == typeof(VideoEncoder) || value.GetType() == typeof(VideoEncoder)) + { + return EnumHelper.GetDisplay((VideoEncoder)value); + } + if (targetType == typeof(Mixdown) || value.GetType() == typeof(Mixdown)) + { + return EnumHelper.GetDisplay((Mixdown)value); + } + if (targetType == typeof(AudioEncoder) || value.GetType() == typeof(AudioEncoder)) + { + return EnumHelper.GetDisplay((AudioEncoder)value); + } + + return null; + } + + /// + /// Convert Back for the IValueConverter Interface. + /// + /// + /// The value. + /// + /// + /// The target type. + /// + /// + /// The parameter. + /// + /// + /// The culture. + /// + /// + /// Nothing + /// + /// + /// This method is not used! + /// + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + if (targetType == typeof(x264Preset) || value.GetType() == typeof(x264Preset)) + { + return EnumHelper.GetValue(value.ToString()); + } + if (targetType == typeof(x264Profile) || value.GetType() == typeof(x264Profile)) + { + return EnumHelper.GetValue(value.ToString()); + } + if (targetType == typeof(x264Tune) || value.GetType() == typeof(x264Tune)) + { + return EnumHelper.GetValue(value.ToString()); + } + if (targetType == typeof(VideoEncoder) || value.GetType() == typeof(VideoEncoder)) + { + return EnumHelper.GetValue(value.ToString()); + } + if (targetType == typeof(Mixdown) || value.GetType() == typeof(Mixdown)) + { + return EnumHelper.GetValue(value.ToString()); + } + if (targetType == typeof(AudioEncoder) || value.GetType() == typeof(AudioEncoder)) + { + return EnumHelper.GetValue(value.ToString()); + } + + return null; + } + } +} diff --git a/win/CS/HandBrakeWPF/Converters/FullPathToFileNameConverter.cs b/win/CS/HandBrakeWPF/Converters/FullPathToFileNameConverter.cs index b0f764ba8..fa659d232 100644 --- a/win/CS/HandBrakeWPF/Converters/FullPathToFileNameConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/FullPathToFileNameConverter.cs @@ -39,9 +39,10 @@ namespace HandBrakeWPF.Converters /// public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - if (!string.IsNullOrEmpty(value.ToString())) + string path = value as string; + if (!string.IsNullOrEmpty(path) && ! path.EndsWith("\\")) { - return Path.GetFileName(value.ToString()); + return Path.GetFileName(path); } return "Unknown"; diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index dbfd18f20..2b4a5f501 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -48,29 +48,24 @@ ..\libraries\caliburn\Castle.Windsor.dll - - ..\libraries\caliburn\Common.Logging.dll - ..\libraries\EagleBoost.Wpf.Presentation.dll + + ..\libraries\WPFDragDrop\GongSolutions.Wpf.DragDrop.dll + ..\libraries\OokiiDialogs\Ookii.Dialogs.Wpf.dll - - - ..\libraries\caliburn\System.Windows.Interactivity.dll - - 4.0 @@ -84,7 +79,7 @@ - + @@ -103,6 +98,7 @@ + diff --git a/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs index 60a82d94e..5428e6bb7 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs @@ -9,13 +9,16 @@ namespace HandBrakeWPF.ViewModels { + using System.Collections.Generic; using System.ComponentModel.Composition; using Caliburn.Micro; + using HandBrake.ApplicationServices.Functions; using HandBrake.ApplicationServices.Model; using HandBrake.ApplicationServices.Parsing; using HandBrake.ApplicationServices.Services.Interfaces; + using HandBrake.Interop.Model.Encoding; using HandBrake.Interop.Model.Encoding.x264; using HandBrakeWPF.ViewModels.Interfaces; @@ -48,6 +51,11 @@ namespace HandBrakeWPF.ViewModels /// private x264Tune x264Tune; + /// + /// Backing field used to display / hide the x264 options + /// + private bool displayX264Options; + #endregion #region Constructors and Destructors @@ -63,6 +71,13 @@ namespace HandBrakeWPF.ViewModels /// public AdvancedViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { + X264Presets = EnumHelper.GetEnumList(); + X264Profiles = EnumHelper.GetEnumList(); + X264Tunes = EnumHelper.GetEnumList(); + + this.x264Preset = x264Preset.None; + this.x264Profile = x264Profile.None; + this.x264Tune = x264Tune.None; } #endregion @@ -133,6 +148,37 @@ namespace HandBrakeWPF.ViewModels } } + /// + /// Gets or sets X264Presets. + /// + public IEnumerable X264Presets { get; set; } + + /// + /// Gets or sets X264Profiles. + /// + public IEnumerable X264Profiles { get; set; } + + /// + /// Gets or sets X264Tunes. + /// + public IEnumerable X264Tunes { get; set; } + + /// + /// Gets or sets a value indicating whether DisplayX264Options. + /// + public bool DisplayX264Options + { + get + { + return this.displayX264Options; + } + set + { + this.displayX264Options = value; + this.NotifyOfPropertyChange(() => this.DisplayX264Options); + } + } + #endregion #region Public Methods @@ -157,6 +203,46 @@ namespace HandBrakeWPF.ViewModels this.X264Tune = preset.Task.X264Tune; } + /// + /// Setup this tab for the specified preset. + /// + /// + /// The preset. + /// + public void SetPreset(Preset preset) + { + if (preset != null && preset.Task != null) + { + this.Query = preset.Task.AdvancedEncoderOptions; + this.SetEncoder(preset.Task.VideoEncoder); + + this.X264Preset = preset.Task.x264Preset; + this.X264Profile = preset.Task.x264Profile; + this.X264Tune = preset.Task.X264Tune; + } + } + + /// + /// Set the currently selected encoder. + /// + /// + /// The Video Encoder. + /// + public void SetEncoder(VideoEncoder encoder) + { + if (encoder == VideoEncoder.X264) + { + this.DisplayX264Options = true; + } + else + { + this.x264Preset = x264Preset.None; + this.x264Profile = x264Profile.None; + this.x264Tune = x264Tune.None; + this.DisplayX264Options = false; + } + } + #endregion } } \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs index b27c14583..63c333db2 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs @@ -122,6 +122,46 @@ namespace HandBrakeWPF.ViewModels this.SourceTracks = title.AudioTracks; } + /// + /// Setup this tab for the specified preset. + /// + /// + /// The preset. + /// + public void SetPreset(Preset preset) + { + if (preset != null && preset.Task != null) + { + // Store the previously selected tracks + List