diff options
author | sr55 <[email protected]> | 2012-01-22 20:45:08 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2012-01-22 20:45:08 +0000 |
commit | dab8b3b4cfbe05f84bb89fb76252c68c41d3a06f (patch) | |
tree | 4153040ed252f0f5a13a9a8a50c9fd8c7289f2ac /win/CS/HandBrakeWPF/ViewModels | |
parent | 35018826f82041b6ed7bd6b445f07bd64cb178fd (diff) |
WinGui: (WPF) Further work on the Audio and Subtitle tabs along with the API & Utilities.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4418 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
15 files changed, 324 insertions, 76 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs index a11f2a8e8..60a82d94e 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs @@ -14,6 +14,7 @@ namespace HandBrakeWPF.ViewModels using Caliburn.Micro;
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.Interop.Model.Encoding.x264;
@@ -137,12 +138,18 @@ namespace HandBrakeWPF.ViewModels #region Public Methods
/// <summary>
- /// Set the selected preset
+ /// Setup this window for a new source
/// </summary>
+ /// <param name="title">
+ /// The title.
+ /// </param>
/// <param name="preset">
/// The preset.
/// </param>
- public void SetPreset(Preset preset)
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ public void SetSource(Title title, Preset preset, EncodeTask task)
{
this.Query = preset.Task.AdvancedEncoderOptions;
this.X264Preset = preset.Task.x264Preset;
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs index e20e3ae95..b27c14583 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs @@ -9,14 +9,19 @@ namespace HandBrakeWPF.ViewModels
{
+ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.Composition;
+ using System.Linq;
using Caliburn.Micro;
+ using HandBrake.ApplicationServices.Functions;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
+ using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Services.Interfaces;
+ using HandBrake.Interop.Model.Encoding;
using HandBrakeWPF.ViewModels.Interfaces;
@@ -38,6 +43,10 @@ namespace HandBrakeWPF.ViewModels public AudioViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
{
this.AudioTracks = new ObservableCollection<AudioTrack>();
+ 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();
}
/// <summary>
@@ -46,28 +55,88 @@ namespace HandBrakeWPF.ViewModels public ObservableCollection<AudioTrack> AudioTracks { get; set; }
/// <summary>
+ /// Gets or sets SourceTracks.
+ /// </summary>
+ public IEnumerable<Audio> SourceTracks { get; set; }
+
+ /// <summary>
+ /// Gets or sets AudioEncoders.
+ /// </summary>
+ public IEnumerable<AudioEncoder> AudioEncoders { get; set; }
+
+ /// <summary>
+ /// Gets or sets AudioMixdowns.
+ /// </summary>
+ public IEnumerable<Mixdown> AudioMixdowns { get; set; }
+
+ /// <summary>
+ /// Gets or sets SampleRates.
+ /// </summary>
+ public IEnumerable<string> SampleRates { get; set; }
+
+ /// <summary>
+ /// Gets or sets AudioBitrates.
+ /// </summary>
+ public IEnumerable<int> AudioBitrates { get; set; }
+
+ /// <summary>
/// Add an Audio Track
/// </summary>
public void Add()
{
- this.AudioTracks.Add(new AudioTrack());
+ if (SourceTracks != null)
+ {
+ Audio track = this.SourceTracks.FirstOrDefault();
+ if (track != null)
+ {
+ this.AudioTracks.Add(new AudioTrack { ScannedTrack = track });
+ }
+ }
}
/// <summary>
/// Remove the Selected Track
/// </summary>
- public void Remove()
+ /// <param name="track">
+ /// The track.
+ /// </param>
+ public void Remove(AudioTrack track)
{
+ this.AudioTracks.Remove(track);
}
/// <summary>
- /// Set the selected preset.
+ /// Set the Source Title
/// </summary>
+ /// <param name="title">
+ /// The title.
+ /// </param>
/// <param name="preset">
/// The preset.
/// </param>
- public void SetPreset(Preset preset)
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ public void SetSource(Title title, Preset preset, EncodeTask task)
+ {
+ this.SourceTracks = title.AudioTracks;
+ }
+
+ /// <summary>
+ /// Get Appropiate Bitrates for the selected encoder and mixdown.
+ /// </summary>
+ /// <param name="encoder">
+ /// The encoder.
+ /// </param>
+ /// <param name="mixdown">
+ /// The mixdown.
+ /// </param>
+ /// <returns>
+ /// A List of valid audio bitrates
+ /// </returns>
+ private IEnumerable<int> GetAppropiateBitrates(AudioEncoder encoder, Mixdown mixdown)
{
+ return new ObservableCollection<int> { 32, 40, 48, 56, 64, 80, 96, 112, 128, 160 };
}
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs index 262d6585d..c36a7bcef 100644 --- a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs @@ -103,7 +103,9 @@ namespace HandBrakeWPF.ViewModels {
var saveFileDialog = new VistaSaveFileDialog
{
- Filter = "Csv File|*.csv", DefaultExt = "csv", CheckPathExists = true
+ Filter = "Csv File|*.csv",
+ DefaultExt = "csv",
+ CheckPathExists = true
};
saveFileDialog.ShowDialog();
if (!string.IsNullOrEmpty(saveFileDialog.FileName))
@@ -142,8 +144,8 @@ namespace HandBrakeWPF.ViewModels catch (Exception exc)
{
throw new GeneralApplicationException(
- "Unable to save Chapter Makrers file! ",
- "Chapter marker names will NOT be saved in your encode.",
+ "Unable to save Chapter Makrers file! ",
+ "Chapter marker names will NOT be saved in your encode.",
exc);
}
}
@@ -197,18 +199,21 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
- /// The set preset.
+ /// Setup this window for a new source
/// </summary>
+ /// <param name="title">
+ /// The title.
+ /// </param>
/// <param name="preset">
/// The preset.
/// </param>
- /// <param name="currentTitle">
- /// The current Title.
+ /// <param name="task">
+ /// The task.
/// </param>
- public void Setup(Preset preset, Title currentTitle)
+ public void SetSource(Title title, Preset preset, EncodeTask task)
{
this.IncludeChapterMarkers = preset.Task.IncludeChapterMarkers;
- this.SetSourceChapters(currentTitle.Chapters);
+ this.SetSourceChapters(title.Chapters);
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs index 2b4c9a08c..6dd4292e7 100644 --- a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs @@ -16,6 +16,7 @@ namespace HandBrakeWPF.ViewModels using HandBrake.ApplicationServices.Functions;
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.Interop.Model.Encoding;
@@ -358,12 +359,18 @@ namespace HandBrakeWPF.ViewModels #endregion
/// <summary>
- /// Setup a selected preset.
+ /// Setup this window for a new source
/// </summary>
+ /// <param name="title">
+ /// The title.
+ /// </param>
/// <param name="preset">
- /// The Current Preset.
+ /// The preset.
+ /// </param>
+ /// <param name="task">
+ /// The task.
/// </param>
- public void SetPreset(Preset preset)
+ public void SetSource(Title title, Preset preset, EncodeTask task)
{
if (preset != null)
{
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAdvancedViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAdvancedViewModel.cs index 199c10ff9..dc43ac831 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAdvancedViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAdvancedViewModel.cs @@ -10,6 +10,7 @@ namespace HandBrakeWPF.ViewModels.Interfaces
{
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Parsing;
/// <summary>
/// The Advanced View Model Interface
@@ -19,9 +20,15 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// <summary>
/// Set the selected preset
/// </summary>
+ /// <param name="title">
+ /// The title.
+ /// </param>
/// <param name="preset">
/// The preset.
/// </param>
- void SetPreset(Preset preset);
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ void SetSource(Title title, Preset preset, EncodeTask task);
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioViewModel.cs index d29242625..2d38ab31c 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioViewModel.cs @@ -10,6 +10,7 @@ namespace HandBrakeWPF.ViewModels.Interfaces
{
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Parsing;
/// <summary>
/// The Audio View Model Interface
@@ -17,11 +18,17 @@ namespace HandBrakeWPF.ViewModels.Interfaces public interface IAudioViewModel
{
/// <summary>
- /// Set the selected preset
+ /// Set the Source Title
/// </summary>
+ /// <param name="title">
+ /// The title.
+ /// </param>
/// <param name="preset">
/// The preset.
/// </param>
- void SetPreset(Preset preset);
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ void SetSource(Title title, Preset preset, EncodeTask task);
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IChaptersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IChaptersViewModel.cs index 494e1aaa6..42820006a 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IChaptersViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IChaptersViewModel.cs @@ -20,12 +20,15 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// <summary>
/// Set the selected preset
/// </summary>
+ /// <param name="currentTitle">
+ /// The current Title.
+ /// </param>
/// <param name="preset">
/// The preset.
/// </param>
- /// <param name="currentTitle">
- /// The current Title.
+ /// <param name="task">
+ /// The task.
/// </param>
- void Setup(Preset preset, Title currentTitle);
+ void SetSource(Title currentTitle, Preset preset, EncodeTask task);
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IFiltersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IFiltersViewModel.cs index 3390b328b..cf7d00474 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IFiltersViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IFiltersViewModel.cs @@ -10,6 +10,7 @@ namespace HandBrakeWPF.ViewModels.Interfaces
{
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Parsing;
/// <summary>
/// The Filters View Model Interface
@@ -19,9 +20,15 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// <summary>
/// Setup a selected preset.
/// </summary>
+ /// <param name="title">
+ /// The title.
+ /// </param>
/// <param name="preset">
/// The Current Preset.
/// </param>
- void SetPreset(Preset preset);
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ void SetSource(Title title, Preset preset, EncodeTask task);
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPictureSettingsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPictureSettingsViewModel.cs index ef816de5f..293dc728a 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPictureSettingsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPictureSettingsViewModel.cs @@ -23,12 +23,12 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// <param name="selectedTitle">
/// The selected title.
/// </param>
- /// <param name="currentTask">
- /// The current task.
- /// </param>
/// <param name="currentPreset">
/// The Current preset
/// </param>
- void Setup(Title selectedTitle, EncodeTask currentTask, Preset currentPreset);
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ void SetSource(Title selectedTitle, Preset currentPreset, EncodeTask task);
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs index d0ff210b2..e45aec710 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs @@ -10,6 +10,7 @@ namespace HandBrakeWPF.ViewModels.Interfaces
{
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Parsing;
/// <summary>
/// The Subtiles View Model Interface
@@ -19,9 +20,15 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// <summary>
/// Set the selected preset
/// </summary>
+ /// <param name="title">
+ /// The title.
+ /// </param>
/// <param name="preset">
/// The preset.
/// </param>
- void SetPreset(Preset preset);
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ void SetSource(Title title, Preset preset, EncodeTask task);
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IVideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IVideoViewModel.cs index 4a6c01c43..229051812 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IVideoViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IVideoViewModel.cs @@ -10,6 +10,7 @@ namespace HandBrakeWPF.ViewModels.Interfaces
{
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Parsing;
/// <summary>
/// The Video View Model Interface
@@ -19,9 +20,15 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// <summary>
/// Set the selected preset
/// </summary>
+ /// <param name="title">
+ /// The title.
+ /// </param>
/// <param name="preset">
/// The preset.
/// </param>
- void SetPreset(Preset preset);
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ void SetSource(Title title, Preset preset, EncodeTask task);
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 8899ece9d..9bb31ee5a 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -159,6 +159,7 @@ namespace HandBrakeWPF.ViewModels this.WindowTitle = "HandBrake WPF Test Application";
this.CurrentTask = new EncodeTask();
this.ScannedSource = new Source();
+ this.SelectedPreset = this.presetService.DefaultPreset;
// Setup Events
this.scanService.ScanStared += this.ScanStared;
@@ -1022,13 +1023,13 @@ namespace HandBrakeWPF.ViewModels private void SetupTabs()
{
// Setup the Tabs
- this.PictureSettingsViewModel.Setup(this.SelectedTitle, this.CurrentTask, this.SelectedPreset);
- this.VideoViewModel.SetPreset(this.SelectedPreset);
- this.FiltersViewModel.SetPreset(this.SelectedPreset);
- this.AudioViewModel.SetPreset(this.SelectedPreset);
- this.SubtitleViewModel.SetPreset(this.SelectedPreset);
- this.ChaptersViewModel.Setup(this.SelectedPreset, this.SelectedTitle);
- this.AdvancedViewModel.SetPreset(this.SelectedPreset);
+ this.PictureSettingsViewModel.SetSource(this.SelectedTitle, this.SelectedPreset, this.CurrentTask);
+ this.VideoViewModel.SetSource(this.SelectedTitle, this.SelectedPreset, this.CurrentTask);
+ this.FiltersViewModel.SetSource(this.SelectedTitle, this.SelectedPreset, this.CurrentTask);
+ this.AudioViewModel.SetSource(this.SelectedTitle, this.SelectedPreset, this.CurrentTask);
+ this.SubtitleViewModel.SetSource(this.SelectedTitle, this.SelectedPreset, this.CurrentTask);
+ this.ChaptersViewModel.SetSource(this.SelectedTitle, this.SelectedPreset, this.CurrentTask);
+ this.AdvancedViewModel.SetSource(this.SelectedTitle, this.SelectedPreset, this.CurrentTask);
}
#endregion
@@ -1059,18 +1060,23 @@ namespace HandBrakeWPF.ViewModels /// </param>
private void ScanCompleted(object sender, HandBrake.ApplicationServices.EventArgs.ScanCompletedEventArgs e)
{
- if (e.Successful)
- {
- this.scanService.SouceData.CopyTo(this.ScannedSource);
- this.NotifyOfPropertyChange("ScannedSource");
- this.NotifyOfPropertyChange("ScannedSource.Titles");
- this.SelectedTitle = this.ScannedSource.Titles.Where(t => t.MainTitle).FirstOrDefault();
- this.JobContextService.CurrentSource = this.ScannedSource;
- this.JobContextService.CurrentTask = this.CurrentTask;
- this.SetupTabs();
- }
+ Caliburn.Micro.Execute.OnUIThread(() =>
+ {
+ if (e.Successful)
+ {
+ this.scanService.SouceData.CopyTo(this.ScannedSource);
+ this.NotifyOfPropertyChange("ScannedSource");
+ this.NotifyOfPropertyChange("ScannedSource.Titles");
+ this.SelectedTitle = this.ScannedSource.Titles.Where(t => t.MainTitle).FirstOrDefault();
+ this.JobContextService.CurrentSource = this.ScannedSource;
+ this.JobContextService.CurrentTask = this.CurrentTask;
+ this.SetupTabs();
+ }
+
+ this.SourceLabel = "Scan Completed";
+
+ });
- this.SourceLabel = "Scan Completed";
// TODO Re-enable GUI.
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs index f7ca69f6c..4a1a76cd6 100644 --- a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs @@ -393,21 +393,20 @@ namespace HandBrakeWPF.ViewModels #region Public Methods
/// <summary>
- /// Setup the window after a scan.
+ /// Setup this window for a new source
/// </summary>
- /// <param name="selectedTitle">
- /// The selected title.
+ /// <param name="title">
+ /// The title.
/// </param>
- /// <param name="currentTask">
- /// The current task.
+ /// <param name="preset">
+ /// The preset.
/// </param>
- /// <param name="currentPreset">
- /// The Current preset
+ /// <param name="task">
+ /// The task.
/// </param>
- public void Setup(Title selectedTitle, EncodeTask currentTask, Preset currentPreset)
+ public void SetSource(Title title, Preset preset, EncodeTask task)
{
}
-
#endregion
}
}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs index 81a9c07db..4b0a0af9b 100644 --- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs @@ -9,18 +9,22 @@ namespace HandBrakeWPF.ViewModels
{
- using System;
+ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.Composition;
+ using System.Linq;
using Caliburn.Micro;
+ using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
+ using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Services.Interfaces;
+ using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.ViewModels.Interfaces;
- using HandBrake.ApplicationServices.Model;
+ using Ookii.Dialogs.Wpf;
/// <summary>
/// The Subtitles View Model
@@ -28,6 +32,22 @@ namespace HandBrakeWPF.ViewModels [Export(typeof(ISubtitlesViewModel))]
public class SubtitlesViewModel : ViewModelBase, ISubtitlesViewModel
{
+ #region Constants and Fields
+
+ /// <summary>
+ /// The subtitle tracks.
+ /// </summary>
+ private ObservableCollection<SubtitleTrack> subtitleTracks;
+
+ /// <summary>
+ /// Backing field for the source subtitle tracks.
+ /// </summary>
+ private IEnumerable<Subtitle> sourceTracks;
+
+ #endregion
+
+ #region Constructors and Destructors
+
/// <summary>
/// Initializes a new instance of the <see cref="HandBrakeWPF.ViewModels.SubtitlesViewModel"/> class.
/// </summary>
@@ -40,45 +60,135 @@ namespace HandBrakeWPF.ViewModels public SubtitlesViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
{
this.SubtitleTracks = new ObservableCollection<SubtitleTrack>();
+
+ Langauges = LanguageUtilities.MapLanguages().Keys;
+ CharacterCodes = CharCodesUtilities.GetCharacterCodes();
}
+ #endregion
+
+ #region Public Properties
+
/// <summary>
- /// Gets or sets State.
+ /// Gets or sets State.
/// </summary>
- public ObservableCollection<SubtitleTrack> SubtitleTracks { get; set; }
+ public ObservableCollection<SubtitleTrack> SubtitleTracks
+ {
+ get
+ {
+ return this.subtitleTracks;
+ }
+
+ set
+ {
+ this.subtitleTracks = value;
+ this.NotifyOfPropertyChange(() => this.SubtitleTracks);
+ }
+ }
/// <summary>
- /// Set the currently selected preset.
+ /// Gets or sets Langauges.
/// </summary>
- /// <param name="preset">
- /// The preset.
- /// </param>
- public void SetPreset(Preset preset)
- {
+ public IEnumerable<string> Langauges { get; set; }
+
+ /// <summary>
+ /// Gets or sets CharacterCodes.
+ /// </summary>
+ public IEnumerable<string> CharacterCodes { get; set; }
+
+
+ /// <summary>
+ /// Gets or sets SourceTracks.
+ /// </summary>
+ public IEnumerable<Subtitle> SourceTracks
+ {
+ get
+ {
+ return this.sourceTracks;
+ }
+ set
+ {
+ this.sourceTracks = value;
+ this.NotifyOfPropertyChange(() => SourceTracks);
+ }
}
+ #endregion
+
+ #region Public Methods
+
/// <summary>
/// Add a new Track
/// </summary>
public void Add()
{
- this.SubtitleTracks.Add(new SubtitleTrack());
+ if (this.SourceTracks != null)
+ {
+ Subtitle source = this.SourceTracks.FirstOrDefault();
+ if (source != null)
+ {
+ SubtitleTrack track = new SubtitleTrack
+ {
+ SubtitleType = SubtitleType.VobSub
+ };
+
+ this.SubtitleTracks.Add(track);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Import an SRT File.
+ /// </summary>
+ public void Import()
+ {
+ VistaOpenFileDialog dialog = new VistaOpenFileDialog { Filter = "SRT files (*.srt)|*.srt", CheckFileExists = true, Multiselect = true };
+
+ dialog.ShowDialog();
+
+ foreach (var srtFile in dialog.FileNames)
+ {
+ SubtitleTrack track = new SubtitleTrack
+ {
+ SrtFileName = srtFile,
+ SrtOffset = 0,
+ SrtCharCode = "UTF-8",
+ SrtLang = "English",
+ SubtitleType = SubtitleType.SRT
+ };
+ this.SubtitleTracks.Add(track);
+ }
}
/// <summary>
/// Remove a Track
/// </summary>
- public void Remove()
+ /// <param name="track">
+ /// The track.
+ /// </param>
+ public void Remove(SubtitleTrack track)
{
- throw new NotImplementedException();
+ this.SubtitleTracks.Remove(track);
}
/// <summary>
- /// Import an SRT File.
+ /// Setup this window for a new source
/// </summary>
- public void Import()
+ /// <param name="title">
+ /// The title.
+ /// </param>
+ /// <param name="preset">
+ /// The preset.
+ /// </param>
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ public void SetSource(Title title, Preset preset, EncodeTask task)
{
- throw new NotImplementedException();
+ this.SourceTracks = title.Subtitles;
+ this.SubtitleTracks = task.SubtitleTracks;
}
+
+ #endregion
}
-}
+}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs index 0368c781c..842e109d1 100644 --- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs @@ -16,6 +16,7 @@ namespace HandBrakeWPF.ViewModels using HandBrake.ApplicationServices.Functions;
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.Interop.Model.Encoding;
@@ -389,12 +390,18 @@ namespace HandBrakeWPF.ViewModels #region Public Methods
/// <summary>
- /// Set the currently selected preset.
+ /// Setup this window for a new source
/// </summary>
+ /// <param name="title">
+ /// The title.
+ /// </param>
/// <param name="preset">
/// The preset.
/// </param>
- public void SetPreset(Preset preset)
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ public void SetSource(Title title, Preset preset, EncodeTask task)
{
}
|