Suggested values are: 18 to 20 for Standard Definition and 20 to 23 for High Definition.</value>\r
</data>\r
<data name="AddPreset_PictureSizeMode" xml:space="preserve">\r
- <value>You can optionally store a maximum resolution for encodes that use this preset. There are 3 modes:\r
+ <value>You can optionally store a maximum resolution for encodes that use this preset. There are 4 modes:\r
\r
-None: There is no maximum resolution for encodes using this preset. They will always use the source resolution minus any cropping that may be applied.\r
+None: There is no maximum resolution for encodes using this preset. When the preset is loaded, the current width, height and aspect ratio that you currently have set will be reloaded.\r
\r
-Custom: You can optionally set a Maximum width and height. When doing this an encode will be less than or equal to these values.\r
+Custom: You can optionally set a Maximum width and Height. When doing this an encode will be less than or equal to these values. Keep Aspect Ratio will be automatically turned on.\r
\r
-Source Maximum: Similar to custom, but the resolution of your current source is used as the Max width and Height values instead.</value>\r
+Source Maximum: Similar to custom, but the resolution of your current source is used as the Max width and Height values instead. Keep Aspect Ratio will be automatically turned on.\r
+\r
+No Limit: Always use the full source resolution for all sources keeping aspect ratio. This is the default behaviour.</value>\r
</data>\r
<data name="Advanced_EncoderOptions" xml:space="preserve">\r
<value>The options passed to the x264 encoder. \r
using System.Windows;\r
\r
using HandBrake.ApplicationServices.Model;\r
+ using HandBrake.ApplicationServices.Parsing;\r
using HandBrake.ApplicationServices.Services;\r
using HandBrake.ApplicationServices.Services.Interfaces;\r
using HandBrake.ApplicationServices.Utilities;\r
/// </summary>\r
public class AddPresetViewModel : ViewModelBase, IAddPresetViewModel\r
{\r
- /* TODO this window is up for redesign. Quite a few nippy edge cases that can cause odd behaviour with importing presets. */\r
-\r
/// <summary>\r
/// Backing field for the Preset Service\r
/// </summary>\r
/// </summary>\r
private bool showCustomInputs;\r
\r
+ /// <summary>\r
+ /// The source.\r
+ /// </summary>\r
+ private Title selectedTitle;\r
+\r
/// <summary>\r
/// Initializes a new instance of the <see cref="AddPresetViewModel"/> class.\r
/// </summary>\r
/// <param name="task">\r
/// The Encode Task.\r
/// </param>\r
- public void Setup(EncodeTask task)\r
+ public void Setup(EncodeTask task, Title title)\r
{\r
this.Preset.Task = new EncodeTask(task);\r
+ this.selectedTitle = title;\r
}\r
\r
/// <summary>\r
}\r
}\r
\r
- if (this.SelectedPictureSettingMode == PresetPictureSettingsMode.SourceMaximum && (this.Preset.Task.Width == null || this.Preset.Task.Width == 0))\r
+ if (this.SelectedPictureSettingMode == PresetPictureSettingsMode.SourceMaximum && this.selectedTitle == null)\r
{\r
this.errorService.ShowMessageBox("You must first scan a source to use the 'Source Maximum' Option.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);\r
return;\r
\r
if (this.SelectedPictureSettingMode == PresetPictureSettingsMode.SourceMaximum)\r
{\r
- this.Preset.Task.MaxWidth = this.Preset.Task.Width;\r
- this.Preset.Task.MaxHeight = this.Preset.Task.Height;\r
+ this.Preset.Task.MaxWidth = selectedTitle.Resolution.Width;\r
+ this.Preset.Task.MaxHeight = selectedTitle.Resolution.Height;\r
}\r
\r
// Add the Preset\r
{\r
this.Task = task;\r
\r
- // TODO: These all need to be handled correctly.\r
+ // Anamorphic Mode\r
this.SelectedAnamorphicMode = preset.Task.Anamorphic;\r
\r
- // Set the limits on the UI Controls.\r
- this.MaxWidth = preset.Task.MaxWidth ?? this.sourceResolution.Width;\r
- this.MaxHeight = preset.Task.MaxHeight ?? this.sourceResolution.Height;\r
- this.Task.MaxWidth = preset.Task.MaxWidth;\r
- this.Task.MaxHeight = preset.Task.MaxHeight;\r
-\r
- // Setup the Width\r
- if (preset.Task.MaxWidth.HasValue)\r
+ // Modulus\r
+ if (preset.Task.Modulus.HasValue)\r
{\r
- if (this.Width > preset.Task.MaxWidth)\r
- {\r
- // Limit the Width to the Max Width\r
- this.Width = preset.Task.MaxWidth.Value; \r
- }\r
- else\r
- {\r
- // Figure out the best width based on the preset and source\r
- this.Width = preset.Task.Width ?? this.GetModulusValue(this.getRes((this.sourceResolution.Width - this.CropLeft - this.CropRight), preset.Task.MaxWidth.Value));\r
- }\r
+ this.SelectedModulus = preset.Task.Modulus;\r
}\r
- else\r
+\r
+ // Set the Maintain Aspect ratio.\r
+ this.MaintainAspectRatio = preset.Task.Anamorphic == Anamorphic.None && preset.Task.KeepDisplayAspect;\r
+\r
+ // Handle built-in presets.\r
+ if (preset.IsBuildIn)\r
{\r
- this.Width = preset.Task.Width ?? this.GetModulusValue((this.sourceResolution.Width - this.CropLeft - this.CropRight));\r
+ preset.PictureSettingsMode = PresetPictureSettingsMode.Custom;\r
}\r
\r
- // Set the Maintain Aspect ratio. This will calculate Height for us now.\r
- this.MaintainAspectRatio = preset.Task.Anamorphic == Anamorphic.None || preset.Task.KeepDisplayAspect;\r
-\r
- // Set Height, but only if necessary.\r
- if (preset.Task.MaxHeight.HasValue)\r
+ // Setup the Picture Sizes\r
+ switch (preset.PictureSettingsMode)\r
{\r
- if (this.Height > preset.Task.MaxHeight)\r
- {\r
- // Limit the Height to the Max Height of the preset. Setting this will recalculate the width.\r
- this.Height = preset.Task.MaxHeight.Value;\r
- }\r
- else\r
- {\r
- // Only calculate height if Maintain Aspect ratio is off.\r
- if (!this.MaintainAspectRatio)\r
+ default:\r
+ case PresetPictureSettingsMode.Custom:\r
+ case PresetPictureSettingsMode.SourceMaximum:\r
+ this.MaintainAspectRatio = true;\r
+\r
+ // Set the width, then check the height doesn't breach the max height and correct if necessary.\r
+ int width = this.GetModulusValue(this.getRes((this.sourceResolution.Width - this.CropLeft - this.CropRight), preset.Task.MaxWidth));\r
+ this.Width = width;\r
+\r
+ // If we have a max height, make sure we havn't breached it.\r
+ int height = this.GetModulusValue(this.getRes((this.sourceResolution.Height - this.CropTop - this.CropBottom), preset.Task.MaxHeight));\r
+ if (preset.Task.MaxHeight.HasValue && this.Height > preset.Task.MaxHeight.Value)\r
{\r
- this.Height = preset.Task.Height ??\r
- this.getRes(\r
- (this.sourceResolution.Height - this.CropTop - this.CropBottom),\r
- preset.Task.MaxHeight.Value);\r
+ this.Height = height;\r
}\r
- }\r
+\r
+ this.MaxWidth = width;\r
+ this.MaxHeight = height;\r
+ break;\r
+ case PresetPictureSettingsMode.NoLimit:\r
+ this.MaintainAspectRatio = true;\r
+ this.Width = this.GetModulusValue(this.sourceResolution.Width - this.CropLeft - this.CropRight);\r
+\r
+ this.MaxWidth = this.sourceResolution.Width;\r
+ this.MaxHeight = this.sourceResolution.Height;\r
+ break;\r
+ case PresetPictureSettingsMode.None:\r
+\r
+ if (preset.Task.Width.HasValue)\r
+ {\r
+ this.Width = this.GetModulusValue(preset.Task.Width.Value - this.CropLeft - this.CropRight);\r
+ }\r
+\r
+ if (!this.MaintainAspectRatio && preset.Task.Height.HasValue)\r
+ {\r
+ this.Height = this.GetModulusValue(preset.Task.Height.Value - this.CropTop - this.CropBottom);\r
+ }\r
+\r
+ this.MaxWidth = this.sourceResolution.Width;\r
+ this.MaxHeight = this.sourceResolution.Height;\r
+ break;\r
}\r
\r
- // Anamorphic\r
+ // Custom Anamorphic\r
if (preset.Task.Anamorphic == Anamorphic.Custom)\r
{\r
this.DisplayWidth = preset.Task.DisplayWidth != null ? int.Parse(preset.Task.DisplayWidth.ToString()) : 0;\r
this.ParHeight = preset.Task.PixelAspectY;\r
}\r
\r
- // Modulus\r
- if (preset.Task.Modulus.HasValue)\r
- {\r
- this.SelectedModulus = preset.Task.Modulus;\r
- }\r
-\r
// Cropping\r
if (preset.Task.HasCropping)\r
{\r
}\r
\r
// Set the Width, and Maintain Aspect ratio. That should calc the Height for us.\r
- this.Width = this.MaxWidth;\r
- this.MaintainAspectRatio = true;\r
+ this.Width = preset.Task.Width ?? this.MaxWidth;\r
\r
// If our height is too large, let it downscale the width for us by setting the height to the lower value.\r
if (this.Height > this.MaxHeight)\r
{\r
this.Height = this.MaxHeight;\r
}\r
- \r
+\r
if (this.SelectedAnamorphicMode == Anamorphic.Custom)\r
{\r
this.AnamorphicAdjust(); // Refresh the values\r
/// <returns>\r
/// An Int\r
/// </returns>\r
- private int getRes(int value, int max)\r
+ private int getRes(int value, int? max)\r
{\r
- return value > max ? max : value;\r
+ return max.HasValue ? (value > max.Value ? max.Value : value) : value;\r
}\r
\r
#endregion\r