diff options
17 files changed, 808 insertions, 667 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs b/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs index e1ed6eb62..d89c77082 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs @@ -30,6 +30,9 @@ namespace HandBrake.ApplicationServices.Model this.SubtitleTracks = new ObservableCollection<SubtitleTrack>();
this.ChapterNames = new ObservableCollection<ChapterMarker>();
this.AllowedPassthruOptions = new AllowedPassthru();
+ this.x264Preset = x264Preset.None;
+ this.x264Profile = x264Profile.None;
+ this.X264Tune = x264Tune.None;
}
/// <summary>
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs index 31947d657..35cf3a38e 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs @@ -361,7 +361,7 @@ namespace HandBrake.ApplicationServices.Utilities break;
}
- if (task.Deblock != 4)
+ if (task.Deblock != 0)
query += string.Format(" --deblock={0}", task.Deblock);
if (task.Grayscale)
diff --git a/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs b/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs index d5663f2af..635b3bd0c 100644 --- a/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs @@ -65,16 +65,32 @@ namespace HandBrakeWPF.Converters {
return EnumHelper<Mixdown>.GetEnumDisplayValues(typeof(Mixdown));
}
-
if (value is IEnumerable<AudioEncoder>)
{
return EnumHelper<AudioEncoder>.GetEnumDisplayValues(typeof(AudioEncoder));
}
-
if (value is IEnumerable<PresetPictureSettingsMode>)
{
return EnumHelper<PresetPictureSettingsMode>.GetEnumDisplayValues(typeof(PresetPictureSettingsMode));
}
+ if (value is IEnumerable<Decomb>)
+ {
+ return EnumHelper<Decomb>.GetEnumDisplayValues(typeof(Decomb));
+ }
+ if (value is IEnumerable<Deinterlace>)
+ {
+ return EnumHelper<Deinterlace>.GetEnumDisplayValues(typeof(Deinterlace));
+ }
+ if (value is IEnumerable<Detelecine>)
+ {
+ return EnumHelper<Detelecine>.GetEnumDisplayValues(typeof(Detelecine));
+ }
+ if (value is IEnumerable<Denoise>)
+ {
+ return EnumHelper<Denoise>.GetEnumDisplayValues(typeof(Denoise));
+ }
+
+
// Single Items
if (targetType == typeof(x264Preset) || value.GetType() == typeof(x264Preset))
@@ -105,6 +121,22 @@ namespace HandBrakeWPF.Converters {
return EnumHelper<PresetPictureSettingsMode>.GetDisplay((PresetPictureSettingsMode)value);
}
+ if (targetType == typeof(Deinterlace) || value.GetType() == typeof(Deinterlace))
+ {
+ return EnumHelper<Deinterlace>.GetDisplay((Deinterlace)value);
+ }
+ if (targetType == typeof(Detelecine) || value.GetType() == typeof(Detelecine))
+ {
+ return EnumHelper<Detelecine>.GetDisplay((Detelecine)value);
+ }
+ if (targetType == typeof(Decomb) || value.GetType() == typeof(Decomb))
+ {
+ return EnumHelper<Decomb>.GetDisplay((Decomb)value);
+ }
+ if (targetType == typeof(Denoise) || value.GetType() == typeof(Denoise))
+ {
+ return EnumHelper<Denoise>.GetDisplay((Denoise)value);
+ }
return null;
}
@@ -160,6 +192,22 @@ namespace HandBrakeWPF.Converters {
return EnumHelper<PresetPictureSettingsMode>.GetValue(value.ToString());
}
+ if (targetType == typeof(Denoise) || value.GetType() == typeof(Denoise))
+ {
+ return EnumHelper<Denoise>.GetValue(value.ToString());
+ }
+ if (targetType == typeof(Decomb) || value.GetType() == typeof(Decomb))
+ {
+ return EnumHelper<Decomb>.GetValue(value.ToString());
+ }
+ if (targetType == typeof(Deinterlace) || value.GetType() == typeof(Deinterlace))
+ {
+ return EnumHelper<Deinterlace>.GetValue(value.ToString());
+ }
+ if (targetType == typeof(Detelecine) || value.GetType() == typeof(Detelecine))
+ {
+ return EnumHelper<Detelecine>.GetValue(value.ToString());
+ }
return null;
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs index 5428e6bb7..cd1904cb3 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs @@ -32,26 +32,6 @@ namespace HandBrakeWPF.ViewModels #region Constants and Fields
/// <summary>
- /// The query.
- /// </summary>
- private string query;
-
- /// <summary>
- /// The x264 preset.
- /// </summary>
- private x264Preset x264Preset;
-
- /// <summary>
- /// The x264 profile.
- /// </summary>
- private x264Profile x264Profile;
-
- /// <summary>
- /// The x264 tune.
- /// </summary>
- private x264Tune x264Tune;
-
- /// <summary>
/// Backing field used to display / hide the x264 options
/// </summary>
private bool displayX264Options;
@@ -71,13 +51,10 @@ namespace HandBrakeWPF.ViewModels /// </param>
public AdvancedViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
{
+ this.Task = new EncodeTask();
X264Presets = EnumHelper<x264Preset>.GetEnumList();
X264Profiles = EnumHelper<x264Profile>.GetEnumList();
X264Tunes = EnumHelper<x264Tune>.GetEnumList();
-
- this.x264Preset = x264Preset.None;
- this.x264Profile = x264Profile.None;
- this.x264Tune = x264Tune.None;
}
#endregion
@@ -85,17 +62,22 @@ namespace HandBrakeWPF.ViewModels #region Public Properties
/// <summary>
+ /// Gets or sets Task.
+ /// </summary>
+ public EncodeTask Task { get; set; }
+
+ /// <summary>
/// Gets or sets State.
/// </summary>
public string Query
{
get
{
- return this.query;
+ return this.Task.AdvancedEncoderOptions;
}
set
{
- this.query = value;
+ this.Task.AdvancedEncoderOptions = value;
this.NotifyOfPropertyChange(() => this.Query);
}
}
@@ -107,11 +89,11 @@ namespace HandBrakeWPF.ViewModels {
get
{
- return this.x264Preset;
+ return this.Task.x264Preset;
}
set
{
- this.x264Preset = value;
+ this.Task.x264Preset = value;
this.NotifyOfPropertyChange(() => this.X264Preset);
}
}
@@ -123,11 +105,11 @@ namespace HandBrakeWPF.ViewModels {
get
{
- return this.x264Profile;
+ return this.Task.x264Profile;
}
set
{
- this.x264Profile = value;
+ this.Task.x264Profile = value;
this.NotifyOfPropertyChange(() => this.X264Profile);
}
}
@@ -139,11 +121,11 @@ namespace HandBrakeWPF.ViewModels {
get
{
- return this.x264Tune;
+ return this.Task.X264Tune;
}
set
{
- this.x264Tune = value;
+ this.Task.X264Tune = value;
this.NotifyOfPropertyChange(() => this.X264Tune);
}
}
@@ -197,10 +179,8 @@ namespace HandBrakeWPF.ViewModels /// </param>
public void SetSource(Title title, Preset preset, EncodeTask task)
{
- this.Query = preset.Task.AdvancedEncoderOptions;
- this.X264Preset = preset.Task.x264Preset;
- this.X264Profile = preset.Task.x264Profile;
- this.X264Tune = preset.Task.X264Tune;
+ this.Task = task;
+ this.NotifyOfPropertyChange(() => this.Task);
}
/// <summary>
@@ -209,8 +189,13 @@ namespace HandBrakeWPF.ViewModels /// <param name="preset">
/// The preset.
/// </param>
- public void SetPreset(Preset preset)
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ public void SetPreset(Preset preset, EncodeTask task)
{
+ this.Task = task;
+ this.NotifyOfPropertyChange(() => this.Task);
if (preset != null && preset.Task != null)
{
this.Query = preset.Task.AdvancedEncoderOptions;
@@ -230,17 +215,7 @@ namespace HandBrakeWPF.ViewModels /// </param>
public void SetEncoder(VideoEncoder encoder)
{
- if (encoder == VideoEncoder.X264)
- {
- this.DisplayX264Options = true;
- }
- else
- {
- this.x264Preset = x264Preset.None;
- this.x264Profile = x264Profile.None;
- this.x264Tune = x264Tune.None;
- this.DisplayX264Options = false;
- }
+ this.DisplayX264Options = encoder == VideoEncoder.X264;
}
#endregion
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs index 702019bc3..dbe32a813 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs @@ -9,8 +9,6 @@ namespace HandBrakeWPF.ViewModels
{
- using System;
- using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
@@ -34,6 +32,8 @@ namespace HandBrakeWPF.ViewModels [Export(typeof(IAudioViewModel))]
public class AudioViewModel : ViewModelBase, IAudioViewModel
{
+ #region Constructors and Destructors
+
/// <summary>
/// Initializes a new instance of the <see cref="AudioViewModel"/> class.
/// </summary>
@@ -45,7 +45,7 @@ namespace HandBrakeWPF.ViewModels /// </param>
public AudioViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
{
- this.AudioTracks = new ObservableCollection<AudioTrack>();
+ 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();
@@ -53,15 +53,14 @@ namespace HandBrakeWPF.ViewModels this.SourceTracks = new List<Audio>();
}
- /// <summary>
- /// Gets or sets AudioTracks.
- /// </summary>
- public ObservableCollection<AudioTrack> AudioTracks { get; set; }
+ #endregion
+
+ #region Properties
/// <summary>
- /// Gets or sets SourceTracks.
+ /// Gets or sets AudioBitrates.
/// </summary>
- public IEnumerable<Audio> SourceTracks { get; set; }
+ public IEnumerable<int> AudioBitrates { get; set; }
/// <summary>
/// Gets or sets AudioEncoders.
@@ -79,9 +78,18 @@ namespace HandBrakeWPF.ViewModels public IEnumerable<string> SampleRates { get; set; }
/// <summary>
- /// Gets or sets AudioBitrates.
+ /// Gets or sets SourceTracks.
/// </summary>
- public IEnumerable<int> AudioBitrates { get; set; }
+ public IEnumerable<Audio> SourceTracks { get; set; }
+
+ /// <summary>
+ /// Gets or sets the EncodeTask.
+ /// </summary>
+ public EncodeTask Task { get; set; }
+
+ #endregion
+
+ #region Public Methods
/// <summary>
/// Add an Audio Track
@@ -100,28 +108,14 @@ namespace HandBrakeWPF.ViewModels /// </param>
public void Remove(AudioTrack track)
{
- this.AudioTracks.Remove(track);
+ this.Task.AudioTracks.Remove(track);
}
- /// <summary>
- /// Set the Source Title
- /// </summary>
- /// <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)
- {
- this.SourceTracks = title.AudioTracks;
+ #endregion
- this.SetPreset(preset);
- this.AutomaticTrackSelection();
- }
+ #region Implemented Interfaces
+
+ #region ITabInterface
/// <summary>
/// Setup this tab for the specified preset.
@@ -129,31 +123,45 @@ namespace HandBrakeWPF.ViewModels /// <param name="preset">
/// The preset.
/// </param>
- public void SetPreset(Preset preset)
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ public void SetPreset(Preset preset, EncodeTask task)
{
+ this.Task = task;
+ this.NotifyOfPropertyChange(() => this.Task);
if (preset != null && preset.Task != null)
{
- AddTracksFromPreset(preset);
+ this.AddTracksFromPreset(preset);
}
}
/// <summary>
- /// Get Appropiate Bitrates for the selected encoder and mixdown.
+ /// Set the Source Title
/// </summary>
- /// <param name="encoder">
- /// The encoder.
+ /// <param name="title">
+ /// The title.
/// </param>
- /// <param name="mixdown">
- /// The mixdown.
+ /// <param name="preset">
+ /// The preset.
/// </param>
- /// <returns>
- /// A List of valid audio bitrates
- /// </returns>
- private IEnumerable<int> GetAppropiateBitrates(AudioEncoder encoder, Mixdown mixdown)
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ public void SetSource(Title title, Preset preset, EncodeTask task)
{
- return new ObservableCollection<int> { 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 640, 768 };
+ this.SourceTracks = title.AudioTracks;
+
+ this.SetPreset(preset, task);
+ this.AutomaticTrackSelection();
}
+ #endregion
+
+ #endregion
+
+ #region Methods
+
/// <summary>
/// Add the specified source track, or the first track in the SourceTracks collection if available.
/// </summary>
@@ -162,12 +170,12 @@ namespace HandBrakeWPF.ViewModels /// </param>
private void Add(Audio sourceTrack)
{
- if (SourceTracks != null)
+ if (this.SourceTracks != null)
{
Audio track = sourceTrack ?? this.SourceTracks.FirstOrDefault();
if (track != null)
{
- this.AudioTracks.Add(new AudioTrack { ScannedTrack = track });
+ this.Task.AudioTracks.Add(new AudioTrack { ScannedTrack = track });
}
}
}
@@ -179,7 +187,7 @@ namespace HandBrakeWPF.ViewModels {
foreach (Audio sourceTrack in this.SourceTracks)
{
- bool found = this.AudioTracks.Any(audioTrack => audioTrack.ScannedTrack == sourceTrack);
+ bool found = this.Task.AudioTracks.Any(audioTrack => audioTrack.ScannedTrack == sourceTrack);
if (!found)
{
this.Add(sourceTrack);
@@ -196,24 +204,28 @@ namespace HandBrakeWPF.ViewModels private void AddTracksFromPreset(Preset preset)
{
// Clear out the old tracks
- this.AudioTracks.Clear();
+ this.Task.AudioTracks.Clear();
// Get the preferred Language
- IEnumerable<Audio> languages = this.SourceTracks.Where(item => item.Language.Contains(this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguage)));
+ IEnumerable<Audio> languages =
+ this.SourceTracks.Where(
+ item =>
+ item.Language.Contains(
+ this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguage)));
Audio preferred = languages.FirstOrDefault() ?? this.SourceTracks.FirstOrDefault();
// Get the currently selected langauges
- List<Audio> selectedTracks = this.AudioTracks.Select(track => track.ScannedTrack).ToList();
+ List<Audio> selectedTracks = this.Task.AudioTracks.Select(track => track.ScannedTrack).ToList();
// Add the preset audio tracks with the preferred language
foreach (AudioTrack track in preset.Task.AudioTracks)
{
- this.AudioTracks.Add(new AudioTrack(track) { ScannedTrack = preferred });
+ this.Task.AudioTracks.Add(new AudioTrack(track) { ScannedTrack = preferred });
}
// Attempt to restore the previously selected tracks.
// or fallback to the first source track.
- foreach (AudioTrack track in this.AudioTracks)
+ foreach (AudioTrack track in this.Task.AudioTracks)
{
if (selectedTracks.Count != 0)
{
@@ -247,13 +259,18 @@ namespace HandBrakeWPF.ViewModels else
{
// Otherwise, fetch the preferred language.
- foreach (Audio item in this.SourceTracks.Where(item => item.Language.Contains(this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguage))))
+ foreach (
+ Audio item in
+ this.SourceTracks.Where(
+ item =>
+ item.Language.Contains(
+ this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguage))))
{
trackList.Add(item);
break;
}
- foreach (AudioTrack track in this.AudioTracks)
+ foreach (AudioTrack track in this.Task.AudioTracks)
{
track.ScannedTrack = trackList.FirstOrDefault() ?? this.SourceTracks.FirstOrDefault();
}
@@ -271,7 +288,10 @@ namespace HandBrakeWPF.ViewModels // Figure out the source tracks we want to add
trackList.Clear();
- foreach (string language in this.UserSettingService.GetUserSetting<StringCollection>(UserSettingConstants.SelectedLanguages))
+ 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));
@@ -280,7 +300,7 @@ namespace HandBrakeWPF.ViewModels // Add them if they are not already added.
foreach (Audio sourceTrack in trackList)
{
- bool found = this.AudioTracks.Any(audioTrack => audioTrack.ScannedTrack == sourceTrack);
+ bool found = this.Task.AudioTracks.Any(audioTrack => audioTrack.ScannedTrack == sourceTrack);
if (!found)
{
@@ -291,5 +311,24 @@ namespace HandBrakeWPF.ViewModels break;
}
}
+
+ /// <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, 192, 224, 256, 320, 384, 448, 640, 768 };
+ }
+
+ #endregion
}
-}
+}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs index 0495b8fcc..264643847 100644 --- a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs @@ -33,15 +33,6 @@ namespace HandBrakeWPF.ViewModels [Export(typeof(IChaptersViewModel))]
public class ChaptersViewModel : ViewModelBase, IChaptersViewModel
{
- #region Constants and Fields
-
- /// <summary>
- /// The include chapter markers.
- /// </summary>
- private bool includeChapterMarkers;
-
- #endregion
-
#region Constructors and Destructors
/// <summary>
@@ -55,17 +46,16 @@ namespace HandBrakeWPF.ViewModels /// </param>
public ChaptersViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
{
- this.Chapters = new ObservableCollection<ChapterMarker>();
+ this.Task = new EncodeTask();
}
#endregion
#region Public Properties
-
/// <summary>
- /// Gets or sets State.
+ /// Gets or sets Task.
/// </summary>
- public ObservableCollection<ChapterMarker> Chapters { get; set; }
+ public EncodeTask Task { get; set; }
/// <summary>
/// Gets or sets a value indicating whether chapter markers are enabled.
@@ -74,11 +64,11 @@ namespace HandBrakeWPF.ViewModels {
get
{
- return this.includeChapterMarkers;
+ return this.Task.IncludeChapterMarkers;
}
set
{
- this.includeChapterMarkers = value;
+ this.Task.IncludeChapterMarkers = value;
this.NotifyOfPropertyChange(() => this.IncludeChapterMarkers);
}
}
@@ -129,7 +119,7 @@ namespace HandBrakeWPF.ViewModels {
string csv = string.Empty;
- foreach (ChapterMarker row in this.Chapters)
+ foreach (ChapterMarker row in this.Task.ChapterNames)
{
csv += row.ChapterNumber.ToString();
csv += ",";
@@ -188,7 +178,7 @@ namespace HandBrakeWPF.ViewModels }
// Now iterate over each chatper we have, and set it's name
- foreach (ChapterMarker item in this.Chapters)
+ foreach (ChapterMarker item in this.Task.ChapterNames)
{
string chapterName;
chapterMap.TryGetValue(item.ChapterNumber, out chapterName);
@@ -212,6 +202,8 @@ namespace HandBrakeWPF.ViewModels /// </param>
public void SetSource(Title title, Preset preset, EncodeTask task)
{
+ this.Task = task;
+ this.NotifyOfPropertyChange(() => this.Task);
this.IncludeChapterMarkers = preset.Task.IncludeChapterMarkers;
this.SetSourceChapters(title.Chapters);
}
@@ -222,8 +214,13 @@ namespace HandBrakeWPF.ViewModels /// <param name="preset">
/// The preset.
/// </param>
- public void SetPreset(Preset preset)
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ public void SetPreset(Preset preset, EncodeTask task)
{
+ this.Task = task;
+ this.NotifyOfPropertyChange(() => this.Task);
}
/// <summary>
@@ -236,7 +233,7 @@ namespace HandBrakeWPF.ViewModels {
// Cache the chapters in this screen
this.SourceChapterList = new ObservableCollection<Chapter>(sourceChapters);
- this.Chapters.Clear();
+ this.Task.ChapterNames.Clear();
// Then Add new Chapter Markers.
int counter = 1;
@@ -245,7 +242,7 @@ namespace HandBrakeWPF.ViewModels {
string chapterName = string.IsNullOrEmpty(chapter.ChapterName) ? string.Format("Chapter {0}", counter) : chapter.ChapterName;
var marker = new ChapterMarker(chapter.ChapterNumber, chapterName);
- this.Chapters.Add(marker);
+ this.Task.ChapterNames.Add(marker);
counter += 1;
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs index 9cd9ce540..92d069698 100644 --- a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs @@ -28,88 +28,107 @@ namespace HandBrakeWPF.ViewModels [Export(typeof(IFiltersViewModel))]
public class FiltersViewModel : ViewModelBase, IFiltersViewModel
{
- #region Constants and Fields
+ #region Constructors and Destructors
/// <summary>
- /// Backing field for the deblock value
+ /// Initializes a new instance of the <see cref="FiltersViewModel"/> class.
/// </summary>
- private int deblockValue;
+ /// <param name="windowManager">
+ /// The window manager.
+ /// </param>
+ /// <param name="userSettingService">
+ /// The user Setting Service.
+ /// </param>
+ public FiltersViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
+ {
+ this.CurrentTask = new EncodeTask();
+ }
- /// <summary>
- /// Backing field for the selected deinterlace value
- /// </summary>
- private Deinterlace selectedDeInterlace;
+ #endregion
- /// <summary>
- /// Backing field for the selected decomb value
- /// </summary>
- private Decomb selectedDecomb;
+ #region Properties
/// <summary>
- /// Backing field for the selected denoise value
+ /// Gets CurrentTask.
/// </summary>
- private Denoise selectedDenoise;
+ public EncodeTask CurrentTask { get; private set; }
/// <summary>
- /// Backing field for the selected detelecine value
+ /// Gets or sets CustomDecomb.
/// </summary>
- private Detelecine selectedDetelecine;
+ public string CustomDecomb
+ {
+ get
+ {
+ return this.CurrentTask.CustomDecomb;
+ }
- /// <summary>
- /// Backing field for the custom decomb value
- /// </summary>
- private string customDeinterlace;
+ set
+ {
+ this.CurrentTask.CustomDecomb = value;
+ this.NotifyOfPropertyChange(() => this.CustomDecomb);
+ }
+ }
/// <summary>
- /// Backing field for the custom debcomb value
+ /// Gets or sets CustomDeinterlace.
/// </summary>
- private string customDecomb;
+ public string CustomDeinterlace
+ {
+ get
+ {
+ return this.CurrentTask.CustomDeinterlace;
+ }
- /// <summary>
- /// Backing field for the custom detelecine value
- /// </summary>
- private string customDetelecine;
+ set
+ {
+ this.CurrentTask.CustomDeinterlace = value;
+ this.NotifyOfPropertyChange(() => this.CustomDeinterlace);
+ }
+ }
/// <summary>
- /// Backing field for the custom denoise value
+ /// Gets or sets CustomDenoise.
/// </summary>
- private string customDenoise;
-
- #endregion
+ public string CustomDenoise
+ {
+ get
+ {
+ return this.CurrentTask.CustomDenoise;
+ }
- #region Constructors and Destructors
+ set
+ {
+ this.CurrentTask.CustomDenoise = value;
+ this.NotifyOfPropertyChange(() => this.CustomDenoise);
+ }
+ }
/// <summary>
- /// Initializes a new instance of the <see cref="FiltersViewModel"/> class.
+ /// Gets or sets CustomDetelecine.
/// </summary>
- /// <param name="windowManager">
- /// The window manager.
- /// </param>
- /// <param name="userSettingService">
- /// The user Setting Service.
- /// </param>
- public FiltersViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
+ public string CustomDetelecine
{
- this.CurrentTask = new EncodeTask();
- }
-
- #endregion
-
- #region Properties
+ get
+ {
+ return this.CurrentTask.CustomDetelecine;
+ }
- /// <summary>
- /// Gets CurrentTask.
- /// </summary>
- public EncodeTask CurrentTask { get; private set; }
+ set
+ {
+ this.CurrentTask.CustomDetelecine = value;
+ this.NotifyOfPropertyChange(() => this.CustomDetelecine);
+ }
+ }
/// <summary>
/// Gets DeInterlaceOptions.
/// </summary>
- public IEnumerable<string> DeInterlaceOptions
+ public IEnumerable<Deinterlace> DeInterlaceOptions
{
get
{
- return EnumHelper<Deinterlace>.GetEnumDisplayValues(typeof(Deinterlace));
+ return EnumHelper<Deinterlace>.GetEnumList();
}
}
@@ -131,144 +150,158 @@ namespace HandBrakeWPF.ViewModels {
get
{
- return this.deblockValue;
+ return this.CurrentTask.Deblock;
}
+
set
{
- this.deblockValue = value;
- this.NotifyOfPropertyChange("DeblockValue");
- this.NotifyOfPropertyChange("DeblockText");
+ this.CurrentTask.Deblock = value;
+ this.NotifyOfPropertyChange(() => this.DeblockValue);
+ this.NotifyOfPropertyChange(() => this.DeblockText);
}
}
/// <summary>
/// Gets DecombOptions.
/// </summary>
- public IEnumerable<string> DecombOptions
+ public IEnumerable<Decomb> DecombOptions
{
get
{
- return EnumHelper<Decomb>.GetEnumDisplayValues(typeof(Decomb));
+ return EnumHelper<Decomb>.GetEnumList();
}
}
/// <summary>
/// Gets DenoiseOptions.
/// </summary>
- public IEnumerable<string> DenoiseOptions
+ public IEnumerable<Denoise> DenoiseOptions
{
get
{
- return EnumHelper<Denoise>.GetEnumDisplayValues(typeof(Denoise));
+ return EnumHelper<Denoise>.GetEnumList();
}
}
/// <summary>
/// Gets DetelecineOptions.
/// </summary>
- public IEnumerable<string> DetelecineOptions
+ public IEnumerable<Detelecine> DetelecineOptions
{
get
{
- return EnumHelper<Detelecine>.GetEnumDisplayValues(typeof(Detelecine));
+ return EnumHelper<Detelecine>.GetEnumList();
}
}
/// <summary>
/// Gets or sets a value indicating whether Grayscale.
/// </summary>
- public bool Grayscale { get; set; }
+ public bool Grayscale
+ {
+ get
+ {
+ return this.CurrentTask.Grayscale;
+ }
+
+ set
+ {
+ this.CurrentTask.Grayscale = value;
+ this.NotifyOfPropertyChange(() => this.Grayscale);
+ }
+ }
/// <summary>
/// Gets or sets SelectedDeInterlace.
/// </summary>
- public string SelectedDeInterlace
+ public Deinterlace SelectedDeInterlace
{
get
{
- return EnumHelper<Deinterlace>.GetDisplay(this.selectedDeInterlace);
+ return this.CurrentTask.Deinterlace;
}
set
{
- this.selectedDeInterlace = EnumHelper<Deinterlace>.GetValue(value);
- if (this.selectedDeInterlace != Deinterlace.Off)
+ this.CurrentTask.Deinterlace = value;
+ if (this.CurrentTask.Deinterlace != Deinterlace.Off)
{
- this.SelectedDecomb = EnumHelper<Decomb>.GetDisplay(Decomb.Off);
+ this.SelectedDecomb = Decomb.Off;
}
- this.NotifyOfPropertyChange("SelectedDeInterlace");
+
+ this.NotifyOfPropertyChange(() => this.SelectedDeInterlace);
// Show / Hide the Custom Control
- this.ShowDeinterlaceCustom = this.selectedDeInterlace == Deinterlace.Custom;
- this.NotifyOfPropertyChange("ShowDeinterlaceCustom");
+ this.ShowDeinterlaceCustom = this.CurrentTask.Deinterlace == Deinterlace.Custom;
+ this.NotifyOfPropertyChange(() => this.ShowDeinterlaceCustom);
}
}
/// <summary>
/// Gets or sets SelectedDecomb.
/// </summary>
- public string SelectedDecomb
+ public Decomb SelectedDecomb
{
get
{
- return EnumHelper<Decomb>.GetDisplay(this.selectedDecomb);
+ return this.CurrentTask.Decomb;
}
set
{
- this.selectedDecomb = EnumHelper<Decomb>.GetValue(value);
- if (this.selectedDecomb != Decomb.Off)
+ this.CurrentTask.Decomb = value;
+ if (this.CurrentTask.Decomb != Decomb.Off)
{
- this.SelectedDeInterlace = EnumHelper<Deinterlace>.GetDisplay(Deinterlace.Off);
+ this.SelectedDeInterlace = Deinterlace.Off;
}
- this.NotifyOfPropertyChange("SelectedDecomb");
+ this.NotifyOfPropertyChange(() => this.SelectedDecomb);
// Show / Hide the Custom Control
- this.ShowDecombCustom = this.selectedDecomb == Decomb.Custom;
- this.NotifyOfPropertyChange("ShowDecombCustom");
+ this.ShowDecombCustom = this.CurrentTask.Decomb == Decomb.Custom;
+ this.NotifyOfPropertyChange(() => this.ShowDecombCustom);
}
}
/// <summary>
/// Gets or sets SelectedDenoise.
/// </summary>
- public string SelectedDenoise
+ public Denoise SelectedDenoise
{
get
{
- return EnumHelper<Denoise>.GetDisplay(this.selectedDenoise);
+ return this.CurrentTask.Denoise;
}
set
{
- this.selectedDenoise = EnumHelper<Denoise>.GetValue(value);
- this.NotifyOfPropertyChange("SelectedDenoise");
+ this.CurrentTask.Denoise = value;
+ this.NotifyOfPropertyChange(() => this.SelectedDenoise);
// Show / Hide the Custom Control
- this.ShowDenoiseCustom = this.selectedDenoise == Denoise.Custom;
- this.NotifyOfPropertyChange("ShowDenoiseCustom");
+ this.ShowDenoiseCustom = this.CurrentTask.Denoise == Denoise.Custom;
+ this.NotifyOfPropertyChange(() => this.ShowDenoiseCustom);
}
}
/// <summary>
/// Gets or sets SelectedDetelecine.
/// </summary>
- public string SelectedDetelecine
+ public Detelecine SelectedDetelecine
{
get
{
- return EnumHelper<Detelecine>.GetDisplay(this.selectedDetelecine);
+ return this.CurrentTask.Detelecine;
}
set
{
- this.selectedDetelecine = EnumHelper<Detelecine>.GetValue(value);
- this.NotifyOfPropertyChange("SelectedDetelecine");
+ this.CurrentTask.Detelecine = value;
+ this.NotifyOfPropertyChange(() => this.SelectedDetelecine);
// Show / Hide the Custom Control
- this.ShowDetelecineCustom = this.selectedDetelecine == Detelecine.Custom;
- this.NotifyOfPropertyChange("ShowDetelecineCustom");
+ this.ShowDetelecineCustom = this.CurrentTask.Detelecine == Detelecine.Custom;
+ this.NotifyOfPropertyChange(() => this.ShowDetelecineCustom);
}
}
@@ -292,72 +325,53 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public bool ShowDetelecineCustom { get; set; }
- /// <summary>
- /// Gets or sets CustomDeinterlace.
- /// </summary>
- public string CustomDeinterlace
- {
- get
- {
- return this.customDeinterlace;
- }
- set
- {
- this.customDeinterlace = value;
- this.NotifyOfPropertyChange(() => this.CustomDeinterlace);
- }
- }
+ #endregion
- /// <summary>
- /// Gets or sets CustomDecomb.
- /// </summary>
- public string CustomDecomb
- {
- get
- {
- return this.customDecomb;
- }
- set
- {
- this.customDecomb = value;
- this.NotifyOfPropertyChange(() => this.CustomDecomb);
- }
- }
+ #region Implemented Interfaces
- /// <summary>
- /// Gets or sets CustomDetelecine.
- /// </summary>
- public string CustomDetelecine
- {
- get
- {
- return this.customDetelecine;
- }
- set
- {
- this.customDetelecine = value;
- this.NotifyOfPropertyChange(() => this.CustomDetelecine);
- }
- }
+ #region ITabInterface
/// <summary>
- /// Gets or sets CustomDenoise.
+ /// Setup this tab for the specified preset.
/// </summary>
- public string CustomDenoise
+ /// <param name="preset">
+ /// The preset.
+ /// </param>
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ public void SetPreset(Preset preset, EncodeTask task)
{
- get
+ this.CurrentTask = task;
+
+ if (preset != null && preset.UsePictureFilters)
{
- return this.customDenoise;
+ // Properties
+ this.SelectedDenoise = preset.Task.Denoise;
+ this.SelectedDecomb = preset.Task.Decomb;
+ this.SelectedDeInterlace = preset.Task.Deinterlace;
+ this.SelectedDetelecine = preset.Task.Detelecine;
+ this.Grayscale = preset.Task.Grayscale;
+ this.DeblockValue = preset.Task.Deblock;
+
+ // Custom Values
+ this.CustomDecomb = preset.Task.CustomDecomb;
+ this.CustomDeinterlace = preset.Task.CustomDeinterlace;
+ this.CustomDetelecine = preset.Task.CustomDetelecine;
+ this.CustomDenoise = preset.Task.CustomDenoise;
}
- set
+ else
{
- this.customDenoise = value;
- this.NotifyOfPropertyChange(() => this.CustomDenoise);
+ // Default everything to off
+ this.SelectedDenoise = Denoise.Off;
+ this.SelectedDecomb = Decomb.Off;
+ this.SelectedDeInterlace = Deinterlace.Off;
+ this.SelectedDetelecine = Detelecine.Off;
+ this.Grayscale = false;
+ this.DeblockValue = 0;
}
}
- #endregion
-
/// <summary>
/// Setup this window for a new source
/// </summary>
@@ -372,32 +386,11 @@ namespace HandBrakeWPF.ViewModels /// </param>
public void SetSource(Title title, Preset preset, EncodeTask task)
{
+ this.CurrentTask = task;
}
- /// <summary>
- /// Setup this tab for the specified preset.
- /// </summary>
- /// <param name="preset">
- /// The preset.
- /// </param>
- public void SetPreset(Preset preset)
- {
- if (preset != null)
- {
- // Properties
- this.SelectedDenoise = EnumHelper<Denoise>.GetDisplay(preset.Task.Denoise);
- this.SelectedDecomb = EnumHelper<Decomb>.GetDisplay(preset.Task.Decomb);
- this.SelectedDeInterlace = EnumHelper<Deinterlace>.GetDisplay(preset.Task.Deinterlace);
- this.SelectedDetelecine = EnumHelper<Detelecine>.GetDisplay(preset.Task.Detelecine);
- this.Grayscale = preset.Task.Grayscale;
- this.DeblockValue = preset.Task.Deblock;
+ #endregion
- // Custom Values
- this.CustomDecomb = preset.Task.CustomDecomb;
- this.CustomDeinterlace = preset.Task.CustomDeinterlace;
- this.CustomDetelecine = preset.Task.CustomDetelecine;
- this.CustomDenoise = preset.Task.CustomDenoise;
- }
- }
+ #endregion
}
}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ITabInterface.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ITabInterface.cs index 6091b506a..b583fba86 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ITabInterface.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ITabInterface.cs @@ -37,6 +37,9 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// <param name="preset">
/// The preset.
/// </param>
- void SetPreset(Preset preset);
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ void SetPreset(Preset preset, EncodeTask task);
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index fcaf5aa02..28472343c 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -11,14 +11,11 @@ namespace HandBrakeWPF.ViewModels {
using System;
using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.ComponentModel;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows;
- using System.Windows.Data;
using Caliburn.Micro;
@@ -176,7 +173,6 @@ namespace HandBrakeWPF.ViewModels this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
this.Presets = this.presetService.Presets;
-
}
#region View Model Properties
@@ -278,13 +274,13 @@ namespace HandBrakeWPF.ViewModels if (this.SelectedPreset != null)
{
- this.PictureSettingsViewModel.SetPreset(this.SelectedPreset);
- this.VideoViewModel.SetPreset(this.SelectedPreset);
- this.FiltersViewModel.SetPreset(this.SelectedPreset);
- this.AudioViewModel.SetPreset(this.SelectedPreset);
- this.SubtitleViewModel.SetPreset(this.SelectedPreset);
- this.ChaptersViewModel.SetPreset(this.SelectedPreset);
- this.AdvancedViewModel.SetPreset(this.SelectedPreset);
+ this.PictureSettingsViewModel.SetPreset(this.SelectedPreset, this.CurrentTask);
+ this.VideoViewModel.SetPreset(this.SelectedPreset, this.CurrentTask);
+ this.FiltersViewModel.SetPreset(this.SelectedPreset, this.CurrentTask);
+ this.AudioViewModel.SetPreset(this.SelectedPreset, this.CurrentTask);
+ this.SubtitleViewModel.SetPreset(this.SelectedPreset, this.CurrentTask);
+ this.ChaptersViewModel.SetPreset(this.SelectedPreset, this.CurrentTask);
+ this.AdvancedViewModel.SetPreset(this.SelectedPreset, this.CurrentTask);
}
this.NotifyOfPropertyChange(() => this.SelectedPreset);
@@ -842,6 +838,18 @@ namespace HandBrakeWPF.ViewModels Application.Current.Shutdown();
}
+ /// <summary>
+ /// DEBUG: Show CLI Query for settings+6
+ /// </summary>
+ public void ShowCliQuery()
+ {
+ this.errorService.ShowMessageBox(
+ QueryGeneratorUtility.GenerateQuery(this.CurrentTask),
+ "CLI Query",
+ MessageBoxButton.OK,
+ MessageBoxImage.Information);
+ }
+
#endregion
#region Main Window Public Methods
diff --git a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs index 309bc6df3..7e955e541 100644 --- a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs @@ -35,8 +35,7 @@ namespace HandBrakeWPF.ViewModels * Handle changes in cropping affecting the resolution calcuation.
*
*/
-
- #region Backing Fields
+ #region Constants and Fields
/// <summary>
/// The display size.
@@ -44,9 +43,9 @@ namespace HandBrakeWPF.ViewModels private string displaySize;
/// <summary>
- /// The source info.
+ /// Backing field for for height control enabled
/// </summary>
- private string sourceInfo;
+ private bool heightControlEnabled = true;
/// <summary>
/// Backing field for show custom anamorphic controls
@@ -54,30 +53,30 @@ namespace HandBrakeWPF.ViewModels private bool showCustomAnamorphicControls;
/// <summary>
- /// Backing field for for height control enabled
+ /// The source aspect ratio.
/// </summary>
- private bool heightControlEnabled = true;
+ private double sourceAspectRatio;
/// <summary>
- /// Backing field for width control enabled.
+ /// The source info.
/// </summary>
- private bool widthControlEnabled = true;
-
- #endregion
+ private string sourceInfo;
- #region Source Information
+ /// <summary>
+ /// Source Par Values
+ /// </summary>
+ private Size sourceParValues;
/// <summary>
/// Source Resolution
/// </summary>
private Size sourceResolution;
- private double sourceAspectRatio;
-
/// <summary>
- /// Source Par Values
+ /// Backing field for width control enabled.
/// </summary>
- private Size sourceParValues;
+ private bool widthControlEnabled = true;
+
#endregion
#region Constructors and Destructors
@@ -100,12 +99,7 @@ namespace HandBrakeWPF.ViewModels #endregion
- #region Public Properties
-
- /// <summary>
- /// Gets or sets Task.
- /// </summary>
- public EncodeTask Task { get; set; }
+ #region Properties
/// <summary>
/// Gets AnamorphicModes.
@@ -127,6 +121,7 @@ namespace HandBrakeWPF.ViewModels {
return this.Task.Cropping.Bottom;
}
+
set
{
this.Task.Cropping.Bottom = this.CorrectForModulus(this.Task.Cropping.Bottom, value);
@@ -143,6 +138,7 @@ namespace HandBrakeWPF.ViewModels {
return this.Task.Cropping.Left;
}
+
set
{
this.Task.Cropping.Left = this.CorrectForModulus(this.Task.Cropping.Left, value);
@@ -159,6 +155,7 @@ namespace HandBrakeWPF.ViewModels {
return this.Task.Cropping.Right;
}
+
set
{
this.Task.Cropping.Right = this.CorrectForModulus(this.Task.Cropping.Right, value);
@@ -192,6 +189,7 @@ namespace HandBrakeWPF.ViewModels {
return this.displaySize;
}
+
set
{
this.displaySize = value;
@@ -206,8 +204,11 @@ namespace HandBrakeWPF.ViewModels {
get
{
- return this.Task.DisplayWidth.HasValue ? int.Parse(Math.Round(this.Task.DisplayWidth.Value, 0).ToString()) : 0;
+ return this.Task.DisplayWidth.HasValue
+ ? int.Parse(Math.Round(this.Task.DisplayWidth.Value, 0).ToString())
+ : 0;
}
+
set
{
this.Task.DisplayWidth = value;
@@ -217,6 +218,41 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
+ /// Gets or sets Height.
+ /// </summary>
+ public int Height
+ {
+ get
+ {
+ return this.Task.Height.HasValue ? this.Task.Height.Value : 0;
+ }
+
+ set
+ {
+ this.Task.Height = value;
+ this.HeightAdjust();
+ this.NotifyOfPropertyChange(() => this.Height);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether HeightControlEnabled.
+ /// </summary>
+ public bool HeightControlEnabled
+ {
+ get
+ {
+ return this.heightControlEnabled;
+ }
+
+ set
+ {
+ this.heightControlEnabled = value;
+ this.NotifyOfPropertyChange(() => this.HeightControlEnabled);
+ }
+ }
+
+ /// <summary>
/// Gets or sets a value indicating whether IsCustomCrop.
/// </summary>
public bool IsCustomCrop
@@ -225,6 +261,7 @@ namespace HandBrakeWPF.ViewModels {
return this.Task.HasCropping;
}
+
set
{
this.Task.HasCropping = value;
@@ -241,6 +278,7 @@ namespace HandBrakeWPF.ViewModels {
return this.Task.KeepDisplayAspect;
}
+
set
{
this.Task.KeepDisplayAspect = value;
@@ -269,6 +307,7 @@ namespace HandBrakeWPF.ViewModels {
return this.Task.PixelAspectY;
}
+
set
{
this.Task.PixelAspectY = value;
@@ -286,6 +325,7 @@ namespace HandBrakeWPF.ViewModels {
return this.Task.PixelAspectX;
}
+
set
{
this.Task.PixelAspectX = value;
@@ -303,6 +343,7 @@ namespace HandBrakeWPF.ViewModels {
return this.Task.Anamorphic;
}
+
set
{
this.Task.Anamorphic = value;
@@ -320,6 +361,7 @@ namespace HandBrakeWPF.ViewModels {
return this.Task.Modulus;
}
+
set
{
this.Task.Modulus = value;
@@ -329,153 +371,113 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
- /// Gets or sets SourceInfo.
+ /// Gets or sets a value indicating whether ShowCustomAnamorphicControls.
/// </summary>
- public string SourceInfo
+ public bool ShowCustomAnamorphicControls
{
get
{
- return this.sourceInfo;
+ return this.showCustomAnamorphicControls;
}
+
set
{
- this.sourceInfo = value;
- this.NotifyOfPropertyChange(() => this.SourceInfo);
+ this.showCustomAnamorphicControls = value;
+ this.NotifyOfPropertyChange(() => this.ShowCustomAnamorphicControls);
}
}
/// <summary>
- /// Gets or sets Width.
+ /// Gets or sets SourceInfo.
/// </summary>
- public int Width
+ public string SourceInfo
{
get
{
- return this.Task.Width.HasValue ? this.Task.Width.Value : 0;
+ return this.sourceInfo;
}
set
{
- this.Task.Width = value;
- this.WidthAdjust();
- this.NotifyOfPropertyChange(() => this.Width);
+ this.sourceInfo = value;
+ this.NotifyOfPropertyChange(() => this.SourceInfo);
}
}
/// <summary>
- /// Gets or sets Height.
+ /// Gets or sets Task.
/// </summary>
- public int Height
- {
- get
- {
- return this.Task.Height.HasValue ? this.Task.Height.Value : 0;
- }
- set
- {
- this.Task.Height = value;
- this.HeightAdjust();
- this.NotifyOfPropertyChange(() => this.Height);
- }
- }
+ public EncodeTask Task { get; set; }
/// <summary>
- /// Gets or sets a value indicating whether ShowCustomAnamorphicControls.
+ /// Gets or sets Width.
/// </summary>
- public bool ShowCustomAnamorphicControls
+ public int Width
{
get
{
- return this.showCustomAnamorphicControls;
+ return this.Task.Width.HasValue ? this.Task.Width.Value : 0;
}
+
set
{
- this.showCustomAnamorphicControls = value;
- this.NotifyOfPropertyChange(() => ShowCustomAnamorphicControls);
+ this.Task.Width = value;
+ this.WidthAdjust();
+ this.NotifyOfPropertyChange(() => this.Width);
}
}
/// <summary>
- /// Gets or sets a value indicating whether HeightControlEnabled.
+ /// Gets or sets a value indicating whether WidthControlEnabled.
/// </summary>
- public bool HeightControlEnabled
+ public bool WidthControlEnabled
{
get
{
- return this.heightControlEnabled;
+ return this.widthControlEnabled;
}
+
set
{
- this.heightControlEnabled = value;
- this.NotifyOfPropertyChange(() => HeightControlEnabled);
+ this.widthControlEnabled = value;
+ this.NotifyOfPropertyChange(() => this.WidthControlEnabled);
}
}
/// <summary>
- /// Gets or sets a value indicating whether WidthControlEnabled.
+ /// Gets SourceAspect.
/// </summary>
- public bool WidthControlEnabled
+ private Size SourceAspect
{
get
{
- return this.widthControlEnabled;
- }
- set
- {
- this.widthControlEnabled = value;
- this.NotifyOfPropertyChange(() => WidthControlEnabled);
+ // display aspect = (width * par_width) / (height * par_height)
+ return new Size(
+ (this.sourceParValues.Width * this.sourceResolution.Width),
+ (this.sourceParValues.Height * this.sourceResolution.Height));
}
}
#endregion
- #region Public Methods
+ #region Implemented Interfaces
+
+ #region ITabInterface
/// <summary>
- /// Setup this window for a new source
+ /// Setup this tab for the specified preset.
/// </summary>
- /// <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)
+ public void SetPreset(Preset preset, EncodeTask task)
{
- if (title != null)
- {
- // Set cached info
- this.sourceAspectRatio = title.AspectRatio;
- this.sourceParValues = title.ParVal;
- this.sourceResolution = title.Resolution;
-
- // Set Screen Controls
- this.SourceInfo = string.Format("{0}x{1}, Aspect Ratio: {2:0.00}", title.Resolution.Width, title.Resolution.Height, title.AspectRatio);
- this.CropTop = title.AutoCropDimensions.Top;
- this.CropBottom = title.AutoCropDimensions.Bottom;
- this.CropLeft = title.AutoCropDimensions.Left;
- this.CropRight = title.AutoCropDimensions.Right;
+ this.Task = task;
- // TODO handle preset max width / height
- this.Width = title.Resolution.Width;
- this.Height = title.Resolution.Height;
- this.MaintainAspectRatio = true;
- }
- }
-
- /// <summary>
- /// Setup this tab for the specified preset.
- /// </summary>
- /// <param name="preset">
- /// The preset.
- /// </param>
- public void SetPreset(Preset preset)
- {
// TODO: These all need to be handled correctly.
-
if (preset.PictureSettingsMode == PresetPictureSettingsMode.SourceMaximum)
{
this.Task.MaxWidth = preset.Task.MaxWidth;
@@ -489,7 +491,7 @@ namespace HandBrakeWPF.ViewModels this.Task.Height = preset.Task.Height ?? 0;
}
- if (Task.Anamorphic == Anamorphic.Custom)
+ if (this.Task.Anamorphic == Anamorphic.Custom)
{
this.Task.DisplayWidth = preset.Task.DisplayWidth ?? 0;
this.Task.PixelAspectX = preset.Task.PixelAspectX;
@@ -508,104 +510,52 @@ namespace HandBrakeWPF.ViewModels this.Task.Cropping = preset.Task.Cropping;
}
}
- #endregion
/// <summary>
- /// Adjust other values after the user has altered the width
+ /// Setup this window for a new source
/// </summary>
- private void WidthAdjust()
+ /// <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)
{
- if (this.Width > this.sourceResolution.Width)
- {
- this.Task.Width = this.sourceResolution.Width;
- this.NotifyOfPropertyChange(() => this.Task.Width);
- }
-
- switch (SelectedAnamorphicMode)
+ this.Task = task;
+ if (title != null)
{
- case Anamorphic.None:
- if (this.MaintainAspectRatio)
- {
- double crop_width = this.sourceResolution.Width - this.CropLeft - this.CropRight;
- double crop_height = this.sourceResolution.Height - this.CropTop - this.CropBottom;
-
- if (SourceAspect.Width == 0 && SourceAspect.Height == 0)
- break;
-
- double newHeight = ((double)this.Width * this.sourceResolution.Width * SourceAspect.Height * crop_height) /
- (this.sourceResolution.Height * SourceAspect.Width * crop_width);
+ // Set cached info
+ this.sourceAspectRatio = title.AspectRatio;
+ this.sourceParValues = title.ParVal;
+ this.sourceResolution = title.Resolution;
- this.Task.Height = (int)Math.Round(GetModulusValue(newHeight), 0);
- this.NotifyOfPropertyChange("Height");
- }
- break;
- case Anamorphic.Strict:
- this.Task.Width = 0;
- this.Task.Height = 0;
+ // Set Screen Controls
+ this.SourceInfo = string.Format(
+ "{0}x{1}, Aspect Ratio: {2:0.00}",
+ title.Resolution.Width,
+ title.Resolution.Height,
+ title.AspectRatio);
+ this.CropTop = title.AutoCropDimensions.Top;
+ this.CropBottom = title.AutoCropDimensions.Bottom;
+ this.CropLeft = title.AutoCropDimensions.Left;
+ this.CropRight = title.AutoCropDimensions.Right;
- this.NotifyOfPropertyChange(() => this.Task.Width);
- this.NotifyOfPropertyChange(() => this.Task.Height);
- this.SetDisplaySize();
- break;
- case Anamorphic.Loose:
- this.Task.Height = 0;
- this.NotifyOfPropertyChange(() => this.Task.Width);
- this.NotifyOfPropertyChange(() => this.Task.Height);
- this.SetDisplaySize();
- break;
- case Anamorphic.Custom:
- this.SetDisplaySize();
- break;
+ // TODO handle preset max width / height
+ this.Width = title.Resolution.Width;
+ this.Height = title.Resolution.Height;
+ this.MaintainAspectRatio = true;
}
}
- /// <summary>
- /// Adjust other values after the user has altered the height
- /// </summary>
- private void HeightAdjust()
- {
- if (this.Height > this.sourceResolution.Height)
- {
- this.Task.Height = this.sourceResolution.Height;
- this.NotifyOfPropertyChange(() => this.Task.Height);
- }
-
- switch (SelectedAnamorphicMode)
- {
- case Anamorphic.None:
- if (this.MaintainAspectRatio)
- {
- double crop_width = this.sourceResolution.Width - this.CropLeft - this.CropRight;
- double crop_height = this.sourceResolution.Height - this.CropTop - this.CropBottom;
-
- double new_width = ((double)this.Height * this.sourceResolution.Height * SourceAspect.Width * crop_width) /
- (this.sourceResolution.Width * SourceAspect.Height * crop_height);
+ #endregion
- this.Task.Width = (int)Math.Round(GetModulusValue(new_width), 0);
- this.NotifyOfPropertyChange(() => this.Task.Width);
- }
- break;
- case Anamorphic.Custom:
- this.SetDisplaySize();
- break;
- }
- }
+ #endregion
- /// <summary>
- /// Adjust other values after the user has altered one of the custom anamorphic settings
- /// </summary>
- private void CustomAnamorphicAdjust()
- {
- this.SetDisplaySize();
- }
-
- /// <summary>
- /// Adjust other values after the user has altered the modulus
- /// </summary>
- private void ModulusAdjust()
- {
- this.WidthAdjust();
- }
+ #region Methods
/// <summary>
/// Adjust other values after the user has altered the anamorphic.
@@ -614,17 +564,18 @@ namespace HandBrakeWPF.ViewModels {
this.DisplaySize = this.sourceResolution.IsEmpty
? "No Title Selected"
- : string.Format("{0}x{1}",
- this.CalculateAnamorphicSizes().Width,
+ : string.Format(
+ "{0}x{1}",
+ this.CalculateAnamorphicSizes().Width,
this.CalculateAnamorphicSizes().Height);
- switch (SelectedAnamorphicMode)
+ switch (this.SelectedAnamorphicMode)
{
case Anamorphic.None:
this.WidthControlEnabled = true;
this.HeightControlEnabled = true;
this.ShowCustomAnamorphicControls = false;
- this.Width = sourceResolution.Width;
+ this.Width = this.sourceResolution.Width;
this.SetDisplaySize();
break;
case Anamorphic.Strict:
@@ -634,8 +585,8 @@ namespace HandBrakeWPF.ViewModels this.Width = 0;
this.Height = 0;
- this.NotifyOfPropertyChange(() => Width);
- this.NotifyOfPropertyChange(() => Height);
+ this.NotifyOfPropertyChange(() => this.Width);
+ this.NotifyOfPropertyChange(() => this.Height);
this.SetDisplaySize();
break;
@@ -646,8 +597,8 @@ namespace HandBrakeWPF.ViewModels this.Width = this.sourceResolution.Width;
this.Height = 0;
- this.NotifyOfPropertyChange(() => Width);
- this.NotifyOfPropertyChange(() => Height);
+ this.NotifyOfPropertyChange(() => this.Width);
+ this.NotifyOfPropertyChange(() => this.Height);
this.SetDisplaySize();
break;
@@ -658,15 +609,15 @@ namespace HandBrakeWPF.ViewModels this.Width = this.sourceResolution.Width;
this.Height = 0;
- this.NotifyOfPropertyChange(() => Width);
- this.NotifyOfPropertyChange(() => Height);
+ this.NotifyOfPropertyChange(() => this.Width);
+ this.NotifyOfPropertyChange(() => this.Height);
this.DisplayWidth = this.CalculateAnamorphicSizes().Width;
this.ParWidth = this.sourceParValues.Width;
this.ParHeight = this.sourceParValues.Height;
- this.NotifyOfPropertyChange(() => ParHeight);
- this.NotifyOfPropertyChange(() => ParWidth);
- this.NotifyOfPropertyChange(() => DisplayWidth);
+ this.NotifyOfPropertyChange(() => this.ParHeight);
+ this.NotifyOfPropertyChange(() => this.ParWidth);
+ this.NotifyOfPropertyChange(() => this.DisplayWidth);
this.SetDisplaySize();
break;
@@ -674,31 +625,6 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
- /// Gets SourceAspect.
- /// </summary>
- private Size SourceAspect
- {
- get
- {
- // display aspect = (width * par_width) / (height * par_height)
- return new Size((this.sourceParValues.Width * this.sourceResolution.Width),
- (this.sourceParValues.Height * this.sourceResolution.Height));
- }
- }
-
- /// <summary>
- /// Set the display size text
- /// </summary>
- private void SetDisplaySize()
- {
- this.DisplaySize = this.sourceResolution.IsEmpty
- ? "No Title Selected"
- : string.Format("{0}x{1}",
- this.CalculateAnamorphicSizes().Width,
- this.CalculateAnamorphicSizes().Height);
- }
-
- /// <summary>
/// Calculate the Anamorphic Resolution for the selected title.
/// </summary>
/// <returns>
@@ -730,6 +656,7 @@ namespace HandBrakeWPF.ViewModels {
default:
case Anamorphic.Strict:
+
/* Strict anamorphic */
double dispWidth = ((double)croppedWidth * this.sourceParValues.Width / this.sourceParValues.Height);
dispWidth = Math.Round(dispWidth, 0);
@@ -737,13 +664,14 @@ namespace HandBrakeWPF.ViewModels return output;
case Anamorphic.Loose:
+
/* "Loose" anamorphic.
- Uses mod16-compliant dimensions,
- Allows users to set the width
*/
- calcWidth = GetModulusValue(this.Width); /* Time to get picture width that divide cleanly.*/
+ calcWidth = this.GetModulusValue(this.Width); /* Time to get picture width that divide cleanly.*/
calcHeight = (calcWidth / storageAspect) + 0.5;
- calcHeight = GetModulusValue(calcHeight); /* Time to get picture height that divide cleanly.*/
+ calcHeight = this.GetModulusValue(calcHeight); /* Time to get picture height that divide cleanly.*/
/* The film AR is the source's display width / cropped source height.
The output display width is the output height * film AR.
@@ -753,26 +681,62 @@ namespace HandBrakeWPF.ViewModels double disWidthLoose = (calcWidth * pixelAspectWidth / pixelAspectHeight);
if (double.IsNaN(disWidthLoose))
+ {
disWidthLoose = 0;
+ }
return new Size((int)disWidthLoose, (int)calcHeight);
case Anamorphic.Custom:
+
// Get the User Interface Values
double UIdisplayWidth;
double.TryParse(this.DisplayWidth.ToString(), out UIdisplayWidth);
/* Anamorphic 3: Power User Jamboree - Set everything based on specified values */
- calcHeight = GetModulusValue(this.Height);
+ calcHeight = this.GetModulusValue(this.Height);
if (this.MaintainAspectRatio)
+ {
return new Size((int)Math.Truncate(UIdisplayWidth), (int)calcHeight);
+ }
return new Size((int)Math.Truncate(UIdisplayWidth), (int)calcHeight);
}
}
/// <summary>
+ /// Correct the new value so that the result of the modulus of that value is 0
+ /// </summary>
+ /// <param name="oldValue">
+ /// The old value.
+ /// </param>
+ /// <param name="newValue">
+ /// The new value.
+ /// </param>
+ /// <returns>
+ /// The Value corrected so that for a given modulus the result is 0
+ /// </returns>
+ private int CorrectForModulus(int oldValue, int newValue)
+ {
+ int remainder = newValue % 2;
+ if (remainder == 0)
+ {
+ return newValue;
+ }
+
+ return newValue > oldValue ? newValue + remainder : newValue - remainder;
+ }
+
+ /// <summary>
+ /// Adjust other values after the user has altered one of the custom anamorphic settings
+ /// </summary>
+ private void CustomAnamorphicAdjust()
+ {
+ this.SetDisplaySize();
+ }
+
+ /// <summary>
/// For a given value, correct so that it matches the users currently selected modulus value
/// </summary>
/// <param name="value">
@@ -791,32 +755,123 @@ namespace HandBrakeWPF.ViewModels double remainder = value % this.SelectedModulus.Value;
if (remainder == 0)
+ {
return value;
+ }
- return remainder >= ((double)this.SelectedModulus.Value / 2) ? value + (this.SelectedModulus.Value - remainder) : value - remainder;
+ return remainder >= ((double)this.SelectedModulus.Value / 2)
+ ? value + (this.SelectedModulus.Value - remainder)
+ : value - remainder;
}
/// <summary>
- /// Correct the new value so that the result of the modulus of that value is 0
+ /// Adjust other values after the user has altered the height
/// </summary>
- /// <param name="oldValue">
- /// The old value.
- /// </param>
- /// <param name="newValue">
- /// The new value.
- /// </param>
- /// <returns>
- /// The Value corrected so that for a given modulus the result is 0
- /// </returns>
- private int CorrectForModulus(int oldValue, int newValue)
+ private void HeightAdjust()
{
- int remainder = newValue % 2;
- if (remainder == 0)
+ if (this.Height > this.sourceResolution.Height)
{
- return newValue;
+ this.Task.Height = this.sourceResolution.Height;
+ this.NotifyOfPropertyChange(() => this.Task.Height);
}
- return newValue > oldValue ? newValue + remainder : newValue - remainder;
+ switch (this.SelectedAnamorphicMode)
+ {
+ case Anamorphic.None:
+ if (this.MaintainAspectRatio)
+ {
+ double crop_width = this.sourceResolution.Width - this.CropLeft - this.CropRight;
+ double crop_height = this.sourceResolution.Height - this.CropTop - this.CropBottom;
+
+ double new_width = ((double)this.Height * this.sourceResolution.Height * this.SourceAspect.Width *
+ crop_width) /
+ (this.sourceResolution.Width * this.SourceAspect.Height * crop_height);
+
+ this.Task.Width = (int)Math.Round(this.GetModulusValue(new_width), 0);
+ this.NotifyOfPropertyChange(() => this.Task.Width);
+ }
+
+ break;
+ case Anamorphic.Custom:
+ this.SetDisplaySize();
+ break;
+ }
+ }
+
+ /// <summary>
+ /// Adjust other values after the user has altered the modulus
+ /// </summary>
+ private void ModulusAdjust()
+ {
+ this.WidthAdjust();
}
+
+ /// <summary>
+ /// Set the display size text
+ /// </summary>
+ private void SetDisplaySize()
+ {
+ this.DisplaySize = this.sourceResolution.IsEmpty
+ ? "No Title Selected"
+ : string.Format(
+ "{0}x{1}",
+ this.CalculateAnamorphicSizes().Width,
+ this.CalculateAnamorphicSizes().Height);
+ }
+
+ /// <summary>
+ /// Adjust other values after the user has altered the width
+ /// </summary>
+ private void WidthAdjust()
+ {
+ if (this.Width > this.sourceResolution.Width)
+ {
+ this.Task.Width = this.sourceResolution.Width;
+ this.NotifyOfPropertyChange(() => this.Task.Width);
+ }
+
+ switch (this.SelectedAnamorphicMode)
+ {
+ case Anamorphic.None:
+ if (this.MaintainAspectRatio)
+ {
+ double crop_width = this.sourceResolution.Width - this.CropLeft - this.CropRight;
+ double crop_height = this.sourceResolution.Height - this.CropTop - this.CropBottom;
+
+ if (this.SourceAspect.Width == 0 && this.SourceAspect.Height == 0)
+ {
+ break;
+ }
+
+ double newHeight = ((double)this.Width * this.sourceResolution.Width * this.SourceAspect.Height *
+ crop_height) /
+ (this.sourceResolution.Height * this.SourceAspect.Width * crop_width);
+
+ this.Task.Height = (int)Math.Round(this.GetModulusValue(newHeight), 0);
+ this.NotifyOfPropertyChange("Height");
+ }
+
+ break;
+ case Anamorphic.Strict:
+ this.Task.Width = 0;
+ this.Task.Height = 0;
+
+ this.NotifyOfPropertyChange(() => this.Task.Width);
+ this.NotifyOfPropertyChange(() => this.Task.Height);
+ this.SetDisplaySize();
+ break;
+ case Anamorphic.Loose:
+ this.Task.Height = 0;
+ this.NotifyOfPropertyChange(() => this.Task.Width);
+ this.NotifyOfPropertyChange(() => this.Task.Height);
+ this.SetDisplaySize();
+ break;
+ case Anamorphic.Custom:
+ this.SetDisplaySize();
+ break;
+ }
+ }
+
+ #endregion
}
}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs index cc882b160..9595855bc 100644 --- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs @@ -10,7 +10,6 @@ namespace HandBrakeWPF.ViewModels
{
using System.Collections.Generic;
- using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel.Composition;
using System.Linq;
@@ -36,11 +35,6 @@ namespace HandBrakeWPF.ViewModels #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;
@@ -60,32 +54,20 @@ namespace HandBrakeWPF.ViewModels /// </param>
public SubtitlesViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
{
- this.SubtitleTracks = new ObservableCollection<SubtitleTrack>();
+ this.Task = new EncodeTask();
- Langauges = LanguageUtilities.MapLanguages().Keys;
- CharacterCodes = CharCodesUtilities.GetCharacterCodes();
+ this.Langauges = LanguageUtilities.MapLanguages().Keys;
+ this.CharacterCodes = CharCodesUtilities.GetCharacterCodes();
}
#endregion
- #region Public Properties
+ #region Properties
/// <summary>
- /// Gets or sets State.
+ /// Gets or sets CharacterCodes.
/// </summary>
- public ObservableCollection<SubtitleTrack> SubtitleTracks
- {
- get
- {
- return this.subtitleTracks;
- }
-
- set
- {
- this.subtitleTracks = value;
- this.NotifyOfPropertyChange(() => this.SubtitleTracks);
- }
- }
+ public IEnumerable<string> CharacterCodes { get; set; }
/// <summary>
/// Gets or sets Langauges.
@@ -93,11 +75,6 @@ namespace HandBrakeWPF.ViewModels 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
@@ -106,13 +83,19 @@ namespace HandBrakeWPF.ViewModels {
return this.sourceTracks;
}
+
set
{
this.sourceTracks = value;
- this.NotifyOfPropertyChange(() => SourceTracks);
+ this.NotifyOfPropertyChange(() => this.SourceTracks);
}
}
+ /// <summary>
+ /// Gets or sets Task.
+ /// </summary>
+ public EncodeTask Task { get; set; }
+
#endregion
#region Public Methods
@@ -126,11 +109,46 @@ 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()
{
- VistaOpenFileDialog dialog = new VistaOpenFileDialog { Filter = "SRT files (*.srt)|*.srt", CheckFileExists = true, Multiselect = true };
+ VistaOpenFileDialog dialog = new VistaOpenFileDialog
+ {
+ Filter = "SRT files (*.srt)|*.srt", CheckFileExists = true, Multiselect = true
+ };
dialog.ShowDialog();
@@ -138,13 +156,13 @@ namespace HandBrakeWPF.ViewModels {
SubtitleTrack track = new SubtitleTrack
{
- SrtFileName = srtFile,
- SrtOffset = 0,
- SrtCharCode = "UTF-8",
- SrtLang = "English",
+ SrtFileName = srtFile,
+ SrtOffset = 0,
+ SrtCharCode = "UTF-8",
+ SrtLang = "English",
SubtitleType = SubtitleType.SRT
};
- this.SubtitleTracks.Add(track);
+ this.Task.SubtitleTracks.Add(track);
}
}
@@ -156,75 +174,56 @@ namespace HandBrakeWPF.ViewModels /// </param>
public void Remove(SubtitleTrack track)
{
- this.SubtitleTracks.Remove(track);
+ this.Task.SubtitleTracks.Remove(track);
}
+ #endregion
+
+ #region Implemented Interfaces
+
+ #region ITabInterface
+
/// <summary>
- /// Setup this window for a new source
+ /// Setup this tab for the specified preset.
/// </summary>
- /// <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)
+ public void SetPreset(Preset preset, EncodeTask task)
{
- this.SourceTracks = title.Subtitles;
- this.SubtitleTracks = task.SubtitleTracks;
-
- this.AutomaticSubtitleSelection();
+ this.Task = task;
+ this.NotifyOfPropertyChange(() => this.Task);
}
/// <summary>
- /// Setup this tab for the specified 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)
- {
- // We don't currently support subtitles within presets.
- }
-
- /// <summary>
- /// Automatic Subtitle Selection based on user preferences.
- /// </summary>
- public void AutomaticSubtitleSelection()
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ public void SetSource(Title title, Preset preset, EncodeTask task)
{
- this.SubtitleTracks.Clear();
-
- // New DUB Settings
- int mode = 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;
- }
+ this.SourceTracks = title.Subtitles;
+ this.Task = task;
+ this.NotifyOfPropertyChange(() => this.Task);
- // Add all closed captions if enabled.
- this.AddAllClosedCaptions();
+ this.AutomaticSubtitleSelection();
}
#endregion
- #region Private Methods
+ #endregion
+
+ #region Methods
/// <summary>
/// Add a subtitle track.
@@ -241,20 +240,36 @@ namespace HandBrakeWPF.ViewModels {
if (this.SourceTracks != null)
{
- string preferred = UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguageForSubtitles);
+ string preferred =
+ this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguageForSubtitles);
- Subtitle source = subtitle ?? (this.SourceTracks.FirstOrDefault(l => l.Language == preferred) ??
- this.SourceTracks.FirstOrDefault());
+ Subtitle source = subtitle ??
+ (this.SourceTracks.FirstOrDefault(l => l.Language == preferred) ??
+ this.SourceTracks.FirstOrDefault());
if (source != null)
{
SubtitleTrack track = new SubtitleTrack
- {
- SubtitleType = SubtitleType.VobSub,
- SourceTrack = source,
- };
+ {
+ SubtitleType = SubtitleType.VobSub, SourceTrack = source,
+ };
- this.SubtitleTracks.Add(track);
+ this.Task.SubtitleTracks.Add(track);
+ }
+ }
+ }
+
+ /// <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);
}
}
}
@@ -276,9 +291,12 @@ namespace HandBrakeWPF.ViewModels private void AddAllRemainingForSelectedLanguages()
{
// Get a list of subtitle tracks that match the users lanaguages
- StringCollection userSelectedLanguages = UserSettingService.GetUserSetting<StringCollection>(UserSettingConstants.SelectedLanguages);
- userSelectedLanguages.Add(UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguageForSubtitles));
- List<Subtitle> availableTracks = this.SourceTracks.Where(subtitle => userSelectedLanguages.Contains(subtitle.Language)).ToList();
+ 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))
{
@@ -294,8 +312,8 @@ namespace HandBrakeWPF.ViewModels /// </param>
private void AddForPreferredLanaguages(bool firstOnly)
{
- string preferred = UserSettingService.GetUserSetting<string>(
- UserSettingConstants.NativeLanguageForSubtitles);
+ string preferred =
+ this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguageForSubtitles);
foreach (Subtitle subtitle in this.SourceTitlesSubset(null))
{
@@ -311,20 +329,6 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
- /// Add all closed captions not already on the list.
- /// </summary>
- private void AddAllClosedCaptions()
- {
- if (UserSettingService.GetUserSetting<bool>(UserSettingConstants.UseClosedCaption))
- {
- foreach (Subtitle subtitle in this.SourceTitlesSubset(null).Where(s => s.SubtitleType == SubtitleType.CC))
- {
- this.Add(subtitle);
- }
- }
- }
-
- /// <summary>
/// Gets a list of Source subtitle tracks that are not currently used.
/// </summary>
/// <param name="subtitles">
@@ -335,8 +339,11 @@ namespace HandBrakeWPF.ViewModels /// </returns>
private IEnumerable<Subtitle> SourceTitlesSubset(IEnumerable<Subtitle> subtitles)
{
- return subtitles != null ? subtitles.Where(subtitle => !this.SubtitleTracks.Any(track => track.SourceTrack == subtitle)).ToList()
- : this.SourceTracks.Where(subtitle => !this.SubtitleTracks.Any(track => track.SourceTrack == subtitle)).ToList();
+ 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();
}
#endregion
diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs index 81b1ec6eb..8fa221b21 100644 --- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs @@ -396,8 +396,12 @@ namespace HandBrakeWPF.ViewModels /// <param name="preset">
/// The preset.
/// </param>
- public void SetPreset(Preset preset)
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ public void SetPreset(Preset preset, EncodeTask task)
{
+ this.Task = task;
if (preset == null || preset.Task == null)
{
return;
diff --git a/win/CS/HandBrakeWPF/Views/AudioView.xaml b/win/CS/HandBrakeWPF/Views/AudioView.xaml index 710cdd827..d94f25738 100644 --- a/win/CS/HandBrakeWPF/Views/AudioView.xaml +++ b/win/CS/HandBrakeWPF/Views/AudioView.xaml @@ -29,7 +29,7 @@ <Button Content="Add Track" cal:Message.Attach="[Event Click] = [Action Add]" Grid.Column="0" Width="75" Margin="0,0,10,0" />
</Grid>
- <ListBox Grid.Row="2" ItemsSource="{Binding AudioTracks}"
+ <ListBox Grid.Row="2" ItemsSource="{Binding Task.AudioTracks}"
SelectionMode="Extended" Background="LightGray" Margin="10,10,10,10"
dd:DragDrop.IsDragSource="True" dd:DragDrop.IsDropTarget="True"
dd:DragDrop.DropHandler="{Binding}">
diff --git a/win/CS/HandBrakeWPF/Views/ChaptersView.xaml b/win/CS/HandBrakeWPF/Views/ChaptersView.xaml index f3d6d1ed8..e7eb53f7d 100644 --- a/win/CS/HandBrakeWPF/Views/ChaptersView.xaml +++ b/win/CS/HandBrakeWPF/Views/ChaptersView.xaml @@ -25,7 +25,7 @@ <Button Content="Export" Name="export" Grid.Column="3" Width="75" cal:Message.Attach="[Event Click] = [Action Export]" />
</Grid>
- <DataGrid Grid.Row="2" Margin="10" ItemsSource="{Binding Chapters}"
+ <DataGrid Grid.Row="2" Margin="10" ItemsSource="{Binding Task.ChapterNames}"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch" AutoGenerateColumns="False"
CanUserSortColumns="False" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserResizeRows="False"
CanUserAddRows="False" CanUserDeleteRows="False">
diff --git a/win/CS/HandBrakeWPF/Views/FiltersView.xaml b/win/CS/HandBrakeWPF/Views/FiltersView.xaml index 53e75a6b0..a27deb617 100644 --- a/win/CS/HandBrakeWPF/Views/FiltersView.xaml +++ b/win/CS/HandBrakeWPF/Views/FiltersView.xaml @@ -6,6 +6,7 @@ xmlns:Converters="clr-namespace:HandBrakeWPF.Converters" mc:Ignorable="d" >
<UserControl.Resources>
<Converters:BooleanToVisibilityConverter x:Key="boolToVisConverter" />
+ <Converters:EnumComboConverter x:Key="boolComboConverter" />
</UserControl.Resources>
<Grid>
@@ -34,22 +35,26 @@ </Grid.ColumnDefinitions>
<TextBlock Text="Detelecine:" Grid.Row="0" Grid.Column="0" Margin="0,0,0,10" />
- <ComboBox Width="120" Grid.Row="0" ItemsSource="{Binding DetelecineOptions}" SelectedItem="{Binding SelectedDetelecine}" Grid.Column="1" Margin="0,0,0,10"/>
+ <ComboBox Width="120" Grid.Row="0" ItemsSource="{Binding DetelecineOptions, Converter={StaticResource boolComboConverter}}"
+ SelectedItem="{Binding SelectedDetelecine, Converter={StaticResource boolComboConverter}}" Grid.Column="1" Margin="0,0,0,10"/>
<TextBox Width="120" Grid.Row="0" Grid.Column="2" Margin="0,0,0,10" Text="{Binding CustomDetelecine}"
Visibility="{Binding ShowDetelecineCustom, Converter={StaticResource boolToVisConverter}}"/>
<TextBlock Text="Decomb:" Grid.Row="1" Grid.Column="0" Margin="0,0,0,10"/>
- <ComboBox Width="120" Grid.Row="1" ItemsSource="{Binding DecombOptions}" SelectedItem="{Binding SelectedDecomb}" Grid.Column="1" Margin="0,0,0,10"/>
+ <ComboBox Width="120" Grid.Row="1" ItemsSource="{Binding DecombOptions, Converter={StaticResource boolComboConverter}}"
+ SelectedItem="{Binding SelectedDecomb, Converter={StaticResource boolComboConverter}}" Grid.Column="1" Margin="0,0,0,10"/>
<TextBox Width="120" Grid.Row="1" Grid.Column="2" Margin="0,0,0,10" Text="{Binding CustomDecomb}"
Visibility="{Binding ShowDecombCustom, Converter={StaticResource boolToVisConverter}}" />
<TextBlock Text="Deinterlace:" Grid.Row="2" Grid.Column="0" Margin="0,0,0,10"/>
- <ComboBox Width="120" Grid.Row="2" ItemsSource="{Binding DeInterlaceOptions}" SelectedItem="{Binding SelectedDeInterlace}" Grid.Column="1" Margin="0,0,0,10"/>
+ <ComboBox Width="120" Grid.Row="2" ItemsSource="{Binding DeInterlaceOptions, Converter={StaticResource boolComboConverter}}"
+ SelectedItem="{Binding SelectedDeInterlace, Converter={StaticResource boolComboConverter}}" Grid.Column="1" Margin="0,0,0,10"/>
<TextBox Width="120" Grid.Row="2" Grid.Column="2" Margin="0,0,0,10" Text="{Binding CustomDeinterlace}"
Visibility="{Binding ShowDeinterlaceCustom, Converter={StaticResource boolToVisConverter}}" />
<TextBlock Text="Denoise:" Grid.Row="3" Grid.Column="0" Margin="0,0,0,10"/>
- <ComboBox Width="120" Grid.Row="3" ItemsSource="{Binding DenoiseOptions}" SelectedItem="{Binding SelectedDenoise}" Grid.Column="1" Margin="0,0,0,10"/>
+ <ComboBox Width="120" Grid.Row="3" ItemsSource="{Binding DenoiseOptions, Converter={StaticResource boolComboConverter}}"
+ SelectedItem="{Binding SelectedDenoise, Converter={StaticResource boolComboConverter}}" Grid.Column="1" Margin="0,0,0,10"/>
<TextBox Width="120" Grid.Row="3" Grid.Column="2" Margin="0,0,0,10" Text="{Binding CustomDenoise}"
Visibility="{Binding ShowDenoiseCustom, Converter={StaticResource boolToVisConverter}}" />
diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index 9a44920af..af9e27a7b 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -87,6 +87,10 @@ <Separator />
<MenuItem Header="About..." Micro:Message.Attach="[Event Click] = [Action OpenAboutApplication]" />
</MenuItem>
+
+ <MenuItem Header="Debug">
+ <MenuItem Header="Show CLI Equiv" Micro:Message.Attach="[Event Click] = [Action ShowCliQuery]" />
+ </MenuItem>
</Menu>
<!-- ToolBar -->
diff --git a/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml b/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml index 0492fcaed..71e48a7ba 100644 --- a/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml +++ b/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml @@ -25,7 +25,7 @@ <Button Content="Import SRT" Grid.Column="2" Width="75" cal:Message.Attach="[Event Click] = [Action Import]" />
</Grid>
- <ListBox Grid.Row="2" ItemsSource="{Binding SubtitleTracks}"
+ <ListBox Grid.Row="2" ItemsSource="{Binding Task.SubtitleTracks}"
SelectionMode="Extended" Background="LightGray" Margin="10,10,10,10"
dd:DragDrop.IsDragSource="True" dd:DragDrop.IsDropTarget="True"
dd:DragDrop.DropHandler="{Binding}">
|