summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels
diff options
context:
space:
mode:
authorsr55 <[email protected]>2012-08-04 18:44:50 +0000
committersr55 <[email protected]>2012-08-04 18:44:50 +0000
commitf7f029f905acf0fab8a361e3a87554b1d7a1344a (patch)
treea27325ff6524f11aa83fc29b549c9be1673c714c /win/CS/HandBrakeWPF/ViewModels
parent0ec04d13f9239ae21f2ff05700fee55474bd3b3a (diff)
WinGui: Added a right click menu for the Audio, Subtitles and Chapters tabs with some common actions.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4888 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs106
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs18
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs102
3 files changed, 143 insertions, 83 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
index 6e1fcd675..393702cb2 100644
--- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
@@ -52,7 +52,6 @@ namespace HandBrakeWPF.ViewModels
{
this.Task = new EncodeTask();
this.SampleRates = new ObservableCollection<string> { "Auto", "48", "44.1", "32", "24", "22.05" };
- this.AudioBitrates = this.GetAppropiateBitrates(AudioEncoder.ffaac, Mixdown.DolbyProLogicII);
this.AudioEncoders = EnumHelper<AudioEncoder>.GetEnumList();
this.AudioMixdowns = EnumHelper<Mixdown>.GetEnumList();
this.SourceTracks = new List<Audio>();
@@ -128,6 +127,14 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// The add all remaining.
+ /// </summary>
+ public void AddAllRemaining()
+ {
+ this.AddAllRemainingTracks();
+ }
+
+ /// <summary>
/// Remove the Selected Track
/// </summary>
/// <param name="track">
@@ -139,6 +146,14 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// Clear out the Audio Tracks
+ /// </summary>
+ public void Clear()
+ {
+ this.Task.AudioTracks.Clear();
+ }
+
+ /// <summary>
/// Trigger a Notify Property Changed on the Task to force various UI elements to update.
/// </summary>
public void RefreshTask()
@@ -257,7 +272,7 @@ namespace HandBrakeWPF.ViewModels
/// <summary>
/// Add all source tracks that don't currently exist on the list.
/// </summary>
- private void AddAllRemaining()
+ private void AddAllRemainingTracks()
{
foreach (Audio sourceTrack in this.SourceTracks)
{
@@ -270,6 +285,34 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// Add all remaining for selected languages.
+ /// </summary>
+ public void AddAllRemainingForSelectedLanguages()
+ {
+ // Figure out the source tracks we want to add
+ List<Audio> trackList = new List<Audio>();
+ foreach (
+ string language in
+ this.UserSettingService.GetUserSetting<StringCollection>(
+ UserSettingConstants.SelectedLanguages))
+ {
+ // TODO add support for "Add only 1 per language"
+ trackList.AddRange(this.SourceTracks.Where(source => source.Language.Trim() == language));
+ }
+
+ // Add them if they are not already added.
+ foreach (Audio sourceTrack in trackList)
+ {
+ bool found = this.Task.AudioTracks.Any(audioTrack => audioTrack.ScannedTrack == sourceTrack);
+
+ if (!found)
+ {
+ this.Add(sourceTrack);
+ }
+ }
+ }
+
+ /// <summary>
/// Add the required tracks for the current preset
/// </summary>
/// <param name="preset">
@@ -342,48 +385,41 @@ namespace HandBrakeWPF.ViewModels
this.AddAllRemaining();
break;
case 2: // Add Langauges tracks for the additional languages selected, in-order.
-
- // Figure out the source tracks we want to add
- trackList.Clear();
- foreach (
- string language in
- this.UserSettingService.GetUserSetting<StringCollection>(
- UserSettingConstants.SelectedLanguages))
- {
- // TODO add support for "Add only 1 per language"
- trackList.AddRange(this.SourceTracks.Where(source => source.Language.Trim() == language));
- }
-
- // Add them if they are not already added.
- foreach (Audio sourceTrack in trackList)
- {
- bool found = this.Task.AudioTracks.Any(audioTrack => audioTrack.ScannedTrack == sourceTrack);
-
- if (!found)
- {
- this.Add(sourceTrack);
- }
- }
-
+ this.AddAllRemainingForSelectedLanguages();
break;
}
}
/// <summary>
- /// Get Appropiate Bitrates for the selected encoder and mixdown.
+ /// The get language tracks.
/// </summary>
- /// <param name="encoder">
- /// The encoder.
- /// </param>
- /// <param name="mixdown">
- /// The mixdown.
- /// </param>
/// <returns>
- /// A List of valid audio bitrates
+ /// The Users desired audio tracks
/// </returns>
- private IEnumerable<int> GetAppropiateBitrates(AudioEncoder encoder, Mixdown mixdown)
+ private List<Audio> GetLanguageTracks()
{
- return new ObservableCollection<int> { 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 640, 768 };
+ List<Audio> trackList = new List<Audio>();
+ 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.
+ trackList.Add(this.SourceTracks.FirstOrDefault());
+ }
+ else
+ {
+ // Otherwise, fetch the preferred language.
+ foreach (
+ Audio item in
+ this.SourceTracks.Where(
+ item =>
+ item.Language.Contains(
+ this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguage))))
+ {
+ trackList.Add(item);
+ break;
+ }
+ }
+
+ return trackList;
}
#endregion
diff --git a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs
index 586167840..ee2cebe34 100644
--- a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs
@@ -33,6 +33,11 @@ namespace HandBrakeWPF.ViewModels
[Export(typeof(IChaptersViewModel))]
public class ChaptersViewModel : ViewModelBase, IChaptersViewModel
{
+ /// <summary>
+ /// The source chapters backing field
+ /// </summary>
+ private List<Chapter> sourceChaptersList;
+
#region Constructors and Destructors
/// <summary>
@@ -207,6 +212,8 @@ namespace HandBrakeWPF.ViewModels
{
this.IncludeChapterMarkers = preset.Task.IncludeChapterMarkers;
}
+
+ this.sourceChaptersList = title.Chapters;
this.SetSourceChapters(title.Chapters);
}
@@ -241,6 +248,17 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// Reset Chapter Names
+ /// </summary>
+ public void Reset()
+ {
+ if (this.sourceChaptersList != null)
+ {
+ this.SetSourceChapters(this.sourceChaptersList);
+ }
+ }
+
+ /// <summary>
/// Set the Source Chapters List
/// </summary>
/// <param name="sourceChapters">
diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
index d5e949809..8d6dafb2c 100644
--- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
@@ -7,14 +7,12 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-using System.IO;
-
namespace HandBrakeWPF.ViewModels
{
using System.Collections.Generic;
using System.Collections.Specialized;
- using System.ComponentModel;
using System.ComponentModel.Composition;
+ using System.IO;
using System.Linq;
using Caliburn.Micro;
@@ -120,6 +118,51 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// Add all closed captions not already on the list.
+ /// </summary>
+ public void AddAllClosedCaptions()
+ {
+ if (this.UserSettingService.GetUserSetting<bool>(UserSettingConstants.UseClosedCaption))
+ {
+ foreach (
+ Subtitle subtitle in this.SourceTitlesSubset(null).Where(s => s.SubtitleType == SubtitleType.CC))
+ {
+ this.Add(subtitle);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Add all the remaining subtitle tracks.
+ /// </summary>
+ public void AddAllRemaining()
+ {
+ foreach (Subtitle subtitle in this.SourceTitlesSubset(null))
+ {
+ this.Add(subtitle);
+ }
+ }
+
+ /// <summary>
+ /// Add all remaining tracks for the users preferred and selected languages
+ /// </summary>
+ public void AddAllRemainingForSelectedLanguages()
+ {
+ // Get a list of subtitle tracks that match the users lanaguages
+ StringCollection userSelectedLanguages =
+ this.UserSettingService.GetUserSetting<StringCollection>(UserSettingConstants.SelectedLanguages);
+ userSelectedLanguages.Add(
+ this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguageForSubtitles));
+ List<Subtitle> availableTracks =
+ this.SourceTracks.Where(subtitle => userSelectedLanguages.Contains(subtitle.Language)).ToList();
+
+ foreach (Subtitle subtitle in this.SourceTitlesSubset(availableTracks))
+ {
+ this.Add(subtitle);
+ }
+ }
+
+ /// <summary>
/// Automatic Subtitle Selection based on user preferences.
/// </summary>
public void AutomaticSubtitleSelection()
@@ -192,6 +235,14 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// Clear all Tracks
+ /// </summary>
+ public void Clear()
+ {
+ this.Task.SubtitleTracks.Clear();
+ }
+
+ /// <summary>
/// Select the default subtitle track.
/// </summary>
/// <param name="subtitle">
@@ -335,51 +386,6 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
- /// Add all closed captions not already on the list.
- /// </summary>
- private void AddAllClosedCaptions()
- {
- if (this.UserSettingService.GetUserSetting<bool>(UserSettingConstants.UseClosedCaption))
- {
- foreach (
- Subtitle subtitle in this.SourceTitlesSubset(null).Where(s => s.SubtitleType == SubtitleType.CC))
- {
- this.Add(subtitle);
- }
- }
- }
-
- /// <summary>
- /// Add all the remaining subtitle tracks.
- /// </summary>
- private void AddAllRemaining()
- {
- foreach (Subtitle subtitle in this.SourceTitlesSubset(null))
- {
- this.Add(subtitle);
- }
- }
-
- /// <summary>
- /// Add all remaining tracks for the users preferred and selected languages
- /// </summary>
- private void AddAllRemainingForSelectedLanguages()
- {
- // Get a list of subtitle tracks that match the users lanaguages
- StringCollection userSelectedLanguages =
- this.UserSettingService.GetUserSetting<StringCollection>(UserSettingConstants.SelectedLanguages);
- userSelectedLanguages.Add(
- this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguageForSubtitles));
- List<Subtitle> availableTracks =
- this.SourceTracks.Where(subtitle => userSelectedLanguages.Contains(subtitle.Language)).ToList();
-
- foreach (Subtitle subtitle in this.SourceTitlesSubset(availableTracks))
- {
- this.Add(subtitle);
- }
- }
-
- /// <summary>
/// Add all tracks for the preferred languages settings.
/// </summary>
/// <param name="firstOnly">