From dab8b3b4cfbe05f84bb89fb76252c68c41d3a06f Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 22 Jan 2012 20:45:08 +0000 Subject: WinGui: (WPF) Further work on the Audio and Subtitle tabs along with the API & Utilities. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4418 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../HandBrakeWPF/Converters/AudioEnumConverter.cs | 83 ++++++++++++ win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 1 + .../HandBrakeWPF/ViewModels/AdvancedViewModel.cs | 11 +- win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs | 77 ++++++++++- .../HandBrakeWPF/ViewModels/ChaptersViewModel.cs | 21 +-- win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs | 13 +- .../ViewModels/Interfaces/IAdvancedViewModel.cs | 9 +- .../ViewModels/Interfaces/IAudioViewModel.cs | 11 +- .../ViewModels/Interfaces/IChaptersViewModel.cs | 9 +- .../ViewModels/Interfaces/IFiltersViewModel.cs | 9 +- .../Interfaces/IPictureSettingsViewModel.cs | 8 +- .../ViewModels/Interfaces/ISubtitlesViewModel.cs | 9 +- .../ViewModels/Interfaces/IVideoViewModel.cs | 9 +- win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 42 +++--- .../ViewModels/PictureSettingsViewModel.cs | 17 ++- .../HandBrakeWPF/ViewModels/SubtitlesViewModel.cs | 144 ++++++++++++++++++--- win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs | 11 +- win/CS/HandBrakeWPF/Views/AudioView.xaml | 27 ++-- win/CS/HandBrakeWPF/Views/SubtitlesView.xaml | 20 +-- 19 files changed, 436 insertions(+), 95 deletions(-) create mode 100644 win/CS/HandBrakeWPF/Converters/AudioEnumConverter.cs (limited to 'win/CS/HandBrakeWPF') diff --git a/win/CS/HandBrakeWPF/Converters/AudioEnumConverter.cs b/win/CS/HandBrakeWPF/Converters/AudioEnumConverter.cs new file mode 100644 index 000000000..b53637bca --- /dev/null +++ b/win/CS/HandBrakeWPF/Converters/AudioEnumConverter.cs @@ -0,0 +1,83 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// 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/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 86bb02532..06abbad46 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -83,6 +83,7 @@ + diff --git a/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs index a11f2a8e8..60a82d94e 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs @@ -14,6 +14,7 @@ namespace HandBrakeWPF.ViewModels using Caliburn.Micro; using HandBrake.ApplicationServices.Model; + using HandBrake.ApplicationServices.Parsing; using HandBrake.ApplicationServices.Services.Interfaces; using HandBrake.Interop.Model.Encoding.x264; @@ -137,12 +138,18 @@ namespace HandBrakeWPF.ViewModels #region Public Methods /// - /// Set the selected preset + /// Setup this window for a new source /// + /// + /// The title. + /// /// /// The preset. /// - public void SetPreset(Preset preset) + /// + /// The task. + /// + public void SetSource(Title title, Preset preset, EncodeTask task) { this.Query = preset.Task.AdvancedEncoderOptions; this.X264Preset = preset.Task.x264Preset; diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs index e20e3ae95..b27c14583 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs @@ -9,14 +9,19 @@ namespace HandBrakeWPF.ViewModels { + using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel.Composition; + using System.Linq; using Caliburn.Micro; + using HandBrake.ApplicationServices.Functions; using HandBrake.ApplicationServices.Model; using HandBrake.ApplicationServices.Model.Encoding; + using HandBrake.ApplicationServices.Parsing; using HandBrake.ApplicationServices.Services.Interfaces; + using HandBrake.Interop.Model.Encoding; using HandBrakeWPF.ViewModels.Interfaces; @@ -38,6 +43,10 @@ namespace HandBrakeWPF.ViewModels public AudioViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { this.AudioTracks = new ObservableCollection(); + this.SampleRates = new ObservableCollection { "Auto", "48", "44.1", "32", "24", "22.05" }; + this.AudioBitrates = this.GetAppropiateBitrates(AudioEncoder.ffaac, Mixdown.DolbyProLogicII); + this.AudioEncoders = EnumHelper.GetEnumList(); + this.AudioMixdowns = EnumHelper.GetEnumList(); } /// @@ -45,29 +54,89 @@ namespace HandBrakeWPF.ViewModels /// public ObservableCollection AudioTracks { get; set; } + /// + /// Gets or sets SourceTracks. + /// + public IEnumerable