diff options
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs | 106 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs | 18 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs | 102 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/AudioView.xaml | 10 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/ChaptersView.xaml | 12 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/SubtitlesView.xaml | 11 |
6 files changed, 174 insertions, 85 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">
diff --git a/win/CS/HandBrakeWPF/Views/AudioView.xaml b/win/CS/HandBrakeWPF/Views/AudioView.xaml index a7e03d935..a014c4e68 100644 --- a/win/CS/HandBrakeWPF/Views/AudioView.xaml +++ b/win/CS/HandBrakeWPF/Views/AudioView.xaml @@ -103,6 +103,16 @@ </Style>
</ListBox.ItemContainerStyle>
+ <ListBox.ContextMenu>
+ <ContextMenu>
+ <MenuItem Header="Add New Track" cal:Message.Attach="[Event Click] = [Action Add]" />
+ <MenuItem Header="Add All Remaining Tracks" cal:Message.Attach="[Event Click] = [Action AddAllRemaining]" />
+ <MenuItem Header="Add All Remaining Selected Languages" cal:Message.Attach="[Event Click] = [Action AddAllRemainingForSelectedLanguages]" />
+ <Separator />
+ <MenuItem Header="Clear All" cal:Message.Attach="[Event Click] = [Action Clear]" />
+ </ContextMenu>
+ </ListBox.ContextMenu>
+
<ListBox.ItemTemplate>
<DataTemplate>
diff --git a/win/CS/HandBrakeWPF/Views/ChaptersView.xaml b/win/CS/HandBrakeWPF/Views/ChaptersView.xaml index e7eb53f7d..c6cefb35e 100644 --- a/win/CS/HandBrakeWPF/Views/ChaptersView.xaml +++ b/win/CS/HandBrakeWPF/Views/ChaptersView.xaml @@ -10,9 +10,9 @@ <RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
-
+
<TextBlock Text="Chapter Markers" FontWeight="Bold" Margin="10,5,0,0" Grid.Row="0" ></TextBlock>
-
+
<Grid Grid.Row="1" Margin="10,5,10,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
@@ -29,6 +29,14 @@ VerticalAlignment="Stretch" HorizontalAlignment="Stretch" AutoGenerateColumns="False"
CanUserSortColumns="False" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserResizeRows="False"
CanUserAddRows="False" CanUserDeleteRows="False">
+ <DataGrid.ContextMenu>
+ <ContextMenu>
+ <MenuItem Header="Import Names" cal:Message.Attach="[Event Click] = [Action Import]" />
+ <MenuItem Header="Export Names" cal:Message.Attach="[Event Click] = [Action Export]" />
+ <Separator />
+ <MenuItem Header="Reset Chapter Names" cal:Message.Attach="[Event Click] = [Action Reset]" />
+ </ContextMenu>
+ </DataGrid.ContextMenu>
<DataGrid.Columns>
<DataGridTextColumn Header="Chapter Number" Width="150" Binding="{Binding ChapterNumber}" IsReadOnly="True" />
<DataGridTextColumn Header="Chapter Name" Width="*" Binding="{Binding ChapterName}" IsReadOnly="False" />
diff --git a/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml b/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml index d5a37afa6..0f5d69f21 100644 --- a/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml +++ b/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml @@ -61,6 +61,17 @@ </Style>
</ListBox.ItemContainerStyle>
+ <ListBox.ContextMenu>
+ <ContextMenu>
+ <MenuItem Header="Add New Track" cal:Message.Attach="[Event Click] = [Action Add]" />
+ <MenuItem Header="Add All Remaining Tracks" cal:Message.Attach="[Event Click] = [Action AddAllRemaining]" />
+ <MenuItem Header="Add All Remaining Closed Captions" cal:Message.Attach="[Event Click] = [Action AddAllClosedCaptions]" />
+ <MenuItem Header="Add All Remaining Selected Languages" cal:Message.Attach="[Event Click] = [Action AddAllRemainingForSelectedLanguages]" />
+ <Separator />
+ <MenuItem Header="Clear All" cal:Message.Attach="[Event Click] = [Action Clear]" />
+ </ContextMenu>
+ </ListBox.ContextMenu>
+
<ListBox.ItemTemplate>
<DataTemplate>
|