summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsr55 <[email protected]>2014-08-22 19:58:12 +0000
committersr55 <[email protected]>2014-08-22 19:58:12 +0000
commit54b962645c61f7b53e12a42443e49ca92c9cd3e4 (patch)
tree4c909d001d93861324753bf5ad479a1311363cc5
parentad7edc8fb58a256881fd470801e80dbb425cc79f (diff)
WinGui: Switch to using hb_set_anamorphic_size2. This simplifies the picture settings code in the GUI and should hopefully fix a few bugs.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6348 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj1
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs3
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_geometry.cs116
-rw-r--r--win/CS/HandBrakeWPF/Helpers/PictureSize.cs91
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs850
-rw-r--r--win/CS/HandBrakeWPF/Views/PictureSettingsView.xaml6
6 files changed, 531 insertions, 536 deletions
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj
index 59d7835f3..650361e5f 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj
@@ -162,6 +162,7 @@
<Compile Include="HbLib\hb_error_code.cs" />
<Compile Include="HbLib\hb_filter_ids.cs" />
<Compile Include="HbLib\hb_filter_object_s.cs" />
+ <Compile Include="HbLib\hb_geometry.cs" />
<Compile Include="HbLib\hb_mixdown_s.cs" />
<Compile Include="HbLib\hb_rate_s.cs" />
<Compile Include="HbLib\hb_state_s.cs" />
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs
index cf8193f52..449d7f023 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs
@@ -114,6 +114,9 @@ namespace HandBrake.Interop.HbLib
[DllImport("hb.dll", EntryPoint = "hb_set_anamorphic_size", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_set_anamorphic_size(ref hb_job_s job, ref int output_width, ref int output_height, ref int output_par_width, ref int output_par_height);
+ [DllImport("hb.dll", EntryPoint = "hb_set_anamorphic_size2", CallingConvention = CallingConvention.Cdecl)]
+ public static extern void hb_set_anamorphic_size2(ref hb_geometry_s sourceGeometry, ref hb_ui_geometry_s uiGeometry, ref hb_geometry_s result);
+
/// Return Type: int
///param0: hb_handle_t*
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_geometry.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_geometry.cs
new file mode 100644
index 000000000..6a0001ff7
--- /dev/null
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_geometry.cs
@@ -0,0 +1,116 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="hb_geometry.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 hb_geometry type.
+// </summary>
+// <auto-generated>Disable Stylecop Warnings for this file</auto-generated>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.Interop.HbLib
+{
+ using System.Runtime.InteropServices;
+
+ /// <summary>
+ /// The hb_geometry_s.
+ /// </summary>
+ [StructLayout(LayoutKind.Sequential)]
+ public struct hb_geometry_s
+ {
+ /// <summary>
+ /// The width.
+ /// </summary>
+ public int width;
+
+ /// <summary>
+ /// The height.
+ /// </summary>
+ public int height;
+
+ /// <summary>
+ /// The par.
+ /// </summary>
+ public hb_rational_t par;
+ }
+
+ /// <summary>
+ /// The hb_ui_geometry_s.
+ /// </summary>
+ [StructLayout(LayoutKind.Sequential)]
+ public struct hb_ui_geometry_s
+ {
+ /// <summary>
+ /// Anamorphic mode, see job struct anamorphic
+ /// </summary>
+ public int mode;
+
+ /// <summary>
+ /// Specifies settings that shouldn't be changed
+ /// </summary>
+ public int keep;
+
+ /// <summary>
+ /// use dvd dimensions to determine PAR
+ /// </summary>
+ public int itu_par;
+
+ /// <summary>
+ /// pixel alignment for loose anamorphic
+ /// </summary>
+ public int modulus;
+
+ /// <summary>
+ /// Cropping
+ /// </summary>
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4, ArraySubType = UnmanagedType.I4)]
+ public int[] crop;
+
+ /// <summary>
+ /// destination storage width
+ /// </summary>
+ public int width;
+
+ /// <summary>
+ /// destination storage height
+ /// </summary>
+ public int height;
+
+ /// <summary>
+ /// max destination storage width
+ /// </summary>
+ public int maxWidth;
+
+ /// <summary>
+ /// max destination storage height
+ /// </summary>
+ public int maxHeight;
+
+ /// <summary>
+ /// Pixel aspect used in custom anamorphic
+ /// </summary>
+ public hb_rational_t par;
+
+ /// <summary>
+ /// Display aspect used in custom anamorphic
+ /// </summary>
+ public hb_rational_t dar;
+ }
+
+ /// <summary>
+ /// The hb_rational_t.
+ /// </summary>
+ [StructLayout(LayoutKind.Sequential)]
+ public struct hb_rational_t
+ {
+ /// <summary>
+ /// The num.
+ /// </summary>
+ public int num;
+
+ /// <summary>
+ /// The den.
+ /// </summary>
+ public int den;
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Helpers/PictureSize.cs b/win/CS/HandBrakeWPF/Helpers/PictureSize.cs
index 94967d318..f790c5a15 100644
--- a/win/CS/HandBrakeWPF/Helpers/PictureSize.cs
+++ b/win/CS/HandBrakeWPF/Helpers/PictureSize.cs
@@ -10,6 +10,7 @@
namespace HandBrakeWPF.Helpers
{
using System;
+ using System.Diagnostics;
using System.Runtime.InteropServices;
using HandBrake.Interop.HbLib;
@@ -150,7 +151,17 @@ namespace HandBrakeWPF.Helpers
}
/// <summary>
- /// The hb_set_anamorphic_size_native.
+ /// The keep setting.
+ /// </summary>
+ public enum KeepSetting
+ {
+ HB_KEEP_WIDTH = 0x01,
+ HB_KEEP_HEIGHT = 0x02,
+ HB_KEEP_DISPLAY_ASPECT = 0x04
+ }
+
+ /// <summary>
+ /// The hb_set_anamorphic_size 2.
/// </summary>
/// <param name="job">
/// The job.
@@ -158,54 +169,52 @@ namespace HandBrakeWPF.Helpers
/// <param name="title">
/// The title.
/// </param>
+ /// <param name="setting">
+ /// The setting.
+ /// </param>
/// <returns>
- /// The <see cref="AnamorphicResult"/> object.
+ /// The <see cref="AnamorphicResult"/>.
/// </returns>
- public static AnamorphicResult hb_set_anamorphic_size(PictureSettingsJob job, PictureSettingsTitle title)
+ public static AnamorphicResult hb_set_anamorphic_size2(PictureSettingsJob job, PictureSettingsTitle title, KeepSetting setting)
{
int outputHeight = 0;
int outputParHeight = 0;
int outputParWidth = 0;
int outputWidth = 0;
- hb_job_s nativeJob = new hb_job_s
- {
- modulus = job.Modulus.HasValue ? job.Modulus.Value : 16,
- anamorphic =
- new hb_anamorphic_substruct
- {
- par_width = job.ParW,
- par_height = job.ParH,
- itu_par = 0,
- mode = (hb_anamorphic_mode_t)job.AnamorphicMode,
- dar_width = 0,
- dar_height = 0,
- keep_display_aspect = job.KeepDisplayAspect ? 1 : 0
- },
- maxWidth = title.Width,
- maxHeight = title.Height,
- width = job.Width,
- height = job.Height,
- crop = new[] { job.Crop.Top, job.Crop.Bottom, job.Crop.Left, job.Crop.Right }
- };
-
- hb_title_s title_s = new hb_title_s
- {
- crop = new[] { job.Crop.Top, job.Crop.Bottom, job.Crop.Left, job.Crop.Right },
- width = title.Width,
- height = title.Height,
- pixel_aspect_width = title.ParW,
- pixel_aspect_height = title.ParH,
- aspect = 0
- };
-
- IntPtr pointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(hb_title_s)));
- Marshal.StructureToPtr(title_s, pointer, false);
- nativeJob.title = pointer;
-
- HBFunctions.hb_set_anamorphic_size(
- ref nativeJob, ref outputWidth, ref outputHeight, ref outputParWidth, ref outputParHeight);
-
+ int settingMode = (int)setting + (job.KeepDisplayAspect ? 0x04 : 0);
+
+ hb_ui_geometry_s uiGeometry = new hb_ui_geometry_s
+ {
+ crop = new[] { job.Crop.Top, job.Crop.Bottom, job.Crop.Left, job.Crop.Right },
+ dar = new hb_rational_t { den = 0, num = 0 },
+ height = job.Height,
+ itu_par = 0,
+ keep = settingMode,
+ maxWidth = job.MaxWidth,
+ maxHeight = job.MaxHeight,
+ mode = (int)(hb_anamorphic_mode_t)job.AnamorphicMode,
+ modulus = job.Modulus.HasValue ? job.Modulus.Value : 16,
+ par = job.AnamorphicMode != Anamorphic.Custom ? new hb_rational_t { den = title.ParH, num = title.ParW } : new hb_rational_t { den = job.ParH, num = job.ParW },
+ width = job.Width,
+ };
+
+ hb_geometry_s sourceGeometry = new hb_geometry_s
+ {
+ width = title.Width,
+ height = title.Height,
+ par = new hb_rational_t { den = title.ParH, num = title.ParW }
+ };
+
+ hb_geometry_s result = new hb_geometry_s();
+
+ HBFunctions.hb_set_anamorphic_size2(ref sourceGeometry, ref uiGeometry, ref result);
+
+ outputWidth = result.width;
+ outputHeight = result.height;
+ outputParWidth = result.par.den;
+ outputParHeight = result.par.num;
+ Debug.WriteLine("hb_set_anamorphic_size2: {0}x{1}", outputWidth, outputHeight);
return new AnamorphicResult { OutputWidth = outputWidth, OutputHeight = outputHeight, OutputParWidth = outputParWidth, OutputParHeight = outputParHeight };
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs
index 1bcc43c36..7d8bdd51b 100644
--- a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs
@@ -12,14 +12,9 @@ namespace HandBrakeWPF.ViewModels
using System;
using System.Collections.Generic;
using System.Globalization;
- using System.Windows;
- using System.Windows.Media.Imaging;
-
- using Caliburn.Micro;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Parsing;
- using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.Interop.Model;
using HandBrake.Interop.Model.Encoding;
@@ -109,6 +104,11 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
private DelayedActionProcessor delayedPreviewprocessor = new DelayedActionProcessor();
+ /// <summary>
+ /// The current title.
+ /// </summary>
+ private Title currentTitle;
+
#endregion
#region Constructors and Destructors
@@ -119,12 +119,7 @@ namespace HandBrakeWPF.ViewModels
public PictureSettingsViewModel()
{
this.Task = new EncodeTask();
- this.SelectedModulus = 16;
- this.MaintainAspectRatio = true;
-
- // Default the Max Width / Height to 1080p format
- this.MaxHeight = 1080;
- this.MaxWidth = 1920;
+ this.Init();
}
#endregion
@@ -148,369 +143,314 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
- /// Gets or sets CropBottom.
+ /// Gets or sets DisplaySize.
/// </summary>
- public int CropBottom
+ public string DisplaySize
{
get
{
- return this.Task.Cropping.Bottom;
+ return this.displaySize;
}
set
{
- this.Task.Cropping.Bottom = value;
- this.NotifyOfPropertyChange(() => this.CropBottom);
- this.CropAdjust();
- this.SetDisplaySize();
- this.UpdatePreviewImage();
+ this.displaySize = value;
+ this.NotifyOfPropertyChange(() => this.DisplaySize);
}
}
/// <summary>
- /// Gets or sets CropLeft.
+ /// Gets or sets a value indicating whether HeightControlEnabled.
/// </summary>
- public int CropLeft
+ public bool HeightControlEnabled
{
get
{
- return this.Task.Cropping.Left;
+ return this.heightControlEnabled;
}
set
{
- this.Task.Cropping.Left = value;
- this.NotifyOfPropertyChange(() => this.CropLeft);
- this.CropAdjust();
- this.SetDisplaySize();
- this.UpdatePreviewImage();
+ this.heightControlEnabled = value;
+ this.NotifyOfPropertyChange(() => this.HeightControlEnabled);
}
}
/// <summary>
- /// Gets or sets CropRight.
+ /// Gets ModulusValues.
/// </summary>
- public int CropRight
+ public IEnumerable<int> ModulusValues
{
get
{
- return this.Task.Cropping.Right;
- }
-
- set
- {
- this.Task.Cropping.Right = value;
- this.NotifyOfPropertyChange(() => this.CropRight);
- this.CropAdjust();
- this.SetDisplaySize();
- this.UpdatePreviewImage();
+ return new List<int> { 16, 8, 4, 2 };
}
}
/// <summary>
- /// Gets or sets CropTop.
+ /// Gets or sets a value indicating whether ShowCustomAnamorphicControls.
/// </summary>
- public int CropTop
+ public bool ShowCustomAnamorphicControls
{
get
{
- return this.Task.Cropping.Top;
+ return this.showCustomAnamorphicControls;
}
set
{
- this.Task.Cropping.Top = value;
- this.NotifyOfPropertyChange(() => this.CropTop);
- this.CropAdjust();
- this.SetDisplaySize();
- this.UpdatePreviewImage();
+ this.showCustomAnamorphicControls = value;
+ this.NotifyOfPropertyChange(() => this.ShowCustomAnamorphicControls);
}
}
/// <summary>
- /// Gets or sets DisplaySize.
+ /// Gets or sets SourceInfo.
/// </summary>
- public string DisplaySize
+ public string SourceInfo
{
get
{
- return this.displaySize;
+ return this.sourceInfo;
}
set
{
- this.displaySize = value;
- this.NotifyOfPropertyChange(() => this.DisplaySize);
+ this.sourceInfo = value;
+ this.NotifyOfPropertyChange(() => this.SourceInfo);
}
}
/// <summary>
- /// Gets or sets DisplayWidth.
+ /// Gets or sets Task.
/// </summary>
- public int DisplayWidth
- {
- get
- {
- return this.Task.DisplayWidth.HasValue
- ? int.Parse(Math.Round(this.Task.DisplayWidth.Value, 0).ToString(CultureInfo.InvariantCulture))
- : 0;
- }
-
- set
- {
- if (!object.Equals(this.Task.DisplayWidth, value))
- {
- this.Task.DisplayWidth = value;
- this.CustomAnamorphicAdjust();
- this.NotifyOfPropertyChange(() => this.DisplayWidth);
- this.UpdatePreviewImage();
- }
- }
- }
+ public EncodeTask Task { get; set; }
/// <summary>
- /// Gets or sets Height.
+ /// Gets or sets a value indicating whether WidthControlEnabled.
/// </summary>
- public int Height
+ public bool WidthControlEnabled
{
get
{
- return this.Task.Height.HasValue ? this.Task.Height.Value : 0;
+ return this.widthControlEnabled;
}
set
{
- if (!object.Equals(this.Task.Height, value))
- {
- this.Task.Height = value;
- this.HeightAdjust();
- this.NotifyOfPropertyChange(() => this.Height);
- this.UpdatePreviewImage();
- }
+ this.widthControlEnabled = value;
+ this.NotifyOfPropertyChange(() => this.WidthControlEnabled);
}
}
/// <summary>
- /// Gets or sets a value indicating whether HeightControlEnabled.
+ /// Gets or sets a value indicating whether ShowModulus.
/// </summary>
- public bool HeightControlEnabled
+ public bool ShowModulus
{
get
{
- return this.heightControlEnabled;
+ return this.showModulus;
}
-
set
{
- this.heightControlEnabled = value;
- this.NotifyOfPropertyChange(() => this.HeightControlEnabled);
+ this.showModulus = value;
+ this.NotifyOfPropertyChange(() => this.ShowModulus);
}
}
/// <summary>
- /// Gets or sets a value indicating whether IsCustomCrop.
+ /// Gets or sets a value indicating whether ShowDisplaySize.
/// </summary>
- public bool IsCustomCrop
+ public bool ShowDisplaySize
{
get
{
- return this.Task.HasCropping;
+ return this.showDisplaySize;
}
-
set
{
- this.Task.HasCropping = value;
- this.NotifyOfPropertyChange(() => this.IsCustomCrop);
+ this.showDisplaySize = value;
+ this.NotifyOfPropertyChange(() => this.ShowDisplaySize);
}
}
/// <summary>
- /// Gets or sets a value indicating whether MaintainAspectRatio.
+ /// Gets or sets MaxHeight.
/// </summary>
- public bool MaintainAspectRatio
+ public int MaxHeight
{
get
{
- return this.Task.KeepDisplayAspect;
+ return this.maxHeight;
}
-
set
{
- this.Task.KeepDisplayAspect = value;
- this.WidthAdjust();
- this.NotifyOfPropertyChange(() => this.MaintainAspectRatio);
- this.UpdatePreviewImage();
+ this.maxHeight = value;
+ this.NotifyOfPropertyChange(() => this.MaxHeight);
}
}
/// <summary>
- /// Gets ModulusValues.
+ /// Gets or sets MinHeight.
/// </summary>
- public IEnumerable<int> ModulusValues
+ public int MaxWidth
{
get
{
- return new List<int> { 16, 8, 4, 2 };
+ return this.maxWidth;
+ }
+ set
+ {
+ this.maxWidth = value;
+ this.NotifyOfPropertyChange(() => this.MaxWidth);
}
}
/// <summary>
- /// Gets or sets ParHeight.
+ /// Gets or sets a value indicating whether show keep ar.
/// </summary>
- public int ParHeight
+ public bool ShowKeepAR
{
get
{
- return this.Task.PixelAspectY;
+ return this.showKeepAr;
}
-
set
{
- if (!object.Equals(this.Task.PixelAspectY, value))
- {
- this.Task.PixelAspectY = value;
- this.CustomAnamorphicAdjust();
- this.NotifyOfPropertyChange(() => this.ParHeight);
- this.UpdatePreviewImage();
- }
+ this.showKeepAr = value;
+ this.NotifyOfPropertyChange(() => this.ShowKeepAR);
}
}
/// <summary>
- /// Gets or sets ParWidth.
+ /// Gets a value indicating whether is picture preview enabled.
/// </summary>
- public int ParWidth
+ public bool IsPicturePreviewEnabled
{
get
{
- return this.Task.PixelAspectX;
- }
-
- set
- {
- if (!object.Equals(this.Task.PixelAspectX, value))
- {
- this.Task.PixelAspectX = value;
- this.CustomAnamorphicAdjust();
- this.NotifyOfPropertyChange(() => this.ParWidth);
- this.UpdatePreviewImage();
- }
+ return this.UserSettingService.GetUserSetting<bool>(UserSettingConstants.EnableStaticPreview);
}
}
+ #endregion
+
+ #region Task Properties
+
/// <summary>
- /// Gets or sets SelectedAnamorphicMode.
+ /// Gets or sets CropBottom.
/// </summary>
- public Anamorphic SelectedAnamorphicMode
+ public int CropBottom
{
get
{
- return this.Task.Anamorphic;
+ return this.Task.Cropping.Bottom;
}
set
{
- if (!object.Equals(this.SelectedAnamorphicMode, value))
- {
- this.Task.Anamorphic = value;
- this.AnamorphicAdjust();
- this.NotifyOfPropertyChange(() => this.SelectedAnamorphicMode);
- this.UpdatePreviewImage();
- }
+ this.Task.Cropping.Bottom = value;
+ this.NotifyOfPropertyChange(() => this.CropBottom);
+ this.RecaulcatePictureSettingsProperties(ChangedPictureField.Crop);
}
}
/// <summary>
- /// Gets or sets SelectedModulus.
+ /// Gets or sets CropLeft.
/// </summary>
- public int? SelectedModulus
+ public int CropLeft
{
get
{
- return this.Task.Modulus;
+ return this.Task.Cropping.Left;
}
set
{
- this.Task.Modulus = value;
- this.ModulusAdjust();
- this.NotifyOfPropertyChange(() => this.SelectedModulus);
- this.UpdatePreviewImage();
+ this.Task.Cropping.Left = value;
+ this.NotifyOfPropertyChange(() => this.CropLeft);
+ this.RecaulcatePictureSettingsProperties(ChangedPictureField.Crop);
}
}
/// <summary>
- /// Gets or sets a value indicating whether ShowCustomAnamorphicControls.
+ /// Gets or sets CropRight.
/// </summary>
- public bool ShowCustomAnamorphicControls
+ public int CropRight
{
get
{
- return this.showCustomAnamorphicControls;
+ return this.Task.Cropping.Right;
}
set
{
- this.showCustomAnamorphicControls = value;
- this.NotifyOfPropertyChange(() => this.ShowCustomAnamorphicControls);
+ this.Task.Cropping.Right = value;
+ this.NotifyOfPropertyChange(() => this.CropRight);
+ this.RecaulcatePictureSettingsProperties(ChangedPictureField.Crop);
}
}
/// <summary>
- /// Gets or sets a value indicating whether ShowModulus.
+ /// Gets or sets CropTop.
/// </summary>
- public bool ShowModulus
+ public int CropTop
{
get
{
- return this.showModulus;
+ return this.Task.Cropping.Top;
}
+
set
{
- this.showModulus = value;
- this.NotifyOfPropertyChange(() => this.ShowModulus);
+ this.Task.Cropping.Top = value;
+ this.NotifyOfPropertyChange(() => this.CropTop);
+ this.RecaulcatePictureSettingsProperties(ChangedPictureField.Crop);
}
}
/// <summary>
- /// Gets or sets a value indicating whether ShowDisplaySize.
+ /// Gets or sets a value indicating whether IsCustomCrop.
/// </summary>
- public bool ShowDisplaySize
+ public bool IsCustomCrop
{
get
{
- return this.showDisplaySize;
+ return this.Task.HasCropping;
}
+
set
{
- this.showDisplaySize = value;
- this.NotifyOfPropertyChange(() => this.ShowDisplaySize);
+ this.Task.HasCropping = value;
+ this.NotifyOfPropertyChange(() => this.IsCustomCrop);
}
}
/// <summary>
- /// Gets or sets SourceInfo.
+ /// Gets or sets DisplayWidth.
/// </summary>
- public string SourceInfo
+ public int DisplayWidth
{
get
{
- return this.sourceInfo;
+ return this.Task.DisplayWidth.HasValue
+ ? int.Parse(Math.Round(this.Task.DisplayWidth.Value, 0).ToString(CultureInfo.InvariantCulture))
+ : 0;
}
set
{
- this.sourceInfo = value;
- this.NotifyOfPropertyChange(() => this.SourceInfo);
+ if (!object.Equals(this.Task.DisplayWidth, value))
+ {
+ this.Task.DisplayWidth = value;
+ this.NotifyOfPropertyChange(() => this.DisplayWidth);
+ this.RecaulcatePictureSettingsProperties(ChangedPictureField.DisplayWidth);
+ }
}
}
/// <summary>
- /// Gets or sets Task.
- /// </summary>
- public EncodeTask Task { get; set; }
-
- /// <summary>
/// Gets or sets Width.
/// </summary>
public int Width
@@ -525,100 +465,129 @@ namespace HandBrakeWPF.ViewModels
if (!object.Equals(this.Task.Width, value))
{
this.Task.Width = value;
- this.WidthAdjust();
this.NotifyOfPropertyChange(() => this.Width);
- this.UpdatePreviewImage();
+ this.RecaulcatePictureSettingsProperties(ChangedPictureField.Width);
}
}
}
/// <summary>
- /// Gets or sets a value indicating whether WidthControlEnabled.
+ /// Gets or sets Height.
/// </summary>
- public bool WidthControlEnabled
+ public int Height
{
get
{
- return this.widthControlEnabled;
+ return this.Task.Height.HasValue ? this.Task.Height.Value : 0;
}
set
{
- this.widthControlEnabled = value;
- this.NotifyOfPropertyChange(() => this.WidthControlEnabled);
+ if (!object.Equals(this.Task.Height, value))
+ {
+ this.Task.Height = value;
+ this.NotifyOfPropertyChange(() => this.Height);
+ this.RecaulcatePictureSettingsProperties(ChangedPictureField.Height);
+ }
}
}
/// <summary>
- /// Gets or sets MaxHeight.
+ /// Gets or sets a value indicating whether MaintainAspectRatio.
/// </summary>
- public int MaxHeight
+ public bool MaintainAspectRatio
{
get
{
- return this.maxHeight;
+ return this.Task.KeepDisplayAspect;
}
+
set
{
- this.maxHeight = value;
- this.NotifyOfPropertyChange(() => this.MaxHeight);
+ this.Task.KeepDisplayAspect = value;
+ this.NotifyOfPropertyChange(() => this.MaintainAspectRatio);
+ this.RecaulcatePictureSettingsProperties(ChangedPictureField.MaintainAspectRatio);
}
}
/// <summary>
- /// Gets or sets MinHeight.
+ /// Gets or sets ParHeight.
/// </summary>
- public int MaxWidth
+ public int ParHeight
{
get
{
- return this.maxWidth;
+ return this.Task.PixelAspectY;
}
+
set
{
- this.maxWidth = value;
- this.NotifyOfPropertyChange(() => this.MaxWidth);
+ if (!object.Equals(this.Task.PixelAspectY, value))
+ {
+ this.Task.PixelAspectY = value;
+ this.NotifyOfPropertyChange(() => this.ParHeight);
+ this.RecaulcatePictureSettingsProperties(ChangedPictureField.ParH);
+ }
}
}
/// <summary>
- /// Gets SourceAspect.
+ /// Gets or sets ParWidth.
/// </summary>
- private Size SourceAspect
+ public int ParWidth
{
get
{
- // display aspect = (width * par_width) / (height * par_height)
- return new Size(
- (this.sourceParValues.Width * this.sourceResolution.Width),
- (this.sourceParValues.Height * this.sourceResolution.Height));
+ return this.Task.PixelAspectX;
+ }
+
+ set
+ {
+ if (!object.Equals(this.Task.PixelAspectX, value))
+ {
+ this.Task.PixelAspectX = value;
+ this.NotifyOfPropertyChange(() => this.ParWidth);
+ this.RecaulcatePictureSettingsProperties(ChangedPictureField.ParW);
+ }
}
}
/// <summary>
- /// Gets or sets a value indicating whether show keep ar.
+ /// Gets or sets SelectedAnamorphicMode.
/// </summary>
- public bool ShowKeepAR
+ public Anamorphic SelectedAnamorphicMode
{
get
{
- return this.showKeepAr;
+ return this.Task.Anamorphic;
}
+
set
{
- this.showKeepAr = value;
- this.NotifyOfPropertyChange(() => this.ShowKeepAR);
+ if (!object.Equals(this.SelectedAnamorphicMode, value))
+ {
+ this.Task.Anamorphic = value;
+ this.NotifyOfPropertyChange(() => this.SelectedAnamorphicMode);
+ this.RecaulcatePictureSettingsProperties(ChangedPictureField.Anamorphic);
+ }
}
}
/// <summary>
- /// Gets a value indicating whether is picture preview enabled.
+ /// Gets or sets SelectedModulus.
/// </summary>
- public bool IsPicturePreviewEnabled
+ public int? SelectedModulus
{
get
{
- return this.UserSettingService.GetUserSetting<bool>(UserSettingConstants.EnableStaticPreview);
+ return this.Task.Modulus;
+ }
+
+ set
+ {
+ this.Task.Modulus = value;
+ this.NotifyOfPropertyChange(() => this.SelectedModulus);
+ this.RecaulcatePictureSettingsProperties(ChangedPictureField.Modulus);
}
}
@@ -665,11 +634,11 @@ namespace HandBrakeWPF.ViewModels
this.MaintainAspectRatio = preset.Task.KeepDisplayAspect;
// Set the width, then check the height doesn't breach the max height and correct if necessary.
- int width = this.GetModulusValue(this.getRes((this.sourceResolution.Width - this.CropLeft - this.CropRight), preset.Task.MaxWidth));
+ int width = this.GetModulusValue(this.GetRes((this.sourceResolution.Width - this.CropLeft - this.CropRight), preset.Task.MaxWidth));
this.Width = width;
// If we have a max height, make sure we havn't breached it.
- int height = this.GetModulusValue(this.getRes((this.sourceResolution.Height - this.CropTop - this.CropBottom), preset.Task.MaxHeight));
+ int height = this.GetModulusValue(this.GetRes((this.sourceResolution.Height - this.CropTop - this.CropBottom), preset.Task.MaxHeight));
if (preset.Task.MaxHeight.HasValue && this.Height > preset.Task.MaxHeight.Value)
{
this.Height = height;
@@ -740,6 +709,7 @@ namespace HandBrakeWPF.ViewModels
/// </param>
public void SetSource(Title title, Preset preset, EncodeTask task)
{
+ this.currentTitle = title;
this.Task = task;
if (title != null)
@@ -751,25 +721,25 @@ namespace HandBrakeWPF.ViewModels
// Update the cropping values, preffering those in the presets.
if (!preset.Task.HasCropping)
{
- this.CropTop = title.AutoCropDimensions.Top;
- this.CropBottom = title.AutoCropDimensions.Bottom;
- this.CropLeft = title.AutoCropDimensions.Left;
- this.CropRight = title.AutoCropDimensions.Right;
+ this.Task.Cropping.Top = title.AutoCropDimensions.Top;
+ this.Task.Cropping.Bottom = title.AutoCropDimensions.Bottom;
+ this.Task.Cropping.Left = title.AutoCropDimensions.Left;
+ this.Task.Cropping.Right = title.AutoCropDimensions.Right;
this.IsCustomCrop = false;
}
else
{
- this.CropLeft = preset.Task.Cropping.Left;
- this.CropRight = preset.Task.Cropping.Right;
- this.CropTop = preset.Task.Cropping.Top;
- this.CropBottom = preset.Task.Cropping.Bottom;
+ this.Task.Cropping.Left = preset.Task.Cropping.Left;
+ this.Task.Cropping.Right = preset.Task.Cropping.Right;
+ this.Task.Cropping.Top = preset.Task.Cropping.Top;
+ this.Task.Cropping.Bottom = preset.Task.Cropping.Bottom;
this.IsCustomCrop = true;
}
if (preset.PictureSettingsMode == PresetPictureSettingsMode.None)
{
// We have no instructions, so simply set it to the source.
- this.Width = this.GetModulusValue(this.sourceResolution.Width - this.CropLeft - this.CropRight);
+ this.Task.Width = this.GetModulusValue(this.sourceResolution.Width - this.CropLeft - this.CropRight);
this.MaintainAspectRatio = true;
}
else
@@ -796,23 +766,18 @@ namespace HandBrakeWPF.ViewModels
// Set the Width, and Maintain Aspect ratio. That should calc the Height for us.
if (this.SelectedAnamorphicMode == Anamorphic.None)
{
- this.Width = preset.Task.Width ?? (this.MaxWidth - this.CropLeft - this.CropRight);
+ this.Task.Width = preset.Task.Width ?? (this.MaxWidth - this.CropLeft - this.CropRight);
// Note: This will be auto-corrected in the property if it's too large.
}
else
{
- this.Width = preset.Task.Width ?? this.MaxWidth;
+ this.Task.Width = preset.Task.Width ?? this.MaxWidth;
}
// If our height is too large, let it downscale the width for us by setting the height to the lower value.
if (!this.MaintainAspectRatio && this.Height > this.MaxHeight)
{
- this.Height = this.MaxHeight;
- }
-
- if (this.SelectedAnamorphicMode == Anamorphic.Custom)
- {
- this.AnamorphicAdjust(); // Refresh the values
+ this.Task.Height = this.MaxHeight;
}
}
@@ -824,6 +789,8 @@ namespace HandBrakeWPF.ViewModels
title.AspectRatio,
title.ParVal.Width,
title.ParVal.Height);
+
+ this.RecaulcatePictureSettingsProperties(ChangedPictureField.Width);
}
this.NotifyOfPropertyChange(() => this.Task);
@@ -848,35 +815,171 @@ namespace HandBrakeWPF.ViewModels
#region Methods
/// <summary>
- /// The crop adjust.
+ /// The init.
+ /// </summary>
+ private void Init()
+ {
+ this.Task.Modulus = 16;
+ this.Task.KeepDisplayAspect = true;
+
+ this.NotifyOfPropertyChange(() => this.SelectedModulus);
+ this.NotifyOfPropertyChange(() => this.MaintainAspectRatio);
+
+ // Default the Max Width / Height to 1080p format
+ this.MaxHeight = 1080;
+ this.MaxWidth = 1920;
+ }
+
+ /// <summary>
+ /// The get picture title info.
/// </summary>
- private void CropAdjust()
+ /// <returns>
+ /// The <see cref="PictureSize.PictureSettingsTitle"/>.
+ /// </returns>
+ private PictureSize.PictureSettingsTitle GetPictureTitleInfo()
{
- PictureSize.AnamorphicResult result = PictureSize.hb_set_anamorphic_size(this.GetPictureSettings(), this.GetPictureTitleInfo());
+ PictureSize.PictureSettingsTitle title = new PictureSize.PictureSettingsTitle
+ {
+ Width = this.sourceResolution.Width,
+ Height = this.sourceResolution.Height,
+ ParW = this.sourceParValues.Width,
+ ParH = this.sourceParValues.Height,
+ Aspect = 0 // TODO
+ };
+
+ return title;
+ }
+
+ /// <summary>
+ /// The get picture settings.
+ /// </summary>
+ /// <returns>
+ /// The <see cref="PictureSize.PictureSettingsJob"/>.
+ /// </returns>
+ private PictureSize.PictureSettingsJob GetPictureSettings()
+ {
+ PictureSize.PictureSettingsJob job = new PictureSize.PictureSettingsJob
+ {
+ Width = this.Width,
+ Height = this.Height,
+ ItuPar = false,
+ Modulus = this.SelectedModulus,
+ ParW = this.ParWidth,
+ ParH = this.ParHeight,
+ MaxWidth = this.MaxWidth,
+ MaxHeight = this.MaxHeight,
+ KeepDisplayAspect = this.MaintainAspectRatio,
+ AnamorphicMode = this.SelectedAnamorphicMode,
+ DarWidth = 0,
+ DarHeight = 0,
+ Crop = new Cropping(this.CropTop, this.CropBottom, this.CropLeft, this.CropRight),
+ };
+
+ if (this.SelectedAnamorphicMode == Anamorphic.Loose)
+ {
+ job.ParW = sourceParValues.Width;
+ job.ParH = sourceParValues.Height;
+ }
+
+ return job;
+ }
+
+ /// <summary>
+ /// Recalculate the picture settings when the user changes a particular field defined in the ChangedPictureField enum.
+ /// The properties in this class are dumb. They simply call this method if there is a change.
+ /// It is the job of this method to update all affected private fields and raise change notifications.
+ /// </summary>
+ /// <param name="changedField">
+ /// The changed field.
+ /// </param>
+ private void RecaulcatePictureSettingsProperties(ChangedPictureField changedField)
+ {
+ // Sanity Check
+ if (this.currentTitle == null)
+ {
+ return;
+ }
+
+ // Step 1, Update what controls are visibile.
+ this.UpdateVisibileControls();
+
+ // Step 2, Set sensible defaults
+ if (changedField == ChangedPictureField.Anamorphic && (this.SelectedAnamorphicMode == Anamorphic.None || this.SelectedAnamorphicMode == Anamorphic.Loose))
+ {
+ this.Task.Width = this.sourceResolution.Width > this.MaxWidth
+ ? this.MaxWidth
+ : this.sourceResolution.Width;
+ this.Task.KeepDisplayAspect = true;
+ }
+
+ // Choose which setting to keep.
+ PictureSize.KeepSetting setting = PictureSize.KeepSetting.HB_KEEP_WIDTH;
+ switch (changedField)
+ {
+ case ChangedPictureField.Width:
+ setting = PictureSize.KeepSetting.HB_KEEP_WIDTH;
+ break;
+ case ChangedPictureField.Height:
+ setting = PictureSize.KeepSetting.HB_KEEP_HEIGHT;
+ break;
+ }
+
+ // Step 2, For the changed field, call hb_set_anamorphic_size and process the results.
+ PictureSize.AnamorphicResult result = PictureSize.hb_set_anamorphic_size2(this.GetPictureSettings(), this.GetPictureTitleInfo(), setting);
+
switch (this.SelectedAnamorphicMode)
{
case Anamorphic.None:
- // this.Width = result.OutputWidth;
- // this.Height = result.OutputHeight;
+ this.Task.Width = result.OutputWidth;
+ this.Task.Height = result.OutputHeight;
break;
case Anamorphic.Strict:
+ this.Task.Width = 0;
+ this.Task.Height = 0;
+ break;
case Anamorphic.Loose:
+ this.Task.Width = result.OutputWidth;
+ this.Task.Height = 0;
+ break;
case Anamorphic.Custom:
- double dispWidth = Math.Round((result.OutputWidth * result.OutputParWidth / result.OutputParHeight), 0);
- this.DisplaySize = this.sourceResolution.IsEmpty
- ? string.Empty
- : string.Format("Storage: {0}x{1}, Display: {2}x{3}", result.OutputWidth, result.OutputHeight, dispWidth, result.OutputHeight);
+ this.Task.Width = result.OutputWidth;
+ this.Task.Height = result.OutputHeight;
break;
}
+
+ // Step 3, Set the display width label to indicate the output.
+ double dispWidth = Math.Round((result.OutputWidth * result.OutputParWidth / result.OutputParHeight), 0);
+ this.DisplaySize = this.sourceResolution.IsEmpty
+ ? string.Empty
+ : string.Format("Storage: {0}x{1}, Display: {2}x{3}", result.OutputWidth, result.OutputHeight, dispWidth, result.OutputHeight);
+
+ // Step 4, Force an update on all the UI elements.
+ this.NotifyOfPropertyChange(() => this.Width);
+ this.NotifyOfPropertyChange(() => this.Height);
+ this.NotifyOfPropertyChange(() => this.ParWidth);
+ this.NotifyOfPropertyChange(() => this.ParHeight);
+ this.NotifyOfPropertyChange(() => this.CropTop);
+ this.NotifyOfPropertyChange(() => this.CropBottom);
+ this.NotifyOfPropertyChange(() => this.CropLeft);
+ this.NotifyOfPropertyChange(() => this.CropRight);
+ this.NotifyOfPropertyChange(() => this.SelectedModulus);
+ this.NotifyOfPropertyChange(() => this.MaintainAspectRatio);
+
+ // Step 5, Update the Preview
+ if (delayedPreviewprocessor != null && this.Task != null && this.StaticPreviewViewModel != null && this.StaticPreviewViewModel.IsOpen)
+ {
+ delayedPreviewprocessor.PerformTask(() => this.StaticPreviewViewModel.UpdatePreviewFrame(this.Task), 800);
+ }
}
/// <summary>
- /// Adjust other values after the user has altered the anamorphic.
+ /// The update visibile controls.
/// </summary>
- private void AnamorphicAdjust()
+ private void UpdateVisibileControls()
{
this.ShowDisplaySize = true;
this.ShowKeepAR = true;
+
switch (this.SelectedAnamorphicMode)
{
case Anamorphic.None:
@@ -886,32 +989,13 @@ namespace HandBrakeWPF.ViewModels
this.ShowModulus = true;
this.ShowDisplaySize = true;
this.ShowKeepAR = true;
- this.SelectedModulus = 16; // Reset
- if (this.Width == 0)
- {
- this.Width = this.GetModulusValue(this.sourceResolution.Width - this.CropLeft - this.CropRight);
- }
-
- if (!this.MaintainAspectRatio && this.Height == 0)
- {
- this.Height = this.GetModulusValue(this.sourceResolution.Height - this.CropTop - this.CropBottom);
- }
-
- this.MaintainAspectRatio = true;
-
- this.SetDisplaySize();
break;
case Anamorphic.Strict:
this.WidthControlEnabled = false;
this.HeightControlEnabled = false;
this.ShowCustomAnamorphicControls = false;
this.ShowModulus = false;
- this.SelectedModulus = 16; // Reset
this.ShowKeepAR = false;
-
- this.Width = 0;
- this.Height = 0;
- this.SetDisplaySize();
break;
case Anamorphic.Loose:
@@ -919,59 +1003,21 @@ namespace HandBrakeWPF.ViewModels
this.HeightControlEnabled = false;
this.ShowCustomAnamorphicControls = false;
this.ShowModulus = true;
-
- // Reset to the source size.
- this.Width = this.sourceResolution.Width;
- this.Height = 0; // this.sourceResolution.Height - this.CropTop - this.CropBottom;
this.ShowKeepAR = false;
-
- this.SetDisplaySize();
break;
case Anamorphic.Custom:
this.WidthControlEnabled = true;
this.HeightControlEnabled = true;
this.ShowCustomAnamorphicControls = true;
- this.MaintainAspectRatio = false; // TODO Fix when implementing custom
this.ShowModulus = true;
- this.ShowDisplaySize = false; // Disabled for Custom until we implement it properly. TODO
+ this.ShowDisplaySize = false;
this.ShowKeepAR = false;
-
- // Ignore any of the users current settings and reset to source to make things easier.
- this.Width = this.sourceResolution.Width;
- this.Height = this.sourceResolution.Height - this.CropTop - this.CropBottom;
-
- // Set the Display Width and set the Par X/Y to the source values initially.
- this.ParWidth = this.sourceParValues.Width;
- this.ParHeight = this.sourceParValues.Height;
- if (this.ParHeight != 0)
- {
- this.DisplayWidth = (this.Width * this.ParWidth / this.ParHeight);
- }
-
- // this.SetDisplaySize();
break;
}
}
/// <summary>
- /// Adjust other values after the user has altered one of the custom anamorphic settings
- /// </summary>
- private void CustomAnamorphicAdjust()
- {
- if (this.SelectedAnamorphicMode == Anamorphic.Custom)
- {
- if (this.MaintainAspectRatio && this.DisplayWidth != 0)
- {
- this.ParWidth = this.DisplayWidth;
- this.ParHeight = this.Width;
- }
-
- this.SetDisplaySize();
- }
- }
-
- /// <summary>
/// For a given value, correct so that it matches the users currently selected modulus value
/// </summary>
/// <param name="value">
@@ -1002,139 +1048,8 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
- /// Adjust other values after the user has altered the height
- /// </summary>
- private void HeightAdjust()
- {
- if (this.sourceResolution == new Size(0, 0))
- {
- return;
- }
-
- if (this.Height > this.sourceResolution.Height)
- {
- this.Task.Height = this.sourceResolution.Height;
- this.NotifyOfPropertyChange(() => this.Task.Height);
- }
-
- switch (this.SelectedAnamorphicMode)
- {
- case Anamorphic.None:
- if (this.MaintainAspectRatio)
- {
- double cropWidth = this.sourceResolution.Width - this.CropLeft - this.CropRight;
- double cropHeight = this.sourceResolution.Height - this.CropTop - this.CropBottom;
-
- double newWidth = ((double)this.Height * this.sourceResolution.Height * this.SourceAspect.Width *
- cropWidth) /
- ((double)this.sourceResolution.Width * this.SourceAspect.Height * cropHeight);
-
- this.Task.Width = this.GetModulusValue(newWidth);
- 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()
- {
- /*
- * Handle Anamorphic Display
- */
- if (this.SelectedAnamorphicMode != Anamorphic.None)
- {
- PictureSize.AnamorphicResult result = PictureSize.hb_set_anamorphic_size(this.GetPictureSettings(), this.GetPictureTitleInfo());
- double dispWidth = Math.Round((result.OutputWidth * result.OutputParWidth / result.OutputParHeight), 0);
-
- this.DisplaySize = this.sourceResolution.IsEmpty
- ? string.Format(Properties.Resources.PictureSettings_OutputResolution, "None")
- : string.Format("Output: {0}x{1}, Anamorphic: {2}x{3}", result.OutputWidth, result.OutputHeight, dispWidth, result.OutputHeight);
- }
- else
- {
- this.DisplaySize = this.sourceResolution.IsEmpty
- ? string.Empty
- : string.Format("Output: {0}x{1}", this.Width, this.Height);
- }
- }
-
- /// <summary>
- /// Adjust other values after the user has altered the width
+ /// The get res.
/// </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 cropWidth = this.sourceResolution.Width - this.CropLeft - this.CropRight;
- double cropHeight = 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 *
- cropHeight) /
- ((double)this.sourceResolution.Height * this.SourceAspect.Width * cropWidth);
-
- this.Task.Height = this.GetModulusValue(newHeight);
- this.NotifyOfPropertyChange(() => this.Height);
- }
- this.SetDisplaySize();
- break;
- case Anamorphic.Strict:
- this.Task.Width = 0;
- this.Task.Height = 0;
-
- this.NotifyOfPropertyChange(() => this.Width);
- this.NotifyOfPropertyChange(() => this.Height);
- this.SetDisplaySize();
- break;
- case Anamorphic.Loose:
- this.Task.Height = 0;
- this.NotifyOfPropertyChange(() => this.Width);
- this.NotifyOfPropertyChange(() => this.Height);
- this.SetDisplaySize();
- break;
- case Anamorphic.Custom:
- if (this.MaintainAspectRatio)
- {
- this.ParWidth = this.DisplayWidth;
- this.ParHeight = this.Width;
- }
-
- this.SetDisplaySize();
- break;
- }
- }
-
- /// <summary>
- /// Quick function to get the max resolution value
- /// </summary>
/// <param name="value">
/// The value.
/// </param>
@@ -1142,80 +1057,29 @@ namespace HandBrakeWPF.ViewModels
/// The max.
/// </param>
/// <returns>
- /// An Int
+ /// The <see cref="int"/>.
/// </returns>
- private int getRes(int value, int? max)
+ private int GetRes(int value, int? max)
{
return max.HasValue ? (value > max.Value ? max.Value : value) : value;
}
- /// <summary>
- /// The get picture title info.
- /// </summary>
- /// <returns>
- /// The <see cref="PictureSize.PictureSettingsTitle"/>.
- /// </returns>
- private PictureSize.PictureSettingsTitle GetPictureTitleInfo()
- {
- PictureSize.PictureSettingsTitle title = new PictureSize.PictureSettingsTitle
- {
- Width = this.sourceResolution.Width,
- Height = this.sourceResolution.Height,
- ParW = this.sourceParValues.Width,
- ParH = this.sourceParValues.Height,
- Aspect = 0 // TODO
- };
-
- return title;
- }
-
- /// <summary>
- /// The get picture settings.
- /// </summary>
- /// <returns>
- /// The <see cref="PictureSize.PictureSettingsJob"/>.
- /// </returns>
- private PictureSize.PictureSettingsJob GetPictureSettings()
- {
- PictureSize.PictureSettingsJob job = new PictureSize.PictureSettingsJob
- {
- Width = this.Width,
- Height = this.Height,
- ItuPar = false,
- Modulus = this.SelectedModulus,
- ParW = this.ParWidth,
- ParH = this.ParHeight,
- MaxWidth = this.MaxWidth,
- MaxHeight = this.MaxHeight,
- KeepDisplayAspect = this.MaintainAspectRatio,
- AnamorphicMode = this.SelectedAnamorphicMode,
- DarWidth = 0,
- DarHeight = 0,
- Crop = new Cropping(this.CropTop, this.CropBottom, this.CropLeft, this.CropRight),
- };
-
- if (this.SelectedAnamorphicMode == Anamorphic.Loose)
- {
- job.ParW = sourceParValues.Width;
- job.ParH = sourceParValues.Height;
- }
-
- return job;
- }
-
- /// <summary>
- /// Updates the preview after a period of time.
- /// This gives the user the opertunity to make changes in quick sucession without the image refreshing instantly
- /// and causing performance lag.
- /// </summary>
- private void UpdatePreviewImage()
- {
- if (delayedPreviewprocessor != null && this.Task != null && this.StaticPreviewViewModel != null && this.StaticPreviewViewModel.IsOpen)
- {
- delayedPreviewprocessor.PerformTask(() => this.StaticPreviewViewModel.UpdatePreviewFrame(this.Task), 800);
- }
- }
-
#endregion
}
+
+ /// <summary>
+ /// The changed picture field.
+ /// </summary>
+ enum ChangedPictureField
+ {
+ Width,
+ Height,
+ ParW,
+ ParH,
+ DisplayWidth,
+ Crop,
+ Anamorphic,
+ MaintainAspectRatio,
+ Modulus
+ }
} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Views/PictureSettingsView.xaml b/win/CS/HandBrakeWPF/Views/PictureSettingsView.xaml
index 93e630381..65d6dc1af 100644
--- a/win/CS/HandBrakeWPF/Views/PictureSettingsView.xaml
+++ b/win/CS/HandBrakeWPF/Views/PictureSettingsView.xaml
@@ -47,10 +47,12 @@
<!-- Row 2-->
<StackPanel Orientation="Horizontal" Margin="5,0,5,0">
<Label Content="Width:" />
- <controls:NumberBox Number="{Binding Width, Mode=TwoWay}" IsEnabled="{Binding WidthControlEnabled}" Modulus="{Binding SelectedModulus, Mode=OneWay}"
+ <controls:NumberBox Number="{Binding Width, Mode=TwoWay}" UpdateBindingOnTextChange="True" IsEnabled="{Binding WidthControlEnabled}"
+ Modulus="{Binding SelectedModulus, Mode=OneWay}"
Minimum="0" Width="60" />
<Label Content="Height:" />
- <controls:NumberBox Number="{Binding Height, Mode=TwoWay}" IsEnabled="{Binding HeightControlEnabled}" Modulus="{Binding SelectedModulus, Mode=OneWay}"
+ <controls:NumberBox Number="{Binding Height, Mode=TwoWay}" IsEnabled="{Binding HeightControlEnabled}" UpdateBindingOnTextChange="True"
+ Modulus="{Binding SelectedModulus, Mode=OneWay}"
Minimum="0" Width="60" />
<CheckBox Content="Keep Aspect Ratio" IsChecked="{Binding MaintainAspectRatio}"
Visibility="{Binding ShowKeepAR, Converter={StaticResource boolToVisHiddenConverter}}"