summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs93
1 files changed, 51 insertions, 42 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
index 446fab6cf..3fcca18aa 100644
--- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
@@ -22,6 +22,8 @@ namespace HandBrakeWPF.ViewModels
using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.ApplicationServices.Utilities;
+ using HandBrakeWPF.Commands;
+ using HandBrakeWPF.Model;
using HandBrakeWPF.ViewModels.Interfaces;
using Ookii.Dialogs.Wpf;
@@ -120,13 +122,10 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public void AddAllClosedCaptions()
{
- if (this.UserSettingService.GetUserSetting<bool>(UserSettingConstants.UseClosedCaption))
+
+ foreach (Subtitle subtitle in this.SourceTitlesSubset(null).Where(s => s.SubtitleType == SubtitleType.CC))
{
- foreach (
- Subtitle subtitle in this.SourceTitlesSubset(null).Where(s => s.SubtitleType == SubtitleType.CC))
- {
- this.Add(subtitle);
- }
+ this.Add(subtitle);
}
}
@@ -161,38 +160,6 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
- /// Automatic Subtitle Selection based on user preferences.
- /// </summary>
- public void AutomaticSubtitleSelection()
- {
- this.Task.SubtitleTracks.Clear();
-
- // New DUB Settings
- int mode = this.UserSettingService.GetUserSetting<int>(UserSettingConstants.DubModeSubtitle);
- switch (mode)
- {
- case 1: // Adding all remaining subtitle tracks
- this.AddAllRemaining();
- break;
- case 2: // Adding only the first or preferred first subtitle track.
- this.Add();
- break;
- case 3: // Selected Languages Only
- this.AddAllRemainingForSelectedLanguages();
- break;
- case 4: // Prefered Only
- this.AddForPreferredLanaguages(true);
- break;
- case 5: // Prefered Only All
- this.AddForPreferredLanaguages(false);
- break;
- }
-
- // Add all closed captions if enabled.
- this.AddAllClosedCaptions();
- }
-
- /// <summary>
/// Import an SRT File.
/// </summary>
public void Import()
@@ -279,6 +246,50 @@ namespace HandBrakeWPF.ViewModels
this.NotifyOfPropertyChange(() => this.Task);
}
+ /// <summary>
+ /// Automatic Subtitle Selection based on user preferences.
+ /// </summary>
+ public void AutomaticSubtitleSelection()
+ {
+ this.Task.SubtitleTracks.Clear();
+
+ // New DUB Settings
+ int mode = this.UserSettingService.GetUserSetting<int>(UserSettingConstants.DubModeSubtitle);
+ switch (mode)
+ {
+ case 1: // Adding all remaining subtitle tracks
+ this.AddAllRemaining();
+ break;
+ case 2: // Adding only the first or preferred first subtitle track.
+ this.Add();
+ break;
+ case 3: // Selected Languages Only
+ this.AddAllRemainingForSelectedLanguages();
+ break;
+ case 4: // Prefered Only
+ this.AddForPreferredLanaguages(true);
+ break;
+ case 5: // Prefered Only All
+ this.AddForPreferredLanaguages(false);
+ break;
+ }
+
+ // Add all closed captions if enabled.
+ if (this.UserSettingService.GetUserSetting<bool>(UserSettingConstants.UseClosedCaption))
+ {
+ this.AddAllClosedCaptions();
+ }
+ }
+
+ /// <summary>
+ /// Open the options screen to the Audio and Subtitles tab.
+ /// </summary>
+ public void SetDefaultBehaviour()
+ {
+ OpenOptionsScreenCommand command = new OpenOptionsScreenCommand();
+ command.Execute(OptionsTab.AudioAndSubtitles);
+ }
+
#endregion
#region Implemented Interfaces
@@ -419,10 +430,8 @@ namespace HandBrakeWPF.ViewModels
private IEnumerable<Subtitle> SourceTitlesSubset(IEnumerable<Subtitle> subtitles)
{
return subtitles != null
- ? subtitles.Where(
- subtitle => !this.Task.SubtitleTracks.Any(track => track.SourceTrack == subtitle)).ToList()
- : this.SourceTracks.Where(
- subtitle => !this.Task.SubtitleTracks.Any(track => track.SourceTrack == subtitle)).ToList();
+ ? subtitles.Where(subtitle => !this.Task.SubtitleTracks.Any(track => Equals(track.SourceTrack, subtitle))).ToList()
+ : this.SourceTracks.Where(subtitle => !this.Task.SubtitleTracks.Any(track => Equals(track.SourceTrack, subtitle))).ToList();
}
#endregion