summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs86
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs40
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs17
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs10
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/IAdvancedViewModel.cs19
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioViewModel.cs18
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/IChaptersViewModel.cs18
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/IFiltersViewModel.cs18
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/IPictureSettingsViewModel.cs18
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs18
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/ITabInterface.cs42
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/IVideoViewModel.cs18
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs50
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs230
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs13
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs11
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs263
17 files changed, 523 insertions, 366 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs
index 60a82d94e..5428e6bb7 100644
--- a/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs
@@ -9,13 +9,16 @@
namespace HandBrakeWPF.ViewModels
{
+ using System.Collections.Generic;
using System.ComponentModel.Composition;
using Caliburn.Micro;
+ using HandBrake.ApplicationServices.Functions;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Services.Interfaces;
+ using HandBrake.Interop.Model.Encoding;
using HandBrake.Interop.Model.Encoding.x264;
using HandBrakeWPF.ViewModels.Interfaces;
@@ -48,6 +51,11 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
private x264Tune x264Tune;
+ /// <summary>
+ /// Backing field used to display / hide the x264 options
+ /// </summary>
+ private bool displayX264Options;
+
#endregion
#region Constructors and Destructors
@@ -63,6 +71,13 @@ namespace HandBrakeWPF.ViewModels
/// </param>
public AdvancedViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
{
+ 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
@@ -133,6 +148,37 @@ namespace HandBrakeWPF.ViewModels
}
}
+ /// <summary>
+ /// Gets or sets X264Presets.
+ /// </summary>
+ public IEnumerable<x264Preset> X264Presets { get; set; }
+
+ /// <summary>
+ /// Gets or sets X264Profiles.
+ /// </summary>
+ public IEnumerable<x264Profile> X264Profiles { get; set; }
+
+ /// <summary>
+ /// Gets or sets X264Tunes.
+ /// </summary>
+ public IEnumerable<x264Tune> X264Tunes { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether DisplayX264Options.
+ /// </summary>
+ public bool DisplayX264Options
+ {
+ get
+ {
+ return this.displayX264Options;
+ }
+ set
+ {
+ this.displayX264Options = value;
+ this.NotifyOfPropertyChange(() => this.DisplayX264Options);
+ }
+ }
+
#endregion
#region Public Methods
@@ -157,6 +203,46 @@ namespace HandBrakeWPF.ViewModels
this.X264Tune = preset.Task.X264Tune;
}
+ /// <summary>
+ /// Setup this tab for the specified preset.
+ /// </summary>
+ /// <param name="preset">
+ /// The preset.
+ /// </param>
+ public void SetPreset(Preset preset)
+ {
+ if (preset != null && preset.Task != null)
+ {
+ this.Query = preset.Task.AdvancedEncoderOptions;
+ this.SetEncoder(preset.Task.VideoEncoder);
+
+ this.X264Preset = preset.Task.x264Preset;
+ this.X264Profile = preset.Task.x264Profile;
+ this.X264Tune = preset.Task.X264Tune;
+ }
+ }
+
+ /// <summary>
+ /// Set the currently selected encoder.
+ /// </summary>
+ /// <param name="encoder">
+ /// The Video Encoder.
+ /// </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;
+ }
+ }
+
#endregion
}
} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
index b27c14583..63c333db2 100644
--- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
@@ -123,6 +123,46 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// Setup this tab for the specified preset.
+ /// </summary>
+ /// <param name="preset">
+ /// The preset.
+ /// </param>
+ public void SetPreset(Preset preset)
+ {
+ if (preset != null && preset.Task != null)
+ {
+ // Store the previously selected tracks
+ List<Audio> selectedTracks = this.AudioTracks.Select(track => track.ScannedTrack).ToList();
+ this.AudioTracks.Clear();
+
+ // Add the tracks from the preset
+ foreach (AudioTrack track in preset.Task.AudioTracks)
+ {
+ this.AudioTracks.Add(new AudioTrack(track));
+ }
+
+ // Attempt to restore the previously selected tracks.
+ // or fallback to the first source track.
+ foreach (AudioTrack track in this.AudioTracks)
+ {
+ if (selectedTracks.Count != 0)
+ {
+ track.ScannedTrack = selectedTracks[0];
+ selectedTracks.RemoveAt(0);
+ }
+ else
+ {
+ if (this.SourceTracks != null)
+ {
+ track.ScannedTrack = this.SourceTracks.FirstOrDefault();
+ }
+ }
+ }
+ }
+ }
+
+ /// <summary>
/// Get Appropiate Bitrates for the selected encoder and mixdown.
/// </summary>
/// <param name="encoder">
diff --git a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs
index c36a7bcef..0495b8fcc 100644
--- a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs
@@ -217,6 +217,16 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// Setup this tab for the specified preset.
+ /// </summary>
+ /// <param name="preset">
+ /// The preset.
+ /// </param>
+ public void SetPreset(Preset preset)
+ {
+ }
+
+ /// <summary>
/// Set the Source Chapters List
/// </summary>
/// <param name="sourceChapters">
@@ -229,10 +239,15 @@ namespace HandBrakeWPF.ViewModels
this.Chapters.Clear();
// Then Add new Chapter Markers.
+ int counter = 1;
+
foreach (Chapter chapter in this.SourceChapterList)
{
- var marker = new ChapterMarker(chapter.ChapterNumber, chapter.ChapterName);
+ string chapterName = string.IsNullOrEmpty(chapter.ChapterName) ? string.Format("Chapter {0}", counter) : chapter.ChapterName;
+ var marker = new ChapterMarker(chapter.ChapterNumber, chapterName);
this.Chapters.Add(marker);
+
+ counter += 1;
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs
index 6dd4292e7..9cd9ce540 100644
--- a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs
@@ -372,6 +372,16 @@ namespace HandBrakeWPF.ViewModels
/// </param>
public void SetSource(Title title, Preset preset, EncodeTask 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
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAdvancedViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAdvancedViewModel.cs
index dc43ac831..9114bea32 100644
--- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAdvancedViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAdvancedViewModel.cs
@@ -9,26 +9,19 @@
namespace HandBrakeWPF.ViewModels.Interfaces
{
- using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Parsing;
+ using HandBrake.Interop.Model.Encoding;
/// <summary>
/// The Advanced View Model Interface
/// </summary>
- public interface IAdvancedViewModel
+ public interface IAdvancedViewModel : ITabInterface
{
/// <summary>
- /// Set the selected preset
+ /// Set the currently selected encoder.
/// </summary>
- /// <param name="title">
- /// The title.
+ /// <param name="encoder">
+ /// The Video Encoder.
/// </param>
- /// <param name="preset">
- /// The preset.
- /// </param>
- /// <param name="task">
- /// The task.
- /// </param>
- void SetSource(Title title, Preset preset, EncodeTask task);
+ void SetEncoder(VideoEncoder encoder);
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioViewModel.cs
index 2d38ab31c..e1d4328c6 100644
--- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioViewModel.cs
@@ -9,26 +9,10 @@
namespace HandBrakeWPF.ViewModels.Interfaces
{
- using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Parsing;
-
/// <summary>
/// The Audio View Model Interface
/// </summary>
- public interface IAudioViewModel
+ public interface IAudioViewModel : ITabInterface
{
- /// <summary>
- /// Set the Source Title
- /// </summary>
- /// <param name="title">
- /// The title.
- /// </param>
- /// <param name="preset">
- /// The preset.
- /// </param>
- /// <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 42820006a..8a6ee72c0 100644
--- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IChaptersViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IChaptersViewModel.cs
@@ -9,26 +9,10 @@
namespace HandBrakeWPF.ViewModels.Interfaces
{
- using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Parsing;
-
/// <summary>
/// The Chapters View Model Interface
/// </summary>
- public interface IChaptersViewModel
+ public interface IChaptersViewModel : ITabInterface
{
- /// <summary>
- /// Set the selected preset
- /// </summary>
- /// <param name="currentTitle">
- /// The current Title.
- /// </param>
- /// <param name="preset">
- /// The preset.
- /// </param>
- /// <param name="task">
- /// The task.
- /// </param>
- 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 cf7d00474..ba7d1636e 100644
--- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IFiltersViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IFiltersViewModel.cs
@@ -9,26 +9,10 @@
namespace HandBrakeWPF.ViewModels.Interfaces
{
- using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Parsing;
-
/// <summary>
/// The Filters View Model Interface
/// </summary>
- public interface IFiltersViewModel
+ public interface IFiltersViewModel : ITabInterface
{
- /// <summary>
- /// Setup a selected preset.
- /// </summary>
- /// <param name="title">
- /// The title.
- /// </param>
- /// <param name="preset">
- /// The Current Preset.
- /// </param>
- /// <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 293dc728a..2992a2b1f 100644
--- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPictureSettingsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPictureSettingsViewModel.cs
@@ -9,26 +9,10 @@
namespace HandBrakeWPF.ViewModels.Interfaces
{
- using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Parsing;
-
/// <summary>
/// The Picture Settings View Model Interface
/// </summary>
- public interface IPictureSettingsViewModel
+ public interface IPictureSettingsViewModel : ITabInterface
{
- /// <summary>
- /// Setup the window after a scan.
- /// </summary>
- /// <param name="selectedTitle">
- /// The selected title.
- /// </param>
- /// <param name="currentPreset">
- /// The Current preset
- /// </param>
- /// <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 e45aec710..2b10089de 100644
--- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs
@@ -9,26 +9,10 @@
namespace HandBrakeWPF.ViewModels.Interfaces
{
- using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Parsing;
-
/// <summary>
/// The Subtiles View Model Interface
/// </summary>
- public interface ISubtitlesViewModel
+ public interface ISubtitlesViewModel : ITabInterface
{
- /// <summary>
- /// Set the selected preset
- /// </summary>
- /// <param name="title">
- /// The title.
- /// </param>
- /// <param name="preset">
- /// The preset.
- /// </param>
- /// <param name="task">
- /// The task.
- /// </param>
- void SetSource(Title title, Preset preset, EncodeTask task);
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ITabInterface.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ITabInterface.cs
new file mode 100644
index 000000000..6091b506a
--- /dev/null
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ITabInterface.cs
@@ -0,0 +1,42 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="ITabInterface.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Defines the ITabInterface type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.ViewModels.Interfaces
+{
+ using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Parsing;
+
+ /// <summary>
+ /// Common interface for all the main tab panels
+ /// </summary>
+ public interface ITabInterface
+ {
+ /// <summary>
+ /// Setup the window after a scan.
+ /// </summary>
+ /// <param name="selectedTitle">
+ /// The selected title.
+ /// </param>
+ /// <param name="currentPreset">
+ /// The Current preset
+ /// </param>
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ void SetSource(Title selectedTitle, Preset currentPreset, EncodeTask task);
+
+ /// <summary>
+ /// Set the selected preset
+ /// </summary>
+ /// <param name="preset">
+ /// The preset.
+ /// </param>
+ void SetPreset(Preset preset);
+ }
+}
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IVideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IVideoViewModel.cs
index 229051812..d89e90ac6 100644
--- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IVideoViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IVideoViewModel.cs
@@ -9,26 +9,10 @@
namespace HandBrakeWPF.ViewModels.Interfaces
{
- using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Parsing;
-
/// <summary>
/// The Video View Model Interface
/// </summary>
- public interface IVideoViewModel
+ public interface IVideoViewModel : ITabInterface
{
- /// <summary>
- /// Set the selected preset
- /// </summary>
- /// <param name="title">
- /// The title.
- /// </param>
- /// <param name="preset">
- /// The preset.
- /// </param>
- /// <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 420443a58..7d64cfb5e 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -168,7 +168,6 @@ 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;
@@ -283,7 +282,19 @@ namespace HandBrakeWPF.ViewModels
set
{
this.selectedPreset = value;
- this.NotifyOfPropertyChange("SelectedPreset");
+
+ 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.NotifyOfPropertyChange(() => this.SelectedPreset);
}
}
@@ -523,6 +534,8 @@ namespace HandBrakeWPF.ViewModels
this.CurrentTask.Destination = AutoNameHelper.AutoName(this.CurrentTask, this.SourceName);
this.NotifyOfPropertyChange("CurrentTask");
+ this.Duration = selectedTitle.Duration.ToString();
+
// Setup the tab controls
this.SetupTabs();
}
@@ -557,7 +570,8 @@ namespace HandBrakeWPF.ViewModels
set
{
this.CurrentTask.StartPoint = value;
- this.NotifyOfPropertyChange("SelectedStartPoint");
+ this.NotifyOfPropertyChange(() => this.SelectedStartPoint);
+ this.Duration = this.DurationCalculation();
}
}
@@ -573,7 +587,8 @@ namespace HandBrakeWPF.ViewModels
set
{
this.CurrentTask.EndPoint = value;
- this.NotifyOfPropertyChange("SelectedEndPoint");
+ this.NotifyOfPropertyChange(() => this.SelectedEndPoint);
+ this.Duration = this.DurationCalculation();
}
}
@@ -611,7 +626,6 @@ namespace HandBrakeWPF.ViewModels
}
}
-
#endregion
#region Load and Shutdown Handling
@@ -620,7 +634,7 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public override void OnLoad()
{
- // TODO
+ this.SelectedPreset = this.presetService.DefaultPreset;
}
/// <summary>
@@ -1088,6 +1102,30 @@ namespace HandBrakeWPF.ViewModels
}
}
+ /// <summary>
+ /// Calculate the duration between the end and start point
+ /// </summary>
+ /// <returns>
+ /// The duration calculation.
+ /// </returns>
+ private string DurationCalculation()
+ {
+ double startEndDuration = this.SelectedEndPoint - this.SelectedStartPoint;
+ switch (this.SelectedPointToPoint)
+ {
+ case PointToPointMode.Chapters:
+ return this.SelectedTitle.CalculateDuration(this.SelectedStartPoint, this.SelectedEndPoint).ToString();
+ break;
+ case PointToPointMode.Seconds:
+ return TimeSpan.FromSeconds(startEndDuration).ToString();
+ case PointToPointMode.Frames:
+ startEndDuration = startEndDuration / selectedTitle.Fps;
+ return TimeSpan.FromSeconds(startEndDuration).ToString();
+ }
+
+ return "--:--:--";
+ }
+
#endregion
#region Event Handlers
diff --git a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs
index 6f741dea1..444208076 100644
--- a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs
@@ -39,81 +39,16 @@ namespace HandBrakeWPF.ViewModels
#region Backing Fields
/// <summary>
- /// The crop bottom.
- /// </summary>
- private int cropBottom;
-
- /// <summary>
- /// The crop left.
- /// </summary>
- private int cropLeft;
-
- /// <summary>
- /// The crop right.
- /// </summary>
- private int cropRight;
-
- /// <summary>
- /// The crop top.
- /// </summary>
- private int cropTop;
-
- /// <summary>
/// The display size.
/// </summary>
private string displaySize;
/// <summary>
- /// The display width.
- /// </summary>
- private int displayWidth;
-
- /// <summary>
- /// The height.
- /// </summary>
- private int height;
-
- /// <summary>
- /// The is custom crop.
- /// </summary>
- private bool isCustomCrop;
-
- /// <summary>
- /// The maintain aspect ratio.
- /// </summary>
- private bool maintainAspectRatio;
-
- /// <summary>
- /// The par height.
- /// </summary>
- private int parHeight;
-
- /// <summary>
- /// The par width.
- /// </summary>
- private int parWidth;
-
- /// <summary>
- /// The selected anamorphic mode.
- /// </summary>
- private Anamorphic selectedAnamorphicMode;
-
- /// <summary>
- /// The selected modulus
- /// </summary>
- private int selectedModulus;
-
- /// <summary>
/// The source info.
/// </summary>
private string sourceInfo;
/// <summary>
- /// The width.
- /// </summary>
- private int width;
-
- /// <summary>
/// Backing field for show custom anamorphic controls
/// </summary>
private bool showCustomAnamorphicControls;
@@ -137,9 +72,6 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
private Size sourceResolution;
- /// <summary>
- /// Source Aspect Ratio
- /// </summary>
private double sourceAspectRatio;
/// <summary>
@@ -161,6 +93,7 @@ namespace HandBrakeWPF.ViewModels
/// </param>
public PictureSettingsViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
{
+ this.Task = new EncodeTask();
this.SelectedModulus = 16;
this.MaintainAspectRatio = true;
}
@@ -170,6 +103,11 @@ namespace HandBrakeWPF.ViewModels
#region Public Properties
/// <summary>
+ /// Gets or sets Task.
+ /// </summary>
+ public EncodeTask Task { get; set; }
+
+ /// <summary>
/// Gets AnamorphicModes.
/// </summary>
public IEnumerable<Anamorphic> AnamorphicModes
@@ -187,11 +125,11 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- return this.cropBottom;
+ return this.Task.Cropping.Bottom;
}
set
{
- this.cropBottom = this.CorrectForModulus(this.cropBottom, value);
+ this.Task.Cropping.Bottom = this.CorrectForModulus(this.Task.Cropping.Bottom, value);
this.NotifyOfPropertyChange(() => this.CropBottom);
}
}
@@ -203,11 +141,11 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- return this.cropLeft;
+ return this.Task.Cropping.Left;
}
set
{
- this.cropLeft = this.CorrectForModulus(this.cropLeft, value);
+ this.Task.Cropping.Left = this.CorrectForModulus(this.Task.Cropping.Left, value);
this.NotifyOfPropertyChange(() => this.CropLeft);
}
}
@@ -219,11 +157,11 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- return this.cropRight;
+ return this.Task.Cropping.Right;
}
set
{
- this.cropRight = this.CorrectForModulus(this.cropRight, value);
+ this.Task.Cropping.Right = this.CorrectForModulus(this.Task.Cropping.Right, value);
this.NotifyOfPropertyChange(() => this.CropRight);
}
}
@@ -235,11 +173,12 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- return this.cropTop;
+ return this.Task.Cropping.Top;
}
+
set
{
- this.cropTop = this.CorrectForModulus(this.cropTop, value);
+ this.Task.Cropping.Top = this.CorrectForModulus(this.Task.Cropping.Top, value);
this.NotifyOfPropertyChange(() => this.CropTop);
}
}
@@ -267,11 +206,11 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- return this.displayWidth;
+ return this.Task.DisplayWidth.HasValue ? int.Parse(Math.Round(this.Task.DisplayWidth.Value, 0).ToString()) : 0;
}
set
{
- this.displayWidth = value;
+ this.Task.DisplayWidth = value;
this.CustomAnamorphicAdjust();
this.NotifyOfPropertyChange(() => this.DisplayWidth);
}
@@ -284,11 +223,11 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- return this.isCustomCrop;
+ return this.Task.HasCropping;
}
set
{
- this.isCustomCrop = value;
+ this.Task.HasCropping = value;
this.NotifyOfPropertyChange(() => this.IsCustomCrop);
}
}
@@ -300,11 +239,11 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- return this.maintainAspectRatio;
+ return this.Task.KeepDisplayAspect;
}
set
{
- this.maintainAspectRatio = value;
+ this.Task.KeepDisplayAspect = value;
this.WidthAdjust();
this.NotifyOfPropertyChange(() => this.MaintainAspectRatio);
}
@@ -328,11 +267,11 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- return this.parHeight;
+ return this.Task.PixelAspectY;
}
set
{
- this.parHeight = value;
+ this.Task.PixelAspectY = value;
this.CustomAnamorphicAdjust();
this.NotifyOfPropertyChange(() => this.ParHeight);
}
@@ -345,11 +284,11 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- return this.parWidth;
+ return this.Task.PixelAspectX;
}
set
{
- this.parWidth = value;
+ this.Task.PixelAspectX = value;
this.CustomAnamorphicAdjust();
this.NotifyOfPropertyChange(() => this.ParWidth);
}
@@ -362,11 +301,11 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- return this.selectedAnamorphicMode;
+ return this.Task.Anamorphic;
}
set
{
- this.selectedAnamorphicMode = value;
+ this.Task.Anamorphic = value;
this.AnamorphicAdjust();
this.NotifyOfPropertyChange(() => this.SelectedAnamorphicMode);
}
@@ -375,15 +314,15 @@ namespace HandBrakeWPF.ViewModels
/// <summary>
/// Gets or sets SelectedModulus.
/// </summary>
- public int SelectedModulus
+ public int? SelectedModulus
{
get
{
- return this.selectedModulus;
+ return this.Task.Modulus;
}
set
{
- this.selectedModulus = value;
+ this.Task.Modulus = value;
this.ModulusAdjust();
this.NotifyOfPropertyChange(() => this.SelectedModulus);
}
@@ -412,11 +351,12 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- return this.width;
+ return this.Task.Width.HasValue ? this.Task.Width.Value : 0;
}
+
set
{
- this.width = value;
+ this.Task.Width = value;
this.WidthAdjust();
this.NotifyOfPropertyChange(() => this.Width);
}
@@ -429,11 +369,11 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- return this.height;
+ return this.Task.Height.HasValue ? this.Task.Height.Value : 0;
}
set
{
- this.height = value;
+ this.Task.Height = value;
this.HeightAdjust();
this.NotifyOfPropertyChange(() => this.Height);
}
@@ -525,6 +465,49 @@ namespace HandBrakeWPF.ViewModels
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 (Task.UsesMaxPictureSettings)
+ {
+ this.Task.MaxWidth = preset.Task.MaxWidth;
+ this.Task.MaxHeight = preset.Task.MaxHeight;
+ this.Task.Width = preset.Task.MaxWidth ?? 0;
+ this.Task.Height = preset.Task.MaxHeight ?? 0;
+ }
+ else
+ {
+ this.Task.Width = preset.Task.Width ?? 0;
+ this.Task.Height = preset.Task.Height ?? 0;
+ }
+
+ if (Task.Anamorphic == Anamorphic.Custom)
+ {
+ this.Task.DisplayWidth = preset.Task.DisplayWidth ?? 0;
+ this.Task.PixelAspectX = preset.Task.PixelAspectX;
+ this.Task.PixelAspectY = preset.Task.PixelAspectY;
+ }
+
+ this.Task.KeepDisplayAspect = preset.Task.KeepDisplayAspect;
+
+ if (this.Task.Modulus.HasValue)
+ {
+ this.Task.Modulus = preset.Task.Modulus;
+ }
+
+ if (preset.Task.HasCropping)
+ {
+ this.Task.Cropping = preset.Task.Cropping;
+ }
+ }
#endregion
/// <summary>
@@ -532,9 +515,10 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
private void WidthAdjust()
{
- if (this.width > this.sourceResolution.Width)
+ if (this.Width > this.sourceResolution.Width)
{
- this.width = this.sourceResolution.Width;
+ this.Task.Width = this.sourceResolution.Width;
+ this.NotifyOfPropertyChange(() => this.Task.Width);
}
switch (SelectedAnamorphicMode)
@@ -551,22 +535,22 @@ namespace HandBrakeWPF.ViewModels
double newHeight = ((double)this.Width * this.sourceResolution.Width * SourceAspect.Height * crop_height) /
(this.sourceResolution.Height * SourceAspect.Width * crop_width);
- this.height = (int)Math.Round(GetModulusValue(newHeight), 0);
+ this.Task.Height = (int)Math.Round(GetModulusValue(newHeight), 0);
this.NotifyOfPropertyChange("Height");
}
break;
case Anamorphic.Strict:
- this.width = 0;
- this.height = 0;
+ this.Task.Width = 0;
+ this.Task.Height = 0;
- this.NotifyOfPropertyChange("Width");
- this.NotifyOfPropertyChange("Height");
+ this.NotifyOfPropertyChange(() => this.Task.Width);
+ this.NotifyOfPropertyChange(() => this.Task.Height);
this.SetDisplaySize();
break;
case Anamorphic.Loose:
- this.height = 0;
- this.NotifyOfPropertyChange("Width");
- this.NotifyOfPropertyChange("Height");
+ this.Task.Height = 0;
+ this.NotifyOfPropertyChange(() => this.Task.Width);
+ this.NotifyOfPropertyChange(() => this.Task.Height);
this.SetDisplaySize();
break;
case Anamorphic.Custom:
@@ -580,9 +564,10 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
private void HeightAdjust()
{
- if (this.height > this.sourceResolution.Height)
+ if (this.Height > this.sourceResolution.Height)
{
- this.height = this.sourceResolution.Height;
+ this.Task.Height = this.sourceResolution.Height;
+ this.NotifyOfPropertyChange(() => this.Task.Height);
}
switch (SelectedAnamorphicMode)
@@ -596,8 +581,8 @@ namespace HandBrakeWPF.ViewModels
double new_width = ((double)this.Height * this.sourceResolution.Height * SourceAspect.Width * crop_width) /
(this.sourceResolution.Width * SourceAspect.Height * crop_height);
- this.Width = (int)Math.Round(GetModulusValue(new_width), 0);
- this.NotifyOfPropertyChange("Width");
+ this.Task.Width = (int)Math.Round(GetModulusValue(new_width), 0);
+ this.NotifyOfPropertyChange(() => this.Task.Width);
}
break;
case Anamorphic.Custom:
@@ -647,8 +632,8 @@ namespace HandBrakeWPF.ViewModels
this.HeightControlEnabled = false;
this.ShowCustomAnamorphicControls = false;
- this.width = 0;
- this.height = 0;
+ this.Width = 0;
+ this.Height = 0;
this.NotifyOfPropertyChange(() => Width);
this.NotifyOfPropertyChange(() => Height);
this.SetDisplaySize();
@@ -659,8 +644,8 @@ namespace HandBrakeWPF.ViewModels
this.HeightControlEnabled = false;
this.ShowCustomAnamorphicControls = false;
- this.width = this.sourceResolution.Width;
- this.height = 0;
+ this.Width = this.sourceResolution.Width;
+ this.Height = 0;
this.NotifyOfPropertyChange(() => Width);
this.NotifyOfPropertyChange(() => Height);
this.SetDisplaySize();
@@ -671,14 +656,14 @@ namespace HandBrakeWPF.ViewModels
this.HeightControlEnabled = true;
this.ShowCustomAnamorphicControls = true;
- this.width = this.sourceResolution.Width;
- this.height = 0;
+ this.Width = this.sourceResolution.Width;
+ this.Height = 0;
this.NotifyOfPropertyChange(() => Width);
this.NotifyOfPropertyChange(() => Height);
- this.displayWidth = this.CalculateAnamorphicSizes().Width;
- this.parWidth = this.sourceParValues.Width;
- this.parHeight = this.sourceParValues.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);
@@ -798,12 +783,17 @@ namespace HandBrakeWPF.ViewModels
/// </returns>
private double GetModulusValue(double value)
{
- double remainder = value % this.SelectedModulus;
+ if (this.SelectedModulus == null)
+ {
+ return 0;
+ }
+
+ double remainder = value % this.SelectedModulus.Value;
if (remainder == 0)
return value;
- return remainder >= ((double)this.SelectedModulus / 2) ? value + (this.SelectedModulus - remainder) : value - remainder;
+ return remainder >= ((double)this.SelectedModulus.Value / 2) ? value + (this.SelectedModulus.Value - remainder) : value - remainder;
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
index 45ea7862b..7c3d79994 100644
--- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
@@ -9,15 +9,18 @@
namespace HandBrakeWPF.ViewModels
{
- using System.Windows;
- using HandBrake.ApplicationServices.Model;
- using Services.Interfaces;
using System.Collections.ObjectModel;
- using HandBrake.ApplicationServices.Services.Interfaces;
using System.ComponentModel.Composition;
- using Interfaces;
+ using System.Windows;
+
using Caliburn.Micro;
+ using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Services.Interfaces;
+
+ using HandBrakeWPF.Services.Interfaces;
+ using HandBrakeWPF.ViewModels.Interfaces;
+
/// <summary>
/// The Preview View Model
/// </summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
index 4b0a0af9b..13aabe5e8 100644
--- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
@@ -189,6 +189,17 @@ namespace HandBrakeWPF.ViewModels
this.SubtitleTracks = task.SubtitleTracks;
}
+ /// <summary>
+ /// Setup this tab for the specified preset.
+ /// </summary>
+ /// <param name="preset">
+ /// The preset.
+ /// </param>
+ public void SetPreset(Preset preset)
+ {
+ // We don't currently support subtitles within presets.
+ }
+
#endregion
}
} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
index 842e109d1..81b1ec6eb 100644
--- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
@@ -9,13 +9,16 @@
namespace HandBrakeWPF.ViewModels
{
+ using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using Caliburn.Micro;
+ using HandBrake.ApplicationServices;
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;
@@ -29,41 +32,10 @@ namespace HandBrakeWPF.ViewModels
public class VideoViewModel : ViewModelBase, IVideoViewModel
{
#region Constants and Fields
-
- /// <summary>
- /// The average bitrate.
- /// </summary>
- private int averageBitrate;
-
- /// <summary>
- /// The is constant framerate.
- /// </summary>
- private bool isConstantFramerate;
-
/// <summary>
- /// The is constant quantity.
+ /// Backing field for the user setting service.
/// </summary>
- private bool isConstantQuantity;
-
- /// <summary>
- /// The is peak framerate.
- /// </summary>
- private bool isPeakFramerate;
-
- /// <summary>
- /// The is turbo first pass.
- /// </summary>
- private bool isTurboFirstPass;
-
- /// <summary>
- /// The is two pass.
- /// </summary>
- private bool isTwoPass;
-
- /// <summary>
- /// The is variable framerate.
- /// </summary>
- private bool isVariableFramerate;
+ private IUserSettingService userSettingService;
/// <summary>
/// The quality max.
@@ -76,24 +48,14 @@ namespace HandBrakeWPF.ViewModels
private int qualityMin;
/// <summary>
- /// The rf.
- /// </summary>
- private int rf;
-
- /// <summary>
- /// The selected framerate.
- /// </summary>
- private double? selectedFramerate;
-
- /// <summary>
- /// The selected video encoder.
+ /// The show peak framerate.
/// </summary>
- private VideoEncoder selectedVideoEncoder;
+ private bool showPeakFramerate;
/// <summary>
/// The show peak framerate.
/// </summary>
- private bool showPeakFramerate;
+ private int rf;
#endregion
@@ -110,9 +72,12 @@ namespace HandBrakeWPF.ViewModels
/// </param>
public VideoViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
{
+ this.Task = new EncodeTask { VideoEncoder = VideoEncoder.X264 };
+ this.userSettingService = userSettingService;
this.QualityMin = 0;
this.QualityMax = 51;
this.IsConstantQuantity = true;
+ this.VideoEncoders = EnumHelper<VideoEncoder>.GetEnumList();
}
#endregion
@@ -120,23 +85,9 @@ namespace HandBrakeWPF.ViewModels
#region Public Properties
/// <summary>
- /// Gets or sets AverageBitrate.
+ /// Gets or sets the current Encode Task.
/// </summary>
- public string AverageBitrate
- {
- get
- {
- return this.averageBitrate.ToString();
- }
- set
- {
- if (value != null)
- {
- this.averageBitrate = int.Parse(value);
- }
- this.NotifyOfPropertyChange(() => this.AverageBitrate);
- }
- }
+ public EncodeTask Task { get; set; }
/// <summary>
/// Gets Framerates.
@@ -156,13 +107,13 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- return this.isConstantFramerate;
+ return this.Task.FramerateMode == FramerateMode.CFR;
}
set
{
- this.isConstantFramerate = value;
if (value)
{
+ this.Task.FramerateMode = FramerateMode.CFR;
this.IsVariableFramerate = false;
this.IsPeakFramerate = false;
}
@@ -178,11 +129,23 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- return this.isConstantQuantity;
+ return this.Task.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality;
}
set
{
- this.isConstantQuantity = value;
+ if (value)
+ {
+ this.Task.VideoEncodeRateType = VideoEncodeRateType.ConstantQuality;
+ this.Task.TwoPass = false;
+ this.Task.TurboFirstPass = false;
+ this.Task.VideoBitrate = null;
+ this.NotifyOfPropertyChange(() => this.Task);
+ }
+ else
+ {
+ this.Task.VideoEncodeRateType = VideoEncodeRateType.AverageBitrate;
+ }
+
this.NotifyOfPropertyChange(() => this.IsConstantQuantity);
}
}
@@ -194,13 +157,13 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- return this.isPeakFramerate;
+ return this.Task.FramerateMode == FramerateMode.PFR;
}
set
{
- this.isPeakFramerate = value;
if (value)
{
+ this.Task.FramerateMode = FramerateMode.PFR;
this.IsVariableFramerate = false;
this.IsConstantFramerate = false;
}
@@ -210,53 +173,21 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
- /// Gets or sets a value indicating whether IsTurboFirstPass.
- /// </summary>
- public bool IsTurboFirstPass
- {
- get
- {
- return this.isTurboFirstPass;
- }
- set
- {
- this.isTurboFirstPass = value;
- this.NotifyOfPropertyChange(() => this.IsTurboFirstPass);
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether IsTwoPass.
- /// </summary>
- public bool IsTwoPass
- {
- get
- {
- return this.isTwoPass;
- }
- set
- {
- this.isTwoPass = value;
- this.NotifyOfPropertyChange(() => this.IsTwoPass);
- }
- }
-
- /// <summary>
/// Gets or sets a value indicating whether IsVariableFramerate.
/// </summary>
public bool IsVariableFramerate
{
get
{
- return this.isVariableFramerate;
+ return this.Task.FramerateMode == FramerateMode.VFR;
}
set
{
- this.isVariableFramerate = value;
if (value)
{
this.IsPeakFramerate = false;
this.IsConstantFramerate = false;
+ this.Task.FramerateMode = FramerateMode.VFR;
}
this.NotifyOfPropertyChange(() => this.IsVariableFramerate);
@@ -302,12 +233,44 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- return this.rf;
+ return rf;
}
set
{
this.rf = value;
+
+ double cqStep = userSettingService.GetUserSetting<double>(ASUserSettingConstants.X264Step);
+ switch (this.SelectedVideoEncoder)
+ {
+ case VideoEncoder.FFMpeg:
+ case VideoEncoder.FFMpeg2:
+ this.Task.Quality = (32 - value);
+ break;
+ case VideoEncoder.X264:
+ double rfValue = 51.0 - value * cqStep;
+ rfValue = Math.Round(rfValue, 2);
+ this.Task.Quality = rfValue;
+
+ // TODO: Lossless warning.
+ break;
+ case VideoEncoder.Theora:
+ Task.Quality = value;
+ break;
+ }
+
this.NotifyOfPropertyChange(() => this.RF);
+ this.NotifyOfPropertyChange(() => this.DisplayRF);
+ }
+ }
+
+ /// <summary>
+ /// Gets DisplayRF.
+ /// </summary>
+ public double DisplayRF
+ {
+ get
+ {
+ return Task.Quality.HasValue ? this.Task.Quality.Value : 0;
}
}
@@ -318,43 +281,70 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- if (this.selectedFramerate == null)
+ if (this.Task.Framerate == null)
{
return "Same as source";
}
- return this.selectedFramerate.ToString();
+ return this.Task.Framerate.ToString();
}
set
{
if (value == "Same as source")
{
- this.selectedFramerate = null;
+ this.Task.Framerate = null;
this.ShowPeakFramerate = false;
}
- else
+ else if (!string.IsNullOrEmpty(value))
{
this.ShowPeakFramerate = true;
- this.selectedFramerate = double.Parse(value);
+ if (this.Task.FramerateMode == FramerateMode.VFR)
+ {
+ this.Task.FramerateMode = FramerateMode.PFR;
+ }
+ this.Task.Framerate = double.Parse(value);
}
this.NotifyOfPropertyChange(() => this.SelectedFramerate);
+ this.NotifyOfPropertyChange(() => this.Task);
}
}
/// <summary>
/// Gets or sets SelectedVideoEncoder.
/// </summary>
- public string SelectedVideoEncoder
+ public VideoEncoder SelectedVideoEncoder
{
get
{
- return EnumHelper<VideoEncoder>.GetDisplay(this.selectedVideoEncoder);
+ return this.Task.VideoEncoder;
}
set
{
- this.selectedVideoEncoder = EnumHelper<VideoEncoder>.GetValue(value);
+ this.Task.VideoEncoder = value;
this.NotifyOfPropertyChange(() => this.SelectedVideoEncoder);
+
+ // Tell the Advanced Panel off the change
+ IAdvancedViewModel advancedViewModel = IoC.Get<IAdvancedViewModel>();
+ advancedViewModel.SetEncoder(this.Task.VideoEncoder);
+
+ // Update the Quality Slider
+ switch (this.SelectedVideoEncoder)
+ {
+ case VideoEncoder.FFMpeg:
+ case VideoEncoder.FFMpeg2:
+ this.QualityMin = 1;
+ this.QualityMax = 31;
+ break;
+ case VideoEncoder.X264:
+ this.QualityMin = 0;
+ this.QualityMax = (int)(51 / userSettingService.GetUserSetting<double>(ASUserSettingConstants.X264Step));
+ break;
+ case VideoEncoder.Theora:
+ this.QualityMin = 0;
+ this.QualityMax = 63;
+ break;
+ }
}
}
@@ -375,15 +365,9 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
- /// Gets VideoEncoders.
+ /// Gets or sets VideoEncoders.
/// </summary>
- public IEnumerable<string> VideoEncoders
- {
- get
- {
- return EnumHelper<VideoEncoder>.GetEnumDisplayValues(typeof(VideoEncoder));
- }
- }
+ public IEnumerable<VideoEncoder> VideoEncoders { get; set; }
#endregion
@@ -403,6 +387,47 @@ namespace HandBrakeWPF.ViewModels
/// </param>
public void SetSource(Title title, Preset preset, EncodeTask task)
{
+ this.Task = task;
+ }
+
+ /// <summary>
+ /// Setup this tab for the specified preset.
+ /// </summary>
+ /// <param name="preset">
+ /// The preset.
+ /// </param>
+ public void SetPreset(Preset preset)
+ {
+ if (preset == null || preset.Task == null)
+ {
+ return;
+ }
+
+ this.SelectedVideoEncoder = preset.Task.VideoEncoder;
+ this.SelectedFramerate = preset.Task.Framerate.ToString();
+ switch (preset.Task.FramerateMode)
+ {
+ case FramerateMode.CFR:
+ this.IsConstantFramerate = true;
+ break;
+ case FramerateMode.VFR:
+ this.IsVariableFramerate = true;
+ this.ShowPeakFramerate = false;
+ break;
+ case FramerateMode.PFR:
+ this.IsPeakFramerate = true;
+ this.ShowPeakFramerate = true;
+ break;
+ }
+
+ // TODO Compute RF
+ this.RF = 20;
+
+ this.Task.TwoPass = preset.Task.TwoPass;
+ this.Task.TurboFirstPass = preset.Task.TurboFirstPass;
+ this.Task.VideoBitrate = preset.Task.VideoBitrate;
+
+ this.NotifyOfPropertyChange(() => this.Task);
}
#endregion