private readonly CultureInfo Culture = new CultureInfo("en-US", false);\r
public event EventHandler PictureSettingsChanged;\r
\r
- private Boolean preventChangingWidth, preventChangingHeight, preventChangingCustom, preventChangingDisplayWidth;\r
- private int _PresetMaximumWidth, _PresetMaximumHeight;\r
- private double cachedDar;\r
- private Title _SourceTitle;\r
+ private Boolean _preventChangingWidth, _preventChangingHeight, _preventChangingCustom, _preventChangingDisplayWidth;\r
+ private int _presetMaximumWidth, _presetMaximumHeight;\r
+ private double _cachedDar;\r
+ private Title _sourceTitle;\r
\r
public PictureSettings()\r
{\r
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\r
public Title Source\r
{\r
- get { return _SourceTitle; }\r
+ private get { return _sourceTitle; }\r
set\r
{\r
- _SourceTitle = value;\r
- Enabled = _SourceTitle != null;\r
+ _sourceTitle = value;\r
+ Enabled = _sourceTitle != null;\r
\r
// Set the Aspect Ratio\r
- lbl_Aspect.Text = _SourceTitle.AspectRatio.ToString(Culture);\r
- lbl_src_res.Text = _SourceTitle.Resolution.Width + " x " + _SourceTitle.Resolution.Height;\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
+ 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
// Set the Resolution Boxes\r
if (drp_anamorphic.SelectedIndex == 0)\r
{\r
if (text_width.Value == 0) // Only update the values if the fields don't already have values.\r
- text_width.Value = _SourceTitle.Resolution.Width;\r
+ text_width.Value = _sourceTitle.Resolution.Width;\r
\r
check_KeepAR.Checked = true; // Forces Resolution to be correct.\r
}\r
else\r
{\r
- if (text_width.Value == 0 && text_height.Value ==0)// Only update the values if the fields don't already have values.\r
- { \r
- text_width.Value = _SourceTitle.Resolution.Width;\r
- text_height.Value = _SourceTitle.Resolution.Height - (int) crop_top.Value - (int) crop_bottom.Value;\r
+ if (text_width.Value == 0 && text_height.Value == 0)// Only update the values if the fields don't already have values.\r
+ {\r
+ text_width.Value = _sourceTitle.Resolution.Width;\r
+ text_height.Value = _sourceTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;\r
}\r
\r
- labelDisplaySize.Text = calculateAnamorphicSizes().Width + "x" + calculateAnamorphicSizes().Height;\r
+ labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height;\r
}\r
\r
- updownDisplayWidth.Value = calculateAnamorphicSizes().Width;\r
- updownParWidth.Value = _SourceTitle.ParVal.Width;\r
- updownParHeight.Value = _SourceTitle.ParVal.Height;\r
- cachedDar = (double)updownDisplayWidth.Value / (double)text_height.Value;\r
+ updownDisplayWidth.Value = CalculateAnamorphicSizes().Width;\r
+ updownParWidth.Value = _sourceTitle.ParVal.Width;\r
+ updownParHeight.Value = _sourceTitle.ParVal.Height;\r
+ _cachedDar = (double)updownDisplayWidth.Value / (double)text_height.Value;\r
}\r
}\r
\r
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\r
public Size PresetMaximumResolution\r
{\r
- get { return new Size(_PresetMaximumWidth, _PresetMaximumHeight); }\r
+ get { return new Size(_presetMaximumWidth, _presetMaximumHeight); }\r
set\r
{\r
- _PresetMaximumWidth = value.Width;\r
- _PresetMaximumHeight = value.Height;\r
+ _presetMaximumWidth = value.Width;\r
+ _presetMaximumHeight = value.Height;\r
\r
if (value.Width != 0 && value.Height != 0)\r
lbl_max.Text = "Max Width / Height";\r
// Picture Controls\r
private void text_width_ValueChanged(object sender, EventArgs e)\r
{\r
- if (preventChangingWidth)\r
+ if (_preventChangingWidth)\r
return;\r
\r
// Make sure the new value doesn't exceed the maximum\r
case 0:\r
if (check_KeepAR.Checked && Source != null)\r
{\r
- preventChangingHeight = true;\r
+ _preventChangingHeight = true;\r
\r
int width = (int)text_width.Value;\r
\r
- double crop_width = Source.Resolution.Width - (double)crop_left.Value - (double)crop_right.Value;\r
- double crop_height = Source.Resolution.Height - (double)crop_top.Value - (double)crop_bottom.Value;\r
- double newHeight = (width * Source.Resolution.Width * sourceAspect.Height * crop_height) /\r
- (Source.Resolution.Height * sourceAspect.Width * crop_width);\r
+ double crop_width = Source.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value;\r
+ double crop_height = Source.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;\r
+\r
+ if (SourceAspect.Width == 0 && SourceAspect.Height == 0)\r
+ break;\r
+\r
+ double newHeight = ((double)width * Source.Resolution.Width * SourceAspect.Height * crop_height) /\r
+ (Source.Resolution.Height * SourceAspect.Width * crop_width);\r
text_height.Value = (decimal)GetModulusValue(newHeight);\r
\r
- preventChangingHeight = false;\r
+ _preventChangingHeight = false;\r
}\r
break;\r
case 3:\r
if (check_KeepAR.CheckState == CheckState.Unchecked && Source != null)\r
{\r
- if (preventChangingCustom)\r
+ if (_preventChangingCustom)\r
break;\r
\r
- preventChangingDisplayWidth = true;\r
+ _preventChangingDisplayWidth = true;\r
updownDisplayWidth.Value = text_width.Value * updownParWidth.Value / updownParHeight.Value;\r
- preventChangingDisplayWidth = false;\r
+ _preventChangingDisplayWidth = false;\r
\r
labelDisplaySize.Text = Math.Truncate(updownDisplayWidth.Value) + "x" + text_height.Value;\r
}\r
}\r
break;\r
default:\r
- labelDisplaySize.Text = calculateAnamorphicSizes().Width + "x" + calculateAnamorphicSizes().Height;\r
+ labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height;\r
break;\r
}\r
\r
- preventChangingWidth = false;\r
+ _preventChangingWidth = false;\r
}\r
private void text_height_ValueChanged(object sender, EventArgs e)\r
{\r
- if (preventChangingHeight)\r
+ if (_preventChangingHeight)\r
return;\r
\r
if (Source != null)\r
case 0:\r
if (check_KeepAR.Checked && Source != null)\r
{\r
- preventChangingWidth = true;\r
+ _preventChangingWidth = true;\r
\r
- double crop_width = Source.Resolution.Width - (double)crop_left.Value - (double)crop_right.Value;\r
- double crop_height = Source.Resolution.Height - (double)crop_top.Value - (double)crop_bottom.Value;\r
+ double crop_width = Source.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value;\r
+ double crop_height = Source.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;\r
\r
- double new_width = ((double)text_height.Value * Source.Resolution.Height * sourceAspect.Width * crop_width) /\r
- (Source.Resolution.Width * sourceAspect.Height * crop_height);\r
+ double new_width = ((double)text_height.Value * Source.Resolution.Height * SourceAspect.Width * crop_width) /\r
+ (Source.Resolution.Width * SourceAspect.Height * crop_height);\r
\r
text_width.Value = (decimal)GetModulusValue(new_width);\r
\r
- preventChangingWidth = false;\r
+ _preventChangingWidth = false;\r
}\r
break;\r
case 3:\r
// - Changes PIXEL HEIGHT to STORAGE WIDTH\r
// DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)\r
\r
- double rawCalculatedDisplayWidth = (double)text_height.Value * cachedDar;\r
+ double rawCalculatedDisplayWidth = (double)text_height.Value * _cachedDar;\r
\r
- preventChangingDisplayWidth = true; // Start Guards\r
- preventChangingWidth = true;\r
+ _preventChangingDisplayWidth = true; // Start Guards\r
+ _preventChangingWidth = true;\r
\r
updownDisplayWidth.Value = (decimal)rawCalculatedDisplayWidth;\r
updownParWidth.Value = updownDisplayWidth.Value;\r
updownParHeight.Value = text_width.Value;\r
\r
- preventChangingWidth = false; // Reset Guards\r
- preventChangingDisplayWidth = false;\r
+ _preventChangingWidth = false; // Reset Guards\r
+ _preventChangingDisplayWidth = false;\r
}\r
\r
break;\r
default:\r
- labelDisplaySize.Text = calculateAnamorphicSizes().Width + "x" + calculateAnamorphicSizes().Height;\r
+ labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height;\r
break;\r
}\r
\r
- preventChangingHeight = false;\r
+ _preventChangingHeight = false;\r
}\r
private void check_KeepAR_CheckedChanged(object sender, EventArgs e)\r
{\r
}\r
private void updownDisplayWidth_ValueChanged(object sender, EventArgs e)\r
{\r
- if (preventChangingDisplayWidth == false && check_KeepAR.CheckState == CheckState.Unchecked)\r
+ if (_preventChangingDisplayWidth == false && check_KeepAR.CheckState == CheckState.Unchecked)\r
{\r
- preventChangingCustom = true;\r
+ _preventChangingCustom = true;\r
updownParWidth.Value = updownDisplayWidth.Value;\r
updownParHeight.Value = text_width.Value;\r
- preventChangingCustom = false;\r
+ _preventChangingCustom = false;\r
}\r
\r
- if (preventChangingDisplayWidth == false && check_KeepAR.CheckState == CheckState.Checked)\r
+ if (_preventChangingDisplayWidth == false && check_KeepAR.CheckState == CheckState.Checked)\r
{\r
// - Changes HEIGHT to keep DAR\r
// - Changes PIXEL WIDTH to new DISPLAY WIDTH\r
int modulus = 16;\r
int.TryParse(drp_modulus.SelectedItem.ToString(), out modulus);\r
\r
- int rawCalculatedHeight = (int)((int)updownDisplayWidth.Value / cachedDar);\r
+ int rawCalculatedHeight = (int)((int)updownDisplayWidth.Value / _cachedDar);\r
int modulusHeight = rawCalculatedHeight - (rawCalculatedHeight % modulus);\r
\r
// Update value\r
- preventChangingHeight = true;\r
+ _preventChangingHeight = true;\r
text_height.Value = (decimal)modulusHeight;\r
updownParWidth.Value = updownDisplayWidth.Value;\r
updownParHeight.Value = text_width.Value;\r
- preventChangingHeight = false;\r
+ _preventChangingHeight = false;\r
}\r
\r
}\r
text_height.Enabled = true;\r
check_KeepAR.Enabled = true;\r
\r
- setCustomAnamorphicOptionsVisible(false);\r
+ SetCustomAnamorphicOptionsVisible(false);\r
labelStaticDisplaySize.Visible = false;\r
labelDisplaySize.Visible = false;\r
\r
text_height.Enabled = false;\r
check_KeepAR.Enabled = false;\r
\r
- setCustomAnamorphicOptionsVisible(false);\r
+ SetCustomAnamorphicOptionsVisible(false);\r
labelStaticDisplaySize.Visible = true;\r
labelDisplaySize.Visible = true;\r
drp_modulus.SelectedIndex = 0;\r
text_height.Enabled = false;\r
check_KeepAR.Enabled = false;\r
\r
- setCustomAnamorphicOptionsVisible(false);\r
+ SetCustomAnamorphicOptionsVisible(false);\r
labelStaticDisplaySize.Visible = true;\r
labelDisplaySize.Visible = true;\r
drp_modulus.SelectedIndex = 0;\r
text_height.Enabled = true;\r
check_KeepAR.Enabled = true;\r
\r
- setCustomAnamorphicOptionsVisible(true);\r
+ SetCustomAnamorphicOptionsVisible(true);\r
labelStaticDisplaySize.Visible = true;\r
labelDisplaySize.Visible = true;\r
\r
break;\r
}\r
\r
- labelDisplaySize.Text = calculateAnamorphicSizes().Width + "x" + calculateAnamorphicSizes().Height;\r
+ labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height;\r
\r
if (check_KeepAR.Checked)\r
text_width_ValueChanged(this, new EventArgs());\r
}\r
private void drp_modulus_SelectedIndexChanged(object sender, EventArgs e)\r
{\r
- preventChangingWidth = true;\r
- preventChangingHeight = true;\r
+ _preventChangingWidth = true;\r
+ _preventChangingHeight = true;\r
\r
text_width.Value = (decimal)GetModulusValue((double)text_width.Value);\r
text_height.Value = (decimal)GetModulusValue((double)text_height.Value);\r
\r
- preventChangingWidth = false;\r
- preventChangingHeight = false;\r
+ _preventChangingWidth = false;\r
+ _preventChangingHeight = false;\r
\r
text_width.Increment = int.Parse(drp_modulus.SelectedItem.ToString());\r
text_height.Increment = int.Parse(drp_modulus.SelectedItem.ToString());\r
}\r
\r
// GUI Functions\r
- private void setCustomAnamorphicOptionsVisible(bool visible)\r
+ private void SetCustomAnamorphicOptionsVisible(bool visible)\r
{\r
lbl_modulus.Visible = visible;\r
lbl_displayWidth.Visible = visible;\r
}\r
\r
// Calculation Functions\r
- private Size sourceAspect\r
+ private Size SourceAspect\r
{\r
get\r
{\r
- if (Source != null)\r
- {\r
- if (Source.AspectRatio == 1.78F)\r
- return new Size(16, 9);\r
- if (Source.AspectRatio == 1.33F)\r
- return new Size(4, 3);\r
- }\r
- return new Size(0, 0);\r
+ if (Source != null) // display aspect = (width * par_width) / (height * par_height)\r
+ return new Size((Source.ParVal.Width * Source.Resolution.Width), (Source.ParVal.Height * Source.Resolution.Height));\r
+\r
+ return new Size(0, 0); // Fall over to 16:9 and hope for the best\r
}\r
}\r
- private Size calculateAnamorphicSizes()\r
+ private Size CalculateAnamorphicSizes()\r
{\r
if (Source != null)\r
{\r
double width, height;\r
switch (drp_anamorphic.SelectedIndex)\r
{\r
+ default:\r
case 1:\r
/* Strict anamorphic */\r
double displayWidth = ((double)cropped_width * Source.ParVal.Width / Source.ParVal.Height);\r