diff options
Diffstat (limited to 'win/CS')
8 files changed, 214 insertions, 17 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs index 2117565e5..8d34d230b 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs @@ -66,7 +66,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model this.AudioTracks = new ObservableCollection<AudioTrack>();
foreach (AudioTrack track in task.AudioTracks)
{
- this.AudioTracks.Add(new AudioTrack(track));
+ this.AudioTracks.Add(new AudioTrack(track, true));
}
this.ChapterNames = new ObservableCollection<ChapterMarker>();
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioTrack.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioTrack.cs index f2a454729..4a020365d 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioTrack.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioTrack.cs @@ -94,7 +94,10 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models /// <param name="track">
/// The track.
/// </param>
- public AudioTrack(AudioTrack track)
+ /// <param name="setScannedTrack">
+ /// The set Scanned Track.
+ /// </param>
+ public AudioTrack(AudioTrack track, bool setScannedTrack)
{
this.bitrate = track.Bitrate;
this.drc = track.DRC;
@@ -102,7 +105,10 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models this.gain = track.Gain;
this.mixDown = track.MixDown;
this.sampleRate = track.SampleRate;
- this.scannedTrack = track.ScannedTrack ?? new Audio();
+ if (setScannedTrack)
+ {
+ this.scannedTrack = track.ScannedTrack ?? new Audio();
+ }
this.TrackName = track.TrackName;
}
diff --git a/win/CS/HandBrakeWPF/Converters/Audio/AudioTrackDefaultBehaviourConverter.cs b/win/CS/HandBrakeWPF/Converters/Audio/AudioTrackDefaultBehaviourConverter.cs new file mode 100644 index 000000000..2c779bbce --- /dev/null +++ b/win/CS/HandBrakeWPF/Converters/Audio/AudioTrackDefaultBehaviourConverter.cs @@ -0,0 +1,91 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="AudioTrackDefaultBehaviourConverter.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>
+// Audio Track Default Behaviour Converter
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Converters.Audio
+{
+ using System;
+ using System.ComponentModel;
+ using System.Globalization;
+ using System.Linq;
+ using System.Windows.Data;
+
+ using HandBrake.ApplicationServices.Utilities;
+
+ using HandBrakeWPF.Model.Audio;
+
+ /// <summary>
+ /// Audio Behaviour Converter
+ /// </summary>
+ public class AudioTrackDefaultBehaviourConverter : IValueConverter
+ {
+ /// <summary>
+ /// The convert.
+ /// </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>
+ /// The <see cref="object"/>.
+ /// </returns>
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value != null && value.GetType() == typeof(BindingList<AudioTrackDefaultsMode>))
+ {
+ return
+ new BindingList<string>(
+ EnumHelper<AudioTrackDefaultsMode>.GetEnumDisplayValues(typeof(AudioTrackDefaultsMode)).ToList());
+ }
+
+ if (value != null && value.GetType() == typeof(AudioTrackDefaultsMode))
+ {
+ return EnumHelper<AudioTrackDefaultsMode>.GetDisplay((AudioTrackDefaultsMode)value);
+ }
+
+ return null;
+ }
+
+ /// <summary>
+ /// The convert back.
+ /// </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>
+ /// The <see cref="object"/>.
+ /// </returns>
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ string name = value as string;
+ if (!string.IsNullOrEmpty(name))
+ {
+ return EnumHelper<AudioTrackDefaultsMode>.GetValue(name);
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 7758c7327..7ffb9bc05 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -140,6 +140,7 @@ <Compile Include="Controls\AlertPanel.xaml.cs">
<DependentUpon>AlertPanel.xaml</DependentUpon>
</Compile>
+ <Compile Include="Converters\Audio\AudioTrackDefaultBehaviourConverter.cs" />
<Compile Include="Converters\Audio\AudioBehaviourConverter.cs" />
<Compile Include="Converters\Filters\DenoisePresetConverter.cs" />
<Compile Include="Converters\Subtitles\SubtitleBurnInBehaviourConverter.cs" />
@@ -150,6 +151,7 @@ <Compile Include="EventArgs\QueueProgressEventArgs.cs" />
<Compile Include="EventArgs\SettingChangedEventArgs.cs" />
<Compile Include="Extensions\StringExtensions.cs" />
+ <Compile Include="Model\Audio\AudioTrackDefaultsMode.cs" />
<Compile Include="Model\Audio\AudioBehaviourModes.cs" />
<Compile Include="Model\Audio\AudioBehaviours.cs" />
<Compile Include="Model\DriveInformation.cs" />
diff --git a/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviours.cs b/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviours.cs index 6ffd45db1..8e12460b2 100644 --- a/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviours.cs +++ b/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviours.cs @@ -11,6 +11,7 @@ namespace HandBrakeWPF.Model.Audio {
using System.ComponentModel;
using System.Linq;
+ using System.Windows.Media.Animation;
using Caliburn.Micro;
@@ -29,12 +30,15 @@ namespace HandBrakeWPF.Model.Audio /// </summary>
private BindingList<string> selectedLangauges;
+ private AudioTrackDefaultsMode trackDefaultBehaviour;
+
/// <summary>
/// Initializes a new instance of the <see cref="AudioBehaviours"/> class.
/// </summary>
public AudioBehaviours()
{
this.SelectedBehaviour = AudioBehaviourModes.None;
+ this.SelectedTrackDefaultBehaviour = AudioTrackDefaultsMode.FirstTrack;
this.SelectedLangauges = new BindingList<string>();
}
@@ -47,6 +51,7 @@ namespace HandBrakeWPF.Model.Audio public AudioBehaviours(AudioBehaviours behaviours)
{
this.SelectedBehaviour = behaviours.SelectedBehaviour;
+ this.SelectedTrackDefaultBehaviour = behaviours.SelectedTrackDefaultBehaviour;
this.SelectedLangauges = new BindingList<string>(behaviours.selectedLangauges.ToList());
}
@@ -72,6 +77,26 @@ namespace HandBrakeWPF.Model.Audio }
/// <summary>
+ /// Gets or sets the track default behaviour.
+ /// </summary>
+ public AudioTrackDefaultsMode SelectedTrackDefaultBehaviour
+ {
+ get
+ {
+ return this.trackDefaultBehaviour;
+ }
+ set
+ {
+ if (value == this.trackDefaultBehaviour)
+ {
+ return;
+ }
+ this.trackDefaultBehaviour = value;
+ this.NotifyOfPropertyChange(() => this.SelectedTrackDefaultBehaviour);
+ }
+ }
+
+ /// <summary>
/// Gets or sets the selected langauges.
/// </summary>
public BindingList<string> SelectedLangauges
@@ -102,7 +127,8 @@ namespace HandBrakeWPF.Model.Audio AudioBehaviours cloned = new AudioBehaviours
{
SelectedBehaviour = this.selectedBehaviour,
- SelectedLangauges = new BindingList<string>()
+ SelectedLangauges = new BindingList<string>(),
+ SelectedTrackDefaultBehaviour = this.SelectedTrackDefaultBehaviour
};
foreach (var item in this.SelectedLangauges)
diff --git a/win/CS/HandBrakeWPF/Model/Audio/AudioTrackDefaultsMode.cs b/win/CS/HandBrakeWPF/Model/Audio/AudioTrackDefaultsMode.cs new file mode 100644 index 000000000..42f8770cf --- /dev/null +++ b/win/CS/HandBrakeWPF/Model/Audio/AudioTrackDefaultsMode.cs @@ -0,0 +1,28 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="AudioTrackDefaultsMode.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 audio track defaults mode.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Model.Audio
+{
+ using System.ComponentModel.DataAnnotations;
+
+ /// <summary>
+ /// The audio behaviours.
+ /// </summary>
+ public enum AudioTrackDefaultsMode
+ {
+ [Display(Name = "Default")]
+ None = 0,
+
+ [Display(Name = "Use First Track as template")]
+ FirstTrack,
+
+ [Display(Name = "Use All Tracks as templates")]
+ AllTracks,
+ }
+}
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs index f568a5ddf..3424b4c09 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs @@ -119,6 +119,17 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
+ /// Gets the audio track default behaviour mode list.
+ /// </summary>
+ public BindingList<AudioTrackDefaultsMode> AudioTrackDefaultBehaviourModeList
+ {
+ get
+ {
+ return new BindingList<AudioTrackDefaultsMode>(EnumHelper<AudioTrackDefaultsMode>.GetEnumList().ToList());
+ }
+ }
+
+ /// <summary>
/// Gets or sets AudioBitrates.
/// </summary>
public IEnumerable<int> AudioBitrates { get; set; }
@@ -240,7 +251,7 @@ namespace HandBrakeWPF.ViewModels public void Add()
{
// Add the first track if available.
- this.Add(null);
+ this.Add(null, false);
}
/// <summary>
@@ -455,14 +466,39 @@ namespace HandBrakeWPF.ViewModels /// <param name="sourceTrack">
/// The source track.
/// </param>
- private void Add(Audio sourceTrack)
+ /// <param name="useBehaviourTemplateMode">
+ /// The use Behaviour Template Mode.
+ /// </param>
+ private void Add(Audio sourceTrack, bool useBehaviourTemplateMode)
{
if (this.SourceTracks != null)
{
Audio track = sourceTrack ?? this.GetPreferredAudioTrack();
if (track != null)
{
- this.Task.AudioTracks.Add(new AudioTrack { ScannedTrack = track });
+ if (!useBehaviourTemplateMode)
+ {
+ this.Task.AudioTracks.Add(new AudioTrack { ScannedTrack = track });
+ return;
+ }
+
+ switch (this.AudioBehaviours.SelectedTrackDefaultBehaviour)
+ {
+ case AudioTrackDefaultsMode.None:
+ this.Task.AudioTracks.Add(new AudioTrack { ScannedTrack = track });
+ break;
+ case AudioTrackDefaultsMode.FirstTrack:
+ AudioTrack template = this.currentPreset.Task.AudioTracks.FirstOrDefault();
+ this.Task.AudioTracks.Add(template != null ? new AudioTrack(template, false) { ScannedTrack = track } : new AudioTrack { ScannedTrack = track });
+ break;
+ case AudioTrackDefaultsMode.AllTracks:
+ foreach (AudioTrack tmpl in this.currentPreset.Task.AudioTracks)
+ {
+ this.Task.AudioTracks.Add(tmpl != null ? new AudioTrack(tmpl, false) { ScannedTrack = track } : new AudioTrack { ScannedTrack = track });
+ }
+
+ break;
+ }
}
}
}
@@ -480,7 +516,7 @@ namespace HandBrakeWPF.ViewModels if (!found)
{
// If it doesn't, add it.
- this.Add(sourceTrack);
+ this.Add(sourceTrack, true);
}
}
}
@@ -510,7 +546,7 @@ namespace HandBrakeWPF.ViewModels // Step 3, Setup the tracks from the preset
foreach (AudioTrack track in this.currentPreset.Task.AudioTracks)
{
- this.Task.AudioTracks.Add(new AudioTrack(track) { ScannedTrack = this.GetPreferredAudioTrack() });
+ this.Task.AudioTracks.Add(new AudioTrack(track, false) { ScannedTrack = this.GetPreferredAudioTrack() });
}
// Step 4, Handle the default selection behaviour.
@@ -552,7 +588,7 @@ namespace HandBrakeWPF.ViewModels }
// If it doesn't, add it.
- this.Add(sourceTrack);
+ this.Add(sourceTrack, true);
}
}
}
@@ -570,7 +606,7 @@ namespace HandBrakeWPF.ViewModels if (!found)
{
// If it doesn't, add it.
- this.Add(sourceTrack);
+ this.Add(sourceTrack, true);
}
}
}
@@ -648,6 +684,7 @@ namespace HandBrakeWPF.ViewModels if (preset != null && preset.AudioTrackBehaviours != null)
{
this.AudioBehaviours.SelectedBehaviour = preset.AudioTrackBehaviours.SelectedBehaviour;
+ this.AudioBehaviours.SelectedTrackDefaultBehaviour = preset.AudioTrackBehaviours.SelectedTrackDefaultBehaviour;
foreach (string selectedItem in preset.AudioTrackBehaviours.SelectedLangauges)
{
diff --git a/win/CS/HandBrakeWPF/Views/AudioView.xaml b/win/CS/HandBrakeWPF/Views/AudioView.xaml index b2aa68f5e..1901069a8 100644 --- a/win/CS/HandBrakeWPF/Views/AudioView.xaml +++ b/win/CS/HandBrakeWPF/Views/AudioView.xaml @@ -11,7 +11,7 @@ xmlns:splitButton="clr-namespace:HandBrakeWPF.Controls.SplitButton"
xmlns:controls="clr-namespace:HandBrakeWPF.Controls"
xmlns:helpers="clr-namespace:HandBrakeWPF.Helpers"
- d:DesignHeight="400"
+ d:DesignHeight="800"
d:DesignWidth="750"
mc:Ignorable="d"
x:Name="audioTab">
@@ -23,12 +23,14 @@ <Audio:AudioBitrateConverter x:Key="audioBitrateConverter" />
<Audio:AudioEncoderConverter x:Key="audioEncoderConverter" />
<Audio:AudioBehaviourConverter x:Key="audioBehaviourConverter" />
+ <Audio:AudioTrackDefaultBehaviourConverter x:Key="audioTrackDefaultBehaviourConverter" />
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
@@ -54,7 +56,7 @@ <!-- Row 1 -->
- <Grid Grid.Row="1" Margin="10,5,10,0" Grid.Column="0"
+ <Grid Grid.Row="1" Margin="10,5,10,0" Grid.Column="0"
Visibility="{Binding ShowAudioDefaultsPanel, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
@@ -69,7 +71,6 @@ <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
-
<splitButton:SplitMenuButton Content="Add Track" cal:Message.Attach="[Event Click] = [Action Add]" FontWeight="Bold" Margin="0,0,10,0" Grid.Column="0">
<splitButton:SplitMenuButton.ItemSource>
<MenuItem Header="Add New Track" cal:Message.Attach="[Event Click] = [Action Add]" />
@@ -98,7 +99,7 @@ <!-- Row 2 -->
- <ListBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"
+ <ListBox Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Stretch" Grid.RowSpan="1"
Visibility="{Binding ShowAudioDefaultsPanel, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}"
Margin="10,10,10,10"
dd:DragDrop.DropHandler="{Binding}"
@@ -273,7 +274,7 @@ </ListBox>
<StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="10,0,10,0"
- Visibility="{Binding ShowAudioDefaultsPanel, Converter={StaticResource boolToVisConverter}, ConverterParameter=false, FallbackValue=Collapsed}">
+ Visibility="{Binding ShowAudioDefaultsPanel, Converter={StaticResource boolToVisConverter}, ConverterParameter=false, FallbackValue=Visible}">
<Grid Margin="5,0,0,0" >
<Grid.RowDefinitions>
@@ -295,6 +296,12 @@ <ComboBox Name="autoAudioMode" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left"
ItemsSource="{Binding AudioBehaviourModeList, Converter={StaticResource audioBehaviourConverter}}"
SelectedItem="{Binding AudioBehaviours.SelectedBehaviour, Converter={StaticResource audioBehaviourConverter}}" Width="210" Margin="0,0,5,0" />
+
+
+ <TextBlock Text="Track Setting Default Behaviour:" Grid.Column="0" Grid.Row="1" Margin="0,5,5,0" HorizontalAlignment="Left" VerticalAlignment="Center" />
+ <ComboBox Name="audioTrackBeahaviorMode" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Left"
+ ItemsSource="{Binding AudioTrackDefaultBehaviourModeList, Converter={StaticResource audioTrackDefaultBehaviourConverter}}"
+ SelectedItem="{Binding AudioBehaviours.SelectedTrackDefaultBehaviour, Converter={StaticResource audioTrackDefaultBehaviourConverter}}" Width="210" Margin="0,5,5,0" />
</Grid>
<TextBlock Text="Choose Languages:" Margin="5,10,0,0" />
@@ -375,7 +382,7 @@ <TextBlock Margin="15,0,5,0" Text="Otherwise use fallback encoder:" />
- <ComboBox VerticalAlignment="Center" Width="100" Height="22" Margin="10,0,5,0">
+ <ComboBox VerticalAlignment="Center" Width="105" Height="22" Margin="10,0,5,0">
<ComboBox.SelectedItem>
<MultiBinding Converter="{StaticResource audioEncoderConverter}">
<Binding Path="Task.AllowedPassthruOptions.AudioEncoderFallback" />
|