using System.Globalization;\r
using System.Windows.Forms;\r
using Handbrake.Parsing;\r
+using Handbrake.Presets;\r
\r
namespace Handbrake.Controls\r
{\r
lbl_Aspect.Text = _sourceTitle.AspectRatio.ToString(Culture);\r
lbl_src_res.Text = _sourceTitle.Resolution.Width + " x " + _sourceTitle.Resolution.Height;\r
\r
- // Set the Recommended Cropping values\r
- crop_top.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[0]);\r
- crop_bottom.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[1]);\r
- crop_left.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[2]);\r
- crop_right.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[3]);\r
+ // Set the Recommended Cropping values, but only if a preset doesn't have hard set picture settings.\r
+ if (CurrentlySelectedPreset != null && CurrentlySelectedPreset.PictureSettings == false)\r
+ {\r
+ crop_top.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[0]);\r
+ crop_bottom.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[1]);\r
+ crop_left.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[2]);\r
+ crop_right.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[3]);\r
+ }\r
+ else if (CurrentlySelectedPreset == null )\r
+ {\r
+ crop_top.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[0]);\r
+ crop_bottom.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[1]);\r
+ crop_left.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[2]);\r
+ crop_right.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[3]);\r
+ }\r
\r
// Set the Resolution Boxes\r
if (drp_anamorphic.SelectedIndex == 0)\r
\r
\r
Size croppedDar = CalculateAnamorphicSizes();\r
- _cachedDar = (double) croppedDar.Width/croppedDar.Height;\r
+ _cachedDar = (double)croppedDar.Width / croppedDar.Height;\r
updownDisplayWidth.Value = croppedDar.Width;\r
}\r
}\r
\r
+ /// <summary>\r
+ /// Which preset is currently selected by the user.\r
+ /// </summary>\r
+ public Preset CurrentlySelectedPreset { get; set; }\r
+\r
/// <summary>\r
/// Gets or sets the maximum allowable size for the encoded resolution. Set a value to\r
/// "0" if the maximum does not matter.\r
\r
// Calculate new Height Value\r
int modulus;\r
- if(!int.TryParse(drp_modulus.SelectedItem.ToString(), out modulus))\r
+ if (!int.TryParse(drp_modulus.SelectedItem.ToString(), out modulus))\r
modulus = 16;\r
\r
int rawCalculatedHeight = (int)((int)updownDisplayWidth.Value / _cachedDar);\r
- Uses mod16-compliant dimensions,\r
- Allows users to set the width\r
*/\r
- width = (int) text_width.Value;\r
+ width = (int)text_width.Value;\r
width = GetModulusValue(width); /* Time to get picture width that divide cleanly.*/\r
\r
height = (width / storage_aspect) + 0.5;\r
// Hidden UI feature to drop the MaxWidth / Height with the MaxWidth/Height label is double clicked\r
private void lbl_max_DoubleClick(object sender, EventArgs e)\r
{\r
- PresetMaximumResolution = new Size(0,0);\r
+ PresetMaximumResolution = new Size(0, 0);\r
if (PictureSettingsChanged != null)\r
PictureSettingsChanged(this, new EventArgs());\r
}\r
private SourceType selectedSourceType;\r
private string dvdDrivePath;\r
private string dvdDriveLabel;\r
+ private Preset CurrentlySelectedPreset;\r
\r
// Delegates **********************************************************\r
private delegate void UpdateWindowHandler();\r
private void changePresetLabel(object sender, EventArgs e)\r
{\r
labelPreset.Text = "Output Settings (Preset: Custom)";\r
+ CurrentlySelectedPreset = null;\r
}\r
\r
private static void frmMain_DragEnter(object sender, DragEventArgs e)\r
{\r
// Ok, so, we've selected a preset. Now we want to load it.\r
string presetName = treeView_presets.SelectedNode.Text;\r
- if (presetHandler.GetPreset(presetName) != null)\r
+ Preset preset = presetHandler.GetPreset(presetName);\r
+ if (preset != null)\r
{\r
string query = presetHandler.GetPreset(presetName).Query;\r
Boolean loadPictureSettings = presetHandler.GetPreset(presetName).PictureSettings;\r
// The x264 widgets will need updated, so do this now:\r
x264Panel.X264_StandardizeOptString();\r
x264Panel.X264_SetCurrentSettingsInPanel();\r
+\r
+ // Finally, let this window have a copy of the preset settings.\r
+ CurrentlySelectedPreset = preset;\r
}\r
}\r
}\r
{\r
selectedTitle = drp_dvdtitle.SelectedItem as Title;\r
lbl_duration.Text = selectedTitle.Duration.ToString();\r
+ PictureSettings.CurrentlySelectedPreset = CurrentlySelectedPreset;\r
PictureSettings.Source = selectedTitle; // Setup Picture Settings Tab Control\r
\r
// Populate the Angles dropdown\r