diff options
Diffstat (limited to 'win/CS')
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs | 17 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Converters/BooleanToHiddenVisibilityConverter.cs | 91 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 1 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs | 75 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/AudioView.xaml | 35 | ||||
-rw-r--r-- | win/CS/libraries/EagleBoost.Wpf.Presentation.dll | bin | 24064 -> 22528 bytes | |||
-rw-r--r-- | win/CS/libraries/EagleBoost.Wpf.Presentation.pdb | bin | 0 -> 54784 bytes |
7 files changed, 177 insertions, 42 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs index d7e3941bb..3fcf7cb5a 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs @@ -197,6 +197,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding {
this.encoder = value;
this.OnPropertyChanged("Encoder");
+ this.OnPropertyChanged("IsPassthru");
}
}
@@ -341,6 +342,22 @@ namespace HandBrake.ApplicationServices.Model.Encoding }
}
+ /// <summary>
+ /// Gets a value indicating whether IsPassthru.
+ /// </summary>
+ public bool IsPassthru
+ {
+ get
+ {
+ if (this.Encoder == AudioEncoder.Ac3Passthrough || this.Encoder == AudioEncoder.DtsPassthrough
+ || this.Encoder == AudioEncoder.DtsHDPassthrough || this.Encoder == AudioEncoder.AacPassthru
+ || this.Encoder == AudioEncoder.Mp3Passthru || this.Encoder == AudioEncoder.Passthrough)
+ {
+ return true;
+ }
+ return false;
+ }
+ }
#endregion
}
}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Converters/BooleanToHiddenVisibilityConverter.cs b/win/CS/HandBrakeWPF/Converters/BooleanToHiddenVisibilityConverter.cs new file mode 100644 index 000000000..c6a66e1f6 --- /dev/null +++ b/win/CS/HandBrakeWPF/Converters/BooleanToHiddenVisibilityConverter.cs @@ -0,0 +1,91 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="BooleanToHiddenVisibilityConverter.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>
+// Defines the BooleanToHiddenVisibilityConverter type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Converters
+{
+ using System.Globalization;
+ using System.Windows;
+ using System.Windows.Data;
+ using System;
+
+ /// <summary>
+ /// Boolean to Visibility Converter (Hidden, not Collasped)
+ /// </summary>
+ public sealed class BooleanToHiddenVisibilityConverter : IValueConverter
+ {
+ /// <summary>
+ /// Convert a boolean to visibility property.
+ /// </summary>
+ /// <param name="value">
+ /// The value.
+ /// </param>
+ /// <param name="targetType">
+ /// The target type.
+ /// </param>
+ /// <param name="parameter">
+ /// The parameter. (A boolean which inverts the output)
+ /// </param>
+ /// <param name="culture">
+ /// The culture.
+ /// </param>
+ /// <returns>
+ /// Visibility property
+ /// </returns>
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ // Paramater is a boolean which inverts the output.
+ var param = System.Convert.ToBoolean(parameter, CultureInfo.InvariantCulture);
+
+ if (value == null)
+ {
+ return Visibility.Hidden;
+ }
+
+ if (value is Boolean)
+ {
+ if (param)
+ {
+ return (bool)value ? Visibility.Hidden : Visibility.Visible;
+ }
+ else
+ {
+ return (bool)value ? Visibility.Visible : Visibility.Hidden;
+ }
+ }
+
+ return value;
+ }
+
+ /// <summary>
+ /// Convert Back for the IValueConverter Interface. Not used!
+ /// </summary>
+ /// <param name="value">
+ /// The value.
+ /// </param>
+ /// <param name="targetType">
+ /// The target type.
+ /// </param>
+ /// <param name="parameter">
+ /// The parameter.
+ /// </param>
+ /// <param name="culture">
+ /// The culture.
+ /// </param>
+ /// <returns>
+ /// Nothing
+ /// </returns>
+ /// <exception cref="NotImplementedException">
+ /// This method is not used!
+ /// </exception>
+ 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 a27c42d96..77665c7f8 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -110,6 +110,7 @@ <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
+ <Compile Include="Converters\BooleanToHiddenVisibilityConverter.cs" />
<Compile Include="ViewModels\Interfaces\ITitleSpecificViewModel.cs" />
<Compile Include="ViewModels\TitleSpecificViewModel.cs" />
<Compile Include="Views\TitleSpecificView.xaml.cs">
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs index c26dd0c73..1936a9898 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs @@ -32,6 +32,11 @@ namespace HandBrakeWPF.ViewModels [Export(typeof(IAudioViewModel))]
public class AudioViewModel : ViewModelBase, IAudioViewModel
{
+ /// <summary>
+ /// Backing field for the source tracks list.
+ /// </summary>
+ private IEnumerable<Audio> sourceTracks;
+
#region Constructors and Destructors
/// <summary>
@@ -80,7 +85,18 @@ namespace HandBrakeWPF.ViewModels /// <summary>
/// Gets or sets SourceTracks.
/// </summary>
- public IEnumerable<Audio> SourceTracks { get; set; }
+ public IEnumerable<Audio> SourceTracks
+ {
+ get
+ {
+ return this.sourceTracks;
+ }
+ set
+ {
+ this.sourceTracks = value;
+ this.NotifyOfPropertyChange(() => this.SourceTracks);
+ }
+ }
/// <summary>
/// Gets or sets the EncodeTask.
@@ -168,8 +184,24 @@ namespace HandBrakeWPF.ViewModels {
this.SourceTracks = title.AudioTracks;
- this.SetPreset(preset, task);
- this.AutomaticTrackSelection();
+ // Only reset the audio tracks if we have none, or if the task is null.
+ if (this.Task == null || this.Task.AudioTracks.Count == 0)
+ {
+ this.SetPreset(preset, task);
+ }
+
+ // If there are no source tracks, clear the list, otherwise try to Auto-Select the correct tracks
+ if (this.SourceTracks == null || !this.SourceTracks.Any())
+ {
+ this.Task.AudioTracks.Clear();
+ }
+ else
+ {
+ this.AutomaticTrackSelection();
+ }
+
+ // Force UI Updates
+ this.NotifyOfPropertyChange(() => this.Task);
}
#endregion
@@ -223,36 +255,18 @@ namespace HandBrakeWPF.ViewModels this.Task.AudioTracks.Clear();
// Get the preferred Language
- IEnumerable<Audio> languages =
+ IEnumerable<Audio> preferredAudioTracks =
this.SourceTracks.Where(
item =>
item.Language.Contains(
this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguage)));
- Audio preferred = languages.FirstOrDefault() ?? this.SourceTracks.FirstOrDefault();
-
- // Get the currently selected langauges
- List<Audio> selectedTracks = this.Task.AudioTracks.Select(track => track.ScannedTrack).ToList();
+ Audio preferred = preferredAudioTracks.FirstOrDefault() ?? this.SourceTracks.FirstOrDefault();
// Add the preset audio tracks with the preferred language
foreach (AudioTrack track in preset.Task.AudioTracks)
{
this.Task.AudioTracks.Add(new AudioTrack(track) { ScannedTrack = preferred });
}
-
- // Attempt to restore the previously selected tracks.
- // or fallback to the first source track.
- foreach (AudioTrack track in this.Task.AudioTracks)
- {
- if (selectedTracks.Count != 0)
- {
- track.ScannedTrack = selectedTracks[0];
- selectedTracks.RemoveAt(0);
- }
- else
- {
- break;
- }
- }
}
/// <summary>
@@ -266,7 +280,7 @@ namespace HandBrakeWPF.ViewModels return;
}
- // Step 1: Preferred Language
+ // Step 1: Fetch all the Preferred Language settings
if (this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguage) == "Any")
{
// If we have Any as the preferred Language, just set the first track to all audio tracks.
@@ -285,18 +299,19 @@ namespace HandBrakeWPF.ViewModels trackList.Add(item);
break;
}
-
- foreach (AudioTrack track in this.Task.AudioTracks)
- {
- track.ScannedTrack = trackList.FirstOrDefault() ?? this.SourceTracks.FirstOrDefault();
- }
}
- // Step 2: Handle "All Remaining Tracks" and "All for Selected Languages"
+ // Step 2: Handle "All Remaining Tracks" and "All for Selected Languages" or use the default behaviour
int mode = this.UserSettingService.GetUserSetting<int>(UserSettingConstants.DubModeAudio);
switch (mode)
{
+ default: // Default by setting all existing tracks to a preferred or first source track.
+ foreach (AudioTrack track in this.Task.AudioTracks)
+ {
+ track.ScannedTrack = trackList.FirstOrDefault() ?? this.SourceTracks.FirstOrDefault();
+ }
+ break;
case 1: // Adding all remaining audio tracks
this.AddAllRemaining();
break;
diff --git a/win/CS/HandBrakeWPF/Views/AudioView.xaml b/win/CS/HandBrakeWPF/Views/AudioView.xaml index 450d463e5..c8d3ba88e 100644 --- a/win/CS/HandBrakeWPF/Views/AudioView.xaml +++ b/win/CS/HandBrakeWPF/Views/AudioView.xaml @@ -12,6 +12,7 @@ <UserControl.Resources>
<Conveters:EnumComboConverter x:Key="enumComboConverter" />
<Conveters:BooleanToVisibilityConverter x:Key="boolToVisConverter" />
+ <Conveters:BooleanToHiddenVisibilityConverter x:Key="boolToHiddenVisConverter" />
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
@@ -103,29 +104,39 @@ ItemsSource="{Binding DataContext.AudioEncoders, Converter={StaticResource enumComboConverter}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
SelectedItem="{Binding Encoder, Converter={StaticResource enumComboConverter}}"/>
- <TextBlock Text="Bitrate" FontWeight="Bold" Grid.Column="4" VerticalAlignment="Center" />
+ <TextBlock Text="Bitrate" FontWeight="Bold" Grid.Column="4" VerticalAlignment="Center"
+ Visibility="{Binding IsPassthru, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
<ComboBox Width="70" Grid.Column="5" Margin="5,0,5,0" Height="22"
ItemsSource="{Binding DataContext.AudioBitrates, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
- SelectedItem="{Binding Bitrate}"/>
+ SelectedItem="{Binding Bitrate}" IsEnabled="{Binding}"
+ Visibility="{Binding IsPassthru, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
- <TextBlock Text="Samplerate" FontWeight="Bold" Grid.Column="6" VerticalAlignment="Center" />
+ <TextBlock Text="Samplerate" FontWeight="Bold" Grid.Column="6" VerticalAlignment="Center"
+ Visibility="{Binding IsPassthru, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
<ComboBox Width="70" Grid.Column="7" Margin="5,0,5,0" Height="22"
ItemsSource="{Binding DataContext.SampleRates, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
- SelectedItem="{Binding SampleRateDisplayValue}"/>
+ SelectedItem="{Binding SampleRateDisplayValue}"
+ Visibility="{Binding IsPassthru, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
<!-- Row 2-->
- <TextBlock Text="Mixdown" FontWeight="Bold" Grid.Column="0" Grid.Row="1" VerticalAlignment="Center"/>
+ <TextBlock Text="Mixdown" FontWeight="Bold" Grid.Column="0" Grid.Row="1" VerticalAlignment="Center"
+ Visibility="{Binding IsPassthru, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
<ComboBox Width="100" Grid.Column="1" Margin="5,0,5,0" Grid.Row="1" Height="22"
ItemsSource="{Binding DataContext.AudioMixdowns, Converter={StaticResource enumComboConverter}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
- SelectedItem="{Binding MixDown, Converter={StaticResource enumComboConverter}}"/>
+ SelectedItem="{Binding MixDown, Converter={StaticResource enumComboConverter}}"
+ Visibility="{Binding IsPassthru, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
- <TextBlock Text="DRC" FontWeight="Bold" Grid.Column="2" Grid.Row="1" VerticalAlignment="Center"/>
- <NumericUpDown:NumericUpDown Width="45" Value="{Binding DRC, Mode=TwoWay}" Grid.Row="1" Grid.Column="3" HorizontalAlignment="Left" Margin="5,0,5,0"
- Minimum="0" Maximum="4" DecimalPlace="1" LargeChange="0.1" SmallChange="0.1"/>
+ <TextBlock Text="DRC" FontWeight="Bold" Grid.Column="2" Grid.Row="1" VerticalAlignment="Center"
+ Visibility="{Binding IsPassthru, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
+ <NumericUpDown:NumericUpDown Name="drcNumericCtl" Width="45" Value="{Binding DRC, Mode=TwoWay}" Grid.Row="1" Grid.Column="3" HorizontalAlignment="Left" Margin="5,0,5,0"
+ Minimum="0" Maximum="4" DecimalPlace="1" LargeChange="0.1" SmallChange="0.1"
+ Visibility="{Binding IsPassthru, Converter={StaticResource boolToHiddenVisConverter}, ConverterParameter=true}" />
- <TextBlock Text="Gain" FontWeight="Bold" Grid.Column="4" Grid.Row="1" VerticalAlignment="Center"/>
- <NumericUpDown:NumericUpDown Width="45" Value="{Binding Gain, Mode=TwoWay}" Grid.Row="1" Grid.Column="5" HorizontalAlignment="Left" Margin="5,0,5,0"
- Minimum="-20" Maximum="20" DecimalPlace="0" SmallChange="1" LargeChange="1" />
+ <TextBlock Text="Gain" FontWeight="Bold" Grid.Column="4" Grid.Row="1" VerticalAlignment="Center"
+ Visibility="{Binding IsPassthru, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
+ <NumericUpDown:NumericUpDown Name="gainNumericCtl" Width="45" Value="{Binding Gain, Mode=TwoWay}" Grid.Row="1" Grid.Column="5" HorizontalAlignment="Left" Margin="5,0,5,0"
+ Minimum="-20" Maximum="20" DecimalPlace="0" SmallChange="1" LargeChange="1"
+ Visibility="{Binding IsPassthru, Converter={StaticResource boolToHiddenVisConverter}, ConverterParameter=true}"/>
</Grid>
diff --git a/win/CS/libraries/EagleBoost.Wpf.Presentation.dll b/win/CS/libraries/EagleBoost.Wpf.Presentation.dll Binary files differindex 760cbbda4..e52ba3ed7 100644 --- a/win/CS/libraries/EagleBoost.Wpf.Presentation.dll +++ b/win/CS/libraries/EagleBoost.Wpf.Presentation.dll diff --git a/win/CS/libraries/EagleBoost.Wpf.Presentation.pdb b/win/CS/libraries/EagleBoost.Wpf.Presentation.pdb Binary files differnew file mode 100644 index 000000000..ba5c655a3 --- /dev/null +++ b/win/CS/libraries/EagleBoost.Wpf.Presentation.pdb |