summaryrefslogtreecommitdiffstats
path: root/win/C#/Controls
diff options
context:
space:
mode:
authorsr55 <[email protected]>2010-02-19 20:57:25 +0000
committersr55 <[email protected]>2010-02-19 20:57:25 +0000
commit5ac461efefc4220228002fb6d9cc8ecbaf9e8029 (patch)
tree4c48d792deef249a37c7931ab775e3c34607aa21 /win/C#/Controls
parent42b5c877042e8882e27f34741013c4ff1f504d56 (diff)
WinGui:
- Some in progress re-factoring. - Enable Modulus for none/loose picture setting modes. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3127 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Controls')
-rw-r--r--win/C#/Controls/Filters.Designer.cs10
-rw-r--r--win/C#/Controls/Filters.cs12
-rw-r--r--win/C#/Controls/PictureSettings.Designer.cs28
-rw-r--r--win/C#/Controls/PictureSettings.cs248
-rw-r--r--win/C#/Controls/Subtitles.Designer.cs28
-rw-r--r--win/C#/Controls/Subtitles.cs241
-rw-r--r--win/C#/Controls/x264Panel.cs2
7 files changed, 356 insertions, 213 deletions
diff --git a/win/C#/Controls/Filters.Designer.cs b/win/C#/Controls/Filters.Designer.cs
index bdcc9c6eb..33531caa1 100644
--- a/win/C#/Controls/Filters.Designer.cs
+++ b/win/C#/Controls/Filters.Designer.cs
@@ -86,7 +86,7 @@
this.drop_detelecine.Name = "drop_detelecine";
this.drop_detelecine.Size = new System.Drawing.Size(174, 21);
this.drop_detelecine.TabIndex = 45;
- this.drop_detelecine.SelectedIndexChanged += new System.EventHandler(this.drop_detelecine_SelectedIndexChanged);
+ this.drop_detelecine.SelectedIndexChanged += new System.EventHandler(this.DropDetelecineSelectedIndexChanged);
//
// text_customDC
//
@@ -124,7 +124,7 @@
this.drop_decomb.Name = "drop_decomb";
this.drop_decomb.Size = new System.Drawing.Size(174, 21);
this.drop_decomb.TabIndex = 48;
- this.drop_decomb.SelectedIndexChanged += new System.EventHandler(this.drop_decomb_SelectedIndexChanged);
+ this.drop_decomb.SelectedIndexChanged += new System.EventHandler(this.DropDecombSelectedIndexChanged);
//
// text_customDI
//
@@ -164,7 +164,7 @@
this.drop_deinterlace.Name = "drop_deinterlace";
this.drop_deinterlace.Size = new System.Drawing.Size(174, 21);
this.drop_deinterlace.TabIndex = 51;
- this.drop_deinterlace.SelectedIndexChanged += new System.EventHandler(this.drop_deinterlace_SelectedIndexChanged);
+ this.drop_deinterlace.SelectedIndexChanged += new System.EventHandler(this.DropDeinterlaceSelectedIndexChanged);
//
// text_customDN
//
@@ -204,7 +204,7 @@
this.drop_denoise.Name = "drop_denoise";
this.drop_denoise.Size = new System.Drawing.Size(174, 21);
this.drop_denoise.TabIndex = 54;
- this.drop_denoise.SelectedIndexChanged += new System.EventHandler(this.drop_denoise_SelectedIndexChanged);
+ this.drop_denoise.SelectedIndexChanged += new System.EventHandler(this.DropDenoiseSelectedIndexChanged);
//
// slider_deblock
//
@@ -218,7 +218,7 @@
this.slider_deblock.Size = new System.Drawing.Size(174, 45);
this.slider_deblock.TabIndex = 58;
this.slider_deblock.Value = 4;
- this.slider_deblock.Scroll += new System.EventHandler(this.slider_deblock_Scroll);
+ this.slider_deblock.Scroll += new System.EventHandler(this.SliderDeblockScroll);
//
// check_grayscale
//
diff --git a/win/C#/Controls/Filters.cs b/win/C#/Controls/Filters.cs
index 6f8d3afd5..adf7bde16 100644
--- a/win/C#/Controls/Filters.cs
+++ b/win/C#/Controls/Filters.cs
@@ -31,7 +31,7 @@ namespace Handbrake.Controls
/// <summary>
/// Returns the CLI query for the query generator.
/// </summary>
- public string GetCLIQuery
+ public string GetCliQuery
{
get
{
@@ -262,14 +262,14 @@ namespace Handbrake.Controls
}
// Controls
- private void drop_detelecine_SelectedIndexChanged(object sender, EventArgs e)
+ private void DropDetelecineSelectedIndexChanged(object sender, EventArgs e)
{
text_customDT.Visible = drop_detelecine.Text == "Custom";
// A Filter has changed so raise a FilterSettingsChanged event.
if (this.FilterSettingsChanged != null)
this.FilterSettingsChanged(this, new EventArgs());
}
- private void drop_decomb_SelectedIndexChanged(object sender, EventArgs e)
+ private void DropDecombSelectedIndexChanged(object sender, EventArgs e)
{
text_customDC.Visible = drop_decomb.Text == "Custom";
if (drop_decomb.SelectedIndex != 0 && drop_deinterlace.SelectedIndex != 0)
@@ -279,7 +279,7 @@ namespace Handbrake.Controls
if (this.FilterSettingsChanged != null)
this.FilterSettingsChanged(this, new EventArgs());
}
- private void drop_deinterlace_SelectedIndexChanged(object sender, EventArgs e)
+ private void DropDeinterlaceSelectedIndexChanged(object sender, EventArgs e)
{
text_customDI.Visible = drop_deinterlace.Text == "Custom";
if (drop_decomb.SelectedIndex != 0 && drop_deinterlace.SelectedIndex != 0)
@@ -289,7 +289,7 @@ namespace Handbrake.Controls
if (this.FilterSettingsChanged != null)
this.FilterSettingsChanged(this, new EventArgs());
}
- private void drop_denoise_SelectedIndexChanged(object sender, EventArgs e)
+ private void DropDenoiseSelectedIndexChanged(object sender, EventArgs e)
{
text_customDN.Visible = drop_denoise.Text == "Custom";
@@ -297,7 +297,7 @@ namespace Handbrake.Controls
if (this.FilterSettingsChanged != null)
this.FilterSettingsChanged(this, new EventArgs());
}
- private void slider_deblock_Scroll(object sender, EventArgs e)
+ private void SliderDeblockScroll(object sender, EventArgs e)
{
lbl_deblockVal.Text = slider_deblock.Value == 4 ? "Off" : slider_deblock.Value.ToString();
diff --git a/win/C#/Controls/PictureSettings.Designer.cs b/win/C#/Controls/PictureSettings.Designer.cs
index 67b427a2e..96953ac53 100644
--- a/win/C#/Controls/PictureSettings.Designer.cs
+++ b/win/C#/Controls/PictureSettings.Designer.cs
@@ -142,7 +142,7 @@ namespace Handbrake.Controls
this.crop_left.Name = "crop_left";
this.crop_left.Size = new System.Drawing.Size(44, 21);
this.crop_left.TabIndex = 98;
- this.crop_left.ValueChanged += new System.EventHandler(this.crop_ValueChanged);
+ this.crop_left.ValueChanged += new System.EventHandler(this.CropValueChanged);
//
// crop_right
//
@@ -161,7 +161,7 @@ namespace Handbrake.Controls
this.crop_right.Name = "crop_right";
this.crop_right.Size = new System.Drawing.Size(44, 21);
this.crop_right.TabIndex = 101;
- this.crop_right.ValueChanged += new System.EventHandler(this.crop_ValueChanged);
+ this.crop_right.ValueChanged += new System.EventHandler(this.CropValueChanged);
//
// check_autoCrop
//
@@ -177,7 +177,7 @@ namespace Handbrake.Controls
this.check_autoCrop.TabStop = true;
this.check_autoCrop.Text = "Automatic";
this.check_autoCrop.UseVisualStyleBackColor = true;
- this.check_autoCrop.CheckedChanged += new System.EventHandler(this.check_autoCrop_CheckedChanged);
+ this.check_autoCrop.CheckedChanged += new System.EventHandler(this.CheckAutoCropCheckedChanged);
//
// Label51
//
@@ -209,7 +209,7 @@ namespace Handbrake.Controls
this.crop_top.Name = "crop_top";
this.crop_top.Size = new System.Drawing.Size(44, 21);
this.crop_top.TabIndex = 100;
- this.crop_top.ValueChanged += new System.EventHandler(this.crop_ValueChanged);
+ this.crop_top.ValueChanged += new System.EventHandler(this.CropValueChanged);
//
// Label53
//
@@ -254,7 +254,7 @@ namespace Handbrake.Controls
this.crop_bottom.Name = "crop_bottom";
this.crop_bottom.Size = new System.Drawing.Size(44, 21);
this.crop_bottom.TabIndex = 103;
- this.crop_bottom.ValueChanged += new System.EventHandler(this.crop_ValueChanged);
+ this.crop_bottom.ValueChanged += new System.EventHandler(this.CropValueChanged);
//
// check_customCrop
//
@@ -374,7 +374,7 @@ namespace Handbrake.Controls
this.text_width.Name = "text_width";
this.text_width.Size = new System.Drawing.Size(64, 21);
this.text_width.TabIndex = 85;
- this.text_width.ValueChanged += new System.EventHandler(this.text_width_ValueChanged);
+ this.text_width.ValueChanged += new System.EventHandler(this.TextWidthValueChanged);
//
// lbl_max
//
@@ -387,7 +387,7 @@ namespace Handbrake.Controls
this.lbl_max.Size = new System.Drawing.Size(15, 13);
this.lbl_max.TabIndex = 83;
this.lbl_max.Text = "--";
- this.lbl_max.DoubleClick += new System.EventHandler(this.lbl_max_DoubleClick);
+ this.lbl_max.DoubleClick += new System.EventHandler(this.LblMaxDoubleClick);
//
// label4
//
@@ -414,7 +414,7 @@ namespace Handbrake.Controls
this.text_height.Name = "text_height";
this.text_height.Size = new System.Drawing.Size(64, 21);
this.text_height.TabIndex = 86;
- this.text_height.ValueChanged += new System.EventHandler(this.text_height_ValueChanged);
+ this.text_height.ValueChanged += new System.EventHandler(this.TextHeightValueChanged);
//
// check_KeepAR
//
@@ -429,7 +429,7 @@ namespace Handbrake.Controls
this.check_KeepAR.TabIndex = 95;
this.check_KeepAR.Text = "Keep Aspect Ratio";
this.check_KeepAR.UseVisualStyleBackColor = true;
- this.check_KeepAR.CheckedChanged += new System.EventHandler(this.check_KeepAR_CheckedChanged);
+ this.check_KeepAR.CheckedChanged += new System.EventHandler(this.CheckKeepArCheckedChanged);
//
// tableLayoutPanel1
//
@@ -473,7 +473,7 @@ namespace Handbrake.Controls
this.updownParHeight.Name = "updownParHeight";
this.updownParHeight.Size = new System.Drawing.Size(53, 21);
this.updownParHeight.TabIndex = 112;
- this.updownParHeight.ValueChanged += new System.EventHandler(this.text_width_ValueChanged);
+ this.updownParHeight.ValueChanged += new System.EventHandler(this.TextWidthValueChanged);
//
// label6
//
@@ -537,7 +537,7 @@ namespace Handbrake.Controls
this.updownParWidth.Name = "updownParWidth";
this.updownParWidth.Size = new System.Drawing.Size(53, 21);
this.updownParWidth.TabIndex = 111;
- this.updownParWidth.ValueChanged += new System.EventHandler(this.text_width_ValueChanged);
+ this.updownParWidth.ValueChanged += new System.EventHandler(this.TextWidthValueChanged);
//
// drp_anamorphic
//
@@ -552,7 +552,7 @@ namespace Handbrake.Controls
this.drp_anamorphic.Name = "drp_anamorphic";
this.drp_anamorphic.Size = new System.Drawing.Size(110, 21);
this.drp_anamorphic.TabIndex = 82;
- this.drp_anamorphic.SelectedIndexChanged += new System.EventHandler(this.drp_anamorphic_SelectedIndexChanged);
+ this.drp_anamorphic.SelectedIndexChanged += new System.EventHandler(this.DrpAnamorphicSelectedIndexChanged);
//
// lbl_parWidth
//
@@ -578,7 +578,7 @@ namespace Handbrake.Controls
this.updownDisplayWidth.Name = "updownDisplayWidth";
this.updownDisplayWidth.Size = new System.Drawing.Size(53, 21);
this.updownDisplayWidth.TabIndex = 110;
- this.updownDisplayWidth.ValueChanged += new System.EventHandler(this.updownDisplayWidth_ValueChanged);
+ this.updownDisplayWidth.ValueChanged += new System.EventHandler(this.UpdownDisplayWidthValueChanged);
//
// lbl_modulus
//
@@ -619,7 +619,7 @@ namespace Handbrake.Controls
this.drp_modulus.Name = "drp_modulus";
this.drp_modulus.Size = new System.Drawing.Size(110, 21);
this.drp_modulus.TabIndex = 88;
- this.drp_modulus.SelectedIndexChanged += new System.EventHandler(this.drp_modulus_SelectedIndexChanged);
+ this.drp_modulus.SelectedIndexChanged += new System.EventHandler(this.DrpModulusSelectedIndexChanged);
//
// label8
//
diff --git a/win/C#/Controls/PictureSettings.cs b/win/C#/Controls/PictureSettings.cs
index d5d088b47..5eedf24df 100644
--- a/win/C#/Controls/PictureSettings.cs
+++ b/win/C#/Controls/PictureSettings.cs
@@ -16,14 +16,17 @@ namespace Handbrake.Controls
{
public partial class PictureSettings : UserControl
{
- private readonly CultureInfo Culture = new CultureInfo("en-US", false);
+ private readonly CultureInfo culture = new CultureInfo("en-US", false);
public event EventHandler PictureSettingsChanged;
- private Boolean _preventChangingWidth, _preventChangingHeight, _preventChangingCustom, _preventChangingDisplayWidth;
- private int _presetMaximumWidth, _presetMaximumHeight;
- private double _cachedDar;
- private Title _sourceTitle;
+ private Boolean preventChangingWidth, preventChangingHeight, preventChangingCustom, preventChangingDisplayWidth;
+ private int presetMaximumWidth, presetMaximumHeight;
+ private double cachedDar;
+ private Title sourceTitle;
+ /// <summary>
+ /// Creates a new instance of the Picture Settings Class
+ /// </summary>
public PictureSettings()
{
InitializeComponent();
@@ -35,65 +38,14 @@ namespace Handbrake.Controls
/// <summary>
/// Gets or sets the source media used by this control.
/// </summary>
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Title Source
{
- private get { return _sourceTitle; }
+ private get { return sourceTitle; }
set
{
- _sourceTitle = value;
- Enabled = _sourceTitle != null;
-
- // Set the Aspect Ratio
- lbl_Aspect.Text = _sourceTitle.AspectRatio.ToString(Culture);
- lbl_src_res.Text = _sourceTitle.Resolution.Width + " x " + _sourceTitle.Resolution.Height;
-
- // Set the Recommended Cropping values, but only if a preset doesn't have hard set picture settings.
- if (CurrentlySelectedPreset != null && CurrentlySelectedPreset.PictureSettings == false)
- {
- crop_top.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[0]);
- crop_bottom.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[1]);
- crop_left.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[2]);
- crop_right.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[3]);
- }
- else if (CurrentlySelectedPreset == null)
- {
- crop_top.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[0]);
- crop_bottom.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[1]);
- crop_left.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[2]);
- crop_right.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[3]);
- }
- SetPresetCropWarningLabel(CurrentlySelectedPreset);
-
- // Set the Resolution Boxes
- if (drp_anamorphic.SelectedIndex == 0)
- {
- if (text_width.Value == 0) // Only update the values if the fields don't already have values.
- text_width.Value = _sourceTitle.Resolution.Width;
-
- check_KeepAR.Checked = true; // Forces Resolution to be correct.
- }
- else
- {
- if (text_width.Value == 0 && text_height.Value == 0)// Only update the values if the fields don't already have values.
- {
- text_width.Value = _sourceTitle.Resolution.Width;
- text_height.Value = _sourceTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
- }
-
- labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height;
- }
-
- //updownDisplayWidth.Value = CalculateAnamorphicSizes().Width;
- updownParWidth.Value = _sourceTitle.ParVal.Width;
- updownParHeight.Value = _sourceTitle.ParVal.Height;
- //_cachedDar = (double)updownDisplayWidth.Value / (double)text_height.Value;
-
-
- Size croppedDar = CalculateAnamorphicSizes();
- _cachedDar = (double)croppedDar.Width / croppedDar.Height;
- updownDisplayWidth.Value = croppedDar.Width;
+ sourceTitle = value;
+ Enabled = sourceTitle != null;
+ NewSourceSet();
}
}
@@ -106,15 +58,13 @@ namespace Handbrake.Controls
/// Gets or sets the maximum allowable size for the encoded resolution. Set a value to
/// "0" if the maximum does not matter.
/// </summary>
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Size PresetMaximumResolution
{
- get { return new Size(_presetMaximumWidth, _presetMaximumHeight); }
+ get { return new Size(presetMaximumWidth, presetMaximumHeight); }
set
{
- _presetMaximumWidth = value.Width;
- _presetMaximumHeight = value.Height;
+ presetMaximumWidth = value.Width;
+ presetMaximumHeight = value.Height;
if (value.Width != 0 && value.Height != 0)
lbl_max.Text = "Max Width / Height";
@@ -127,6 +77,10 @@ namespace Handbrake.Controls
}
}
+ /// <summary>
+ /// Set the Preset Crop Warning Label
+ /// </summary>
+ /// <param name="selectedPreset"></param>
public void SetPresetCropWarningLabel(Preset selectedPreset)
{
lbl_presetCropWarning.Visible = true;
@@ -136,13 +90,60 @@ namespace Handbrake.Controls
lbl_presetCropWarning.Visible = false;
}
+ /// <summary>
+ /// Setup the UI. The Source has just changed.
+ /// </summary>
+ private void NewSourceSet()
+ {
+ // Set the Aspect Ratio
+ lbl_Aspect.Text = sourceTitle.AspectRatio.ToString(culture);
+ lbl_src_res.Text = sourceTitle.Resolution.Width + " x " + sourceTitle.Resolution.Height;
+
+ // Set the Recommended Cropping values, but only if a preset doesn't have hard set picture settings.
+ if ((CurrentlySelectedPreset != null && CurrentlySelectedPreset.PictureSettings == false) || CurrentlySelectedPreset == null)
+ {
+ crop_top.Value = GetCropMod2Clean(sourceTitle.AutoCropDimensions[0]);
+ crop_bottom.Value = GetCropMod2Clean(sourceTitle.AutoCropDimensions[1]);
+ crop_left.Value = GetCropMod2Clean(sourceTitle.AutoCropDimensions[2]);
+ crop_right.Value = GetCropMod2Clean(sourceTitle.AutoCropDimensions[3]);
+ }
+
+ SetPresetCropWarningLabel(CurrentlySelectedPreset);
+
+ // Set the Resolution Boxes
+ if (drp_anamorphic.SelectedIndex == 0)
+ {
+ if (text_width.Value == 0) // Only update the values if the fields don't already have values.
+ text_width.Value = sourceTitle.Resolution.Width;
+
+ check_KeepAR.Checked = true; // Forces Resolution to be correct.
+ }
+ else
+ {
+ if (text_width.Value == 0 && text_height.Value == 0)// Only update the values if the fields don't already have values.
+ {
+ text_width.Value = sourceTitle.Resolution.Width;
+ text_height.Value = sourceTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
+ }
+
+ labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height;
+ }
+
+ updownParWidth.Value = sourceTitle.ParVal.Width;
+ updownParHeight.Value = sourceTitle.ParVal.Height;
+
+ Size croppedDar = CalculateAnamorphicSizes();
+ cachedDar = (double)croppedDar.Width / croppedDar.Height;
+ updownDisplayWidth.Value = croppedDar.Width;
+ }
+
// Picture Controls
- private void text_width_ValueChanged(object sender, EventArgs e)
+ private void TextWidthValueChanged(object sender, EventArgs e)
{
if (Properties.Settings.Default.disableResCalc)
return;
- if (_preventChangingWidth)
+ if (preventChangingWidth)
return;
// Make sure the new value doesn't exceed the maximum
@@ -155,7 +156,7 @@ namespace Handbrake.Controls
case 0:
if (check_KeepAR.Checked && Source != null)
{
- _preventChangingHeight = true;
+ preventChangingHeight = true;
int width = (int)text_width.Value;
@@ -169,18 +170,18 @@ namespace Handbrake.Controls
(Source.Resolution.Height * SourceAspect.Width * crop_width);
text_height.Value = (decimal)GetModulusValue(newHeight);
- _preventChangingHeight = false;
+ preventChangingHeight = false;
}
break;
case 3:
if (check_KeepAR.CheckState == CheckState.Unchecked && Source != null)
{
- if (_preventChangingCustom)
+ if (preventChangingCustom)
break;
- _preventChangingDisplayWidth = true;
+ preventChangingDisplayWidth = true;
updownDisplayWidth.Value = text_width.Value * updownParWidth.Value / updownParHeight.Value;
- _preventChangingDisplayWidth = false;
+ preventChangingDisplayWidth = false;
labelDisplaySize.Text = Math.Truncate(updownDisplayWidth.Value) + "x" + text_height.Value;
}
@@ -196,14 +197,14 @@ namespace Handbrake.Controls
break;
}
- _preventChangingWidth = false;
+ preventChangingWidth = false;
}
- private void text_height_ValueChanged(object sender, EventArgs e)
+ private void TextHeightValueChanged(object sender, EventArgs e)
{
if (Properties.Settings.Default.disableResCalc)
return;
- if (_preventChangingHeight)
+ if (preventChangingHeight)
return;
if (Source != null)
@@ -215,7 +216,7 @@ namespace Handbrake.Controls
case 0:
if (check_KeepAR.Checked && Source != null)
{
- _preventChangingWidth = true;
+ preventChangingWidth = true;
double crop_width = Source.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value;
double crop_height = Source.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
@@ -225,7 +226,7 @@ namespace Handbrake.Controls
text_width.Value = (decimal)GetModulusValue(new_width);
- _preventChangingWidth = false;
+ preventChangingWidth = false;
}
break;
case 3:
@@ -238,17 +239,17 @@ namespace Handbrake.Controls
// - Changes PIXEL HEIGHT to STORAGE WIDTH
// DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)
- double rawCalculatedDisplayWidth = (double)text_height.Value * _cachedDar;
+ double rawCalculatedDisplayWidth = (double)text_height.Value * cachedDar;
- _preventChangingDisplayWidth = true; // Start Guards
- _preventChangingWidth = true;
+ preventChangingDisplayWidth = true; // Start Guards
+ preventChangingWidth = true;
updownDisplayWidth.Value = (decimal)rawCalculatedDisplayWidth;
updownParWidth.Value = updownDisplayWidth.Value;
updownParHeight.Value = text_width.Value;
- _preventChangingWidth = false; // Reset Guards
- _preventChangingDisplayWidth = false;
+ preventChangingWidth = false; // Reset Guards
+ preventChangingDisplayWidth = false;
}
break;
@@ -257,16 +258,16 @@ namespace Handbrake.Controls
break;
}
- _preventChangingHeight = false;
+ preventChangingHeight = false;
}
- private void check_KeepAR_CheckedChanged(object sender, EventArgs e)
+ private void CheckKeepArCheckedChanged(object sender, EventArgs e)
{
if (Properties.Settings.Default.disableResCalc)
return;
//Force TextWidth to recalc height
if (check_KeepAR.Checked)
- text_width_ValueChanged(this, new EventArgs());
+ TextWidthValueChanged(this, new EventArgs());
// Disable the Custom Anamorphic Par Controls if checked.
if (drp_anamorphic.SelectedIndex == 3)
@@ -279,20 +280,20 @@ namespace Handbrake.Controls
if (PictureSettingsChanged != null)
PictureSettingsChanged(this, new EventArgs());
}
- private void updownDisplayWidth_ValueChanged(object sender, EventArgs e)
+ private void UpdownDisplayWidthValueChanged(object sender, EventArgs e)
{
if (Properties.Settings.Default.disableResCalc)
return;
- if (_preventChangingDisplayWidth == false && check_KeepAR.CheckState == CheckState.Unchecked)
+ if (preventChangingDisplayWidth == false && check_KeepAR.CheckState == CheckState.Unchecked)
{
- _preventChangingCustom = true;
+ preventChangingCustom = true;
updownParWidth.Value = updownDisplayWidth.Value;
updownParHeight.Value = text_width.Value;
- _preventChangingCustom = false;
+ preventChangingCustom = false;
}
- if (_preventChangingDisplayWidth == false && check_KeepAR.CheckState == CheckState.Checked)
+ if (preventChangingDisplayWidth == false && check_KeepAR.CheckState == CheckState.Checked)
{
// - Changes HEIGHT to keep DAR
// - Changes PIXEL WIDTH to new DISPLAY WIDTH
@@ -304,41 +305,41 @@ namespace Handbrake.Controls
if (!int.TryParse(drp_modulus.SelectedItem.ToString(), out modulus))
modulus = 16;
- int rawCalculatedHeight = (int)((int)updownDisplayWidth.Value / _cachedDar);
+ int rawCalculatedHeight = (int)((int)updownDisplayWidth.Value / cachedDar);
int modulusHeight = rawCalculatedHeight - (rawCalculatedHeight % modulus);
// Update value
- _preventChangingHeight = true;
+ preventChangingHeight = true;
text_height.Value = (decimal)modulusHeight;
updownParWidth.Value = updownDisplayWidth.Value;
updownParHeight.Value = text_width.Value;
- _preventChangingHeight = false;
+ preventChangingHeight = false;
}
}
// Anamorphic Controls
- private void drp_anamorphic_SelectedIndexChanged(object sender, EventArgs e)
+ private void DrpAnamorphicSelectedIndexChanged(object sender, EventArgs e)
{
switch (drp_anamorphic.SelectedIndex)
{
- case 0:
+ case 0: // None
text_width.Enabled = true;
text_height.Enabled = true;
check_KeepAR.Enabled = true;
SetCustomAnamorphicOptionsVisible(false);
labelStaticDisplaySize.Visible = false;
- labelDisplaySize.Visible = false;
+ labelDisplaySize.Visible = true;
+ drp_modulus.Visible = true;
// check_KeepAR.Checked = true;
- drp_modulus.SelectedIndex = 0;
if (check_KeepAR.Checked)
- text_width_ValueChanged(this, new EventArgs());
+ TextWidthValueChanged(this, new EventArgs());
// Don't update display size if we're not using anamorphic
return;
- case 1:
+ case 1: // Strict
text_width.Enabled = false;
text_height.Enabled = false;
check_KeepAR.Enabled = false;
@@ -346,11 +347,10 @@ namespace Handbrake.Controls
SetCustomAnamorphicOptionsVisible(false);
labelStaticDisplaySize.Visible = true;
labelDisplaySize.Visible = true;
- drp_modulus.SelectedIndex = 0;
check_KeepAR.Checked = true;
break;
- case 2:
+ case 2: // Loose
text_width.Enabled = true;
text_height.Enabled = false;
check_KeepAR.Enabled = false;
@@ -358,11 +358,12 @@ namespace Handbrake.Controls
SetCustomAnamorphicOptionsVisible(false);
labelStaticDisplaySize.Visible = true;
labelDisplaySize.Visible = true;
- drp_modulus.SelectedIndex = 0;
+ drp_modulus.Visible = true;
+ lbl_modulus.Visible = true;
check_KeepAR.Checked = true;
break;
- case 3:
+ case 3: // Custom
text_width.Enabled = true;
text_height.Enabled = true;
check_KeepAR.Enabled = true;
@@ -381,21 +382,21 @@ namespace Handbrake.Controls
labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height;
if (check_KeepAR.Checked)
- text_width_ValueChanged(this, new EventArgs());
+ TextWidthValueChanged(this, new EventArgs());
if (PictureSettingsChanged != null)
PictureSettingsChanged(this, new EventArgs());
}
- private void drp_modulus_SelectedIndexChanged(object sender, EventArgs e)
+ private void DrpModulusSelectedIndexChanged(object sender, EventArgs e)
{
- _preventChangingWidth = true;
- _preventChangingHeight = true;
+ preventChangingWidth = true;
+ preventChangingHeight = true;
text_width.Value = (decimal)GetModulusValue((double)text_width.Value);
text_height.Value = (decimal)GetModulusValue((double)text_height.Value);
- _preventChangingWidth = false;
- _preventChangingHeight = false;
+ preventChangingWidth = false;
+ preventChangingHeight = false;
text_width.Increment = int.Parse(drp_modulus.SelectedItem.ToString());
text_height.Increment = int.Parse(drp_modulus.SelectedItem.ToString());
@@ -405,7 +406,7 @@ namespace Handbrake.Controls
}
// Cropping Controls
- private void check_autoCrop_CheckedChanged(object sender, EventArgs e)
+ private void CheckAutoCropCheckedChanged(object sender, EventArgs e)
{
crop_top.Enabled = check_customCrop.Checked;
crop_bottom.Enabled = check_customCrop.Checked;
@@ -420,9 +421,9 @@ namespace Handbrake.Controls
crop_right.Value = Source.AutoCropDimensions[3];
}
}
- private void crop_ValueChanged(object sender, EventArgs e)
+ private void CropValueChanged(object sender, EventArgs e)
{
- text_width_ValueChanged(this, new EventArgs());
+ TextWidthValueChanged(this, new EventArgs());
}
// GUI Functions
@@ -455,12 +456,12 @@ namespace Handbrake.Controls
if (Source != null)
{
/* Set up some variables to make the math easier to follow. */
- int cropped_width = Source.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value;
- int cropped_height = Source.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
- double storage_aspect = (double)cropped_width / cropped_height;
+ int croppedWidth = Source.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value;
+ int croppedHeight = Source.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
+ double storageAspect = (double)croppedWidth / croppedHeight;
/* Figure out what width the source would display at. */
- double source_display_width = (double)cropped_width * Source.ParVal.Width / Source.ParVal.Height;
+ double sourceDisplayWidth = (double)croppedWidth * Source.ParVal.Width / Source.ParVal.Height;
/*
3 different ways of deciding output dimensions:
@@ -474,9 +475,9 @@ namespace Handbrake.Controls
default:
case 1:
/* Strict anamorphic */
- double displayWidth = ((double)cropped_width * Source.ParVal.Width / Source.ParVal.Height);
+ double displayWidth = ((double)croppedWidth * Source.ParVal.Width / Source.ParVal.Height);
displayWidth = Math.Round(displayWidth, 0);
- Size output = new Size((int)displayWidth, cropped_height);
+ Size output = new Size((int)displayWidth, croppedHeight);
return output;
case 2:
/* "Loose" anamorphic.
@@ -486,16 +487,16 @@ namespace Handbrake.Controls
width = (int)text_width.Value;
width = GetModulusValue(width); /* Time to get picture width that divide cleanly.*/
- height = (width / storage_aspect) + 0.5;
+ height = (width / storageAspect) + 0.5;
height = GetModulusValue(height); /* Time to get picture height that divide cleanly.*/
/* The film AR is the source's display width / cropped source height.
The output display width is the output height * film AR.
The output PAR is the output display width / output storage width. */
- double pixel_aspect_width = height * source_display_width / cropped_height;
- double pixel_aspect_height = width;
+ double pixelAspectWidth = height * sourceDisplayWidth / croppedHeight;
+ double pixelAspectHeight = width;
- double disWidthLoose = (width * pixel_aspect_width / pixel_aspect_height);
+ double disWidthLoose = (width * pixelAspectWidth / pixelAspectHeight);
if (double.IsNaN(disWidthLoose))
disWidthLoose = 0;
return new Size((int)disWidthLoose, (int)height);
@@ -536,12 +537,11 @@ namespace Handbrake.Controls
}
// Hidden UI feature to drop the MaxWidth / Height with the MaxWidth/Height label is double clicked
- private void lbl_max_DoubleClick(object sender, EventArgs e)
+ private void LblMaxDoubleClick(object sender, EventArgs e)
{
PresetMaximumResolution = new Size(0, 0);
if (PictureSettingsChanged != null)
PictureSettingsChanged(this, new EventArgs());
}
-
}
} \ No newline at end of file
diff --git a/win/C#/Controls/Subtitles.Designer.cs b/win/C#/Controls/Subtitles.Designer.cs
index 6c54c3f7c..b38b6e4d5 100644
--- a/win/C#/Controls/Subtitles.Designer.cs
+++ b/win/C#/Controls/Subtitles.Designer.cs
@@ -80,7 +80,7 @@
this.btn_addTrack.Text = "Add";
this.toolTip.SetToolTip(this.btn_addTrack, "Add a new subtitle track to the list below");
this.btn_addTrack.UseVisualStyleBackColor = false;
- this.btn_addTrack.Click += new System.EventHandler(this.btn_addSubTrack_Click);
+ this.btn_addTrack.Click += new System.EventHandler(this.BtnAddSubTrackClick);
//
// btn_RemoveSubTrack
//
@@ -93,7 +93,7 @@
this.btn_RemoveSubTrack.TabIndex = 69;
this.btn_RemoveSubTrack.Text = "Remove";
this.btn_RemoveSubTrack.UseVisualStyleBackColor = false;
- this.btn_RemoveSubTrack.Click += new System.EventHandler(this.btn_RemoveSubTrack_Click);
+ this.btn_RemoveSubTrack.Click += new System.EventHandler(this.BtnRemoveSubTrackClick);
//
// lv_subList
//
@@ -117,7 +117,7 @@
this.lv_subList.TabIndex = 70;
this.lv_subList.UseCompatibleStateImageBehavior = false;
this.lv_subList.View = System.Windows.Forms.View.Details;
- this.lv_subList.SelectedIndexChanged += new System.EventHandler(this.lb_subList_SelectedIndexChanged);
+ this.lv_subList.SelectedIndexChanged += new System.EventHandler(this.LbSubListSelectedIndexChanged);
//
// col_Source
//
@@ -168,7 +168,7 @@
this.mnu_moveup.Name = "mnu_moveup";
this.mnu_moveup.Size = new System.Drawing.Size(138, 22);
this.mnu_moveup.Text = "Move Up";
- this.mnu_moveup.Click += new System.EventHandler(this.mnu_moveup_Click);
+ this.mnu_moveup.Click += new System.EventHandler(this.MnuMoveupClick);
//
// mnu_movedown
//
@@ -176,7 +176,7 @@
this.mnu_movedown.Size = new System.Drawing.Size(138, 22);
this.mnu_movedown.Text = "Move Down";
this.mnu_movedown.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
- this.mnu_movedown.Click += new System.EventHandler(this.mnu_movedown_Click);
+ this.mnu_movedown.Click += new System.EventHandler(this.MnuMovedownClick);
//
// toolStripSeparator2
//
@@ -188,7 +188,7 @@
this.mnu_remove.Name = "mnu_remove";
this.mnu_remove.Size = new System.Drawing.Size(138, 22);
this.mnu_remove.Text = "Remove";
- this.mnu_remove.Click += new System.EventHandler(this.mnu_remove_Click);
+ this.mnu_remove.Click += new System.EventHandler(this.MnuRemoveClick);
//
// label68
//
@@ -233,7 +233,7 @@
this.drp_subtitleTracks.Name = "drp_subtitleTracks";
this.drp_subtitleTracks.Size = new System.Drawing.Size(164, 21);
this.drp_subtitleTracks.TabIndex = 74;
- this.drp_subtitleTracks.SelectedIndexChanged += new System.EventHandler(this.drp_subtitleTracks_SelectedIndexChanged);
+ this.drp_subtitleTracks.SelectedIndexChanged += new System.EventHandler(this.DrpSubtitleTracksSelectedIndexChanged);
//
// label10
//
@@ -284,7 +284,7 @@
this.srt_offset.Name = "srt_offset";
this.srt_offset.Size = new System.Drawing.Size(58, 21);
this.srt_offset.TabIndex = 79;
- this.srt_offset.ValueChanged += new System.EventHandler(this.srt_offset_ValueChanged);
+ this.srt_offset.ValueChanged += new System.EventHandler(this.SrtOffsetValueChanged);
//
// srt_lang
//
@@ -295,7 +295,7 @@
this.srt_lang.Name = "srt_lang";
this.srt_lang.Size = new System.Drawing.Size(103, 21);
this.srt_lang.TabIndex = 50;
- this.srt_lang.SelectedIndexChanged += new System.EventHandler(this.srt_lang_SelectedIndexChanged);
+ this.srt_lang.SelectedIndexChanged += new System.EventHandler(this.SrtLangSelectedIndexChanged);
//
// label8
//
@@ -347,7 +347,7 @@
this.srt_charcode.Name = "srt_charcode";
this.srt_charcode.Size = new System.Drawing.Size(78, 21);
this.srt_charcode.TabIndex = 73;
- this.srt_charcode.SelectedIndexChanged += new System.EventHandler(this.srt_charcode_SelectedIndexChanged);
+ this.srt_charcode.SelectedIndexChanged += new System.EventHandler(this.SrtCharcodeSelectedIndexChanged);
//
// label4
//
@@ -366,7 +366,7 @@
this.check_forced.Size = new System.Drawing.Size(15, 14);
this.check_forced.TabIndex = 75;
this.check_forced.UseVisualStyleBackColor = true;
- this.check_forced.CheckedChanged += new System.EventHandler(this.check_forced_CheckedChanged);
+ this.check_forced.CheckedChanged += new System.EventHandler(this.CheckForcedCheckedChanged);
//
// label7
//
@@ -394,7 +394,7 @@
this.check_default.Size = new System.Drawing.Size(15, 14);
this.check_default.TabIndex = 77;
this.check_default.UseVisualStyleBackColor = true;
- this.check_default.CheckedChanged += new System.EventHandler(this.check_default_CheckedChanged);
+ this.check_default.CheckedChanged += new System.EventHandler(this.CheckDefaultCheckedChanged);
//
// check_burned
//
@@ -404,7 +404,7 @@
this.check_burned.Size = new System.Drawing.Size(15, 14);
this.check_burned.TabIndex = 76;
this.check_burned.UseVisualStyleBackColor = true;
- this.check_burned.CheckedChanged += new System.EventHandler(this.check_burned_CheckedChanged);
+ this.check_burned.CheckedChanged += new System.EventHandler(this.CheckBurnedCheckedChanged);
//
// btn_srtAdd
//
@@ -418,7 +418,7 @@
this.btn_srtAdd.Text = "Import SRT";
this.toolTip.SetToolTip(this.btn_srtAdd, "Add a new SRT file to the \"track\" dropdown menu.");
this.btn_srtAdd.UseVisualStyleBackColor = false;
- this.btn_srtAdd.Click += new System.EventHandler(this.btn_srtAdd_Click);
+ this.btn_srtAdd.Click += new System.EventHandler(this.BtnSrtAddClick);
//
// openFileDialog
//
diff --git a/win/C#/Controls/Subtitles.cs b/win/C#/Controls/Subtitles.cs
index fb179bba2..45a21475f 100644
--- a/win/C#/Controls/Subtitles.cs
+++ b/win/C#/Controls/Subtitles.cs
@@ -13,18 +13,20 @@ using Handbrake.Model;
namespace Handbrake.Controls
{
+ using System.Linq;
+
public partial class Subtitles : UserControl
{
- readonly IDictionary<string, string> LangMap = new Dictionary<string, string>();
- List<SubtitleInfo> SubList = new List<SubtitleInfo>();
- private int FileContainer;
+ readonly IDictionary<string, string> langMap = new Dictionary<string, string>();
+ readonly List<SubtitleInfo> subList = new List<SubtitleInfo>();
+ private int fileContainer;
public Subtitles()
{
InitializeComponent();
- LangMap = Main.MapLanguages();
- foreach (string key in LangMap.Keys)
+ langMap = Main.MapLanguages();
+ foreach (string key in langMap.Keys)
srt_lang.Items.Add(key);
srt_charcode.SelectedIndex = 28;
@@ -32,7 +34,7 @@ namespace Handbrake.Controls
}
// Primary Controls
- private void btn_addSubTrack_Click(object sender, EventArgs e)
+ private void BtnAddSubTrackClick(object sender, EventArgs e)
{
// Logic
string forcedVal = check_forced.CheckState == CheckState.Checked ? "Yes" : "No";
@@ -56,23 +58,20 @@ namespace Handbrake.Controls
if (defaultSub == "Yes") SetNoDefault();
if (burnedVal == "Yes") SetNoBurned();
- if (FileContainer == 0)
+ if (fileContainer == 0)
burnedVal = "Yes"; // MP4 must have bitmap subs burned in.
}
- if (FileContainer == 0) // MP4 and M4V file extension
+ if (fileContainer == 0) // MP4 and M4V file extension
{
// Make sure we only have 1 bitmap track.
if (drp_subtitleTracks.SelectedItem != null && drp_subtitleTracks.SelectedItem.ToString().Contains("Bitmap"))
{
- foreach (ListViewItem item in lv_subList.Items)
+ if (lv_subList.Items.Cast<ListViewItem>().Any(item => item.SubItems[0].Text.Contains("Bitmap")))
{
- if (item.SubItems[0].Text.Contains("Bitmap"))
- {
- MessageBox.Show(this, "More than one vobsub is not supported in mp4... Your first vobsub track will now be used.",
- "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
+ MessageBox.Show(this, "More than one vobsub is not supported in mp4... Your first vobsub track will now be used.",
+ "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ return;
}
}
}
@@ -96,28 +95,28 @@ namespace Handbrake.Controls
};
lv_subList.Items.Add(track.ListView);
- SubList.Add(track);
+ subList.Add(track);
}
- private void btn_srtAdd_Click(object sender, EventArgs e)
+ private void BtnSrtAddClick(object sender, EventArgs e)
{
if (openFileDialog.ShowDialog() != DialogResult.OK)
return;
drp_subtitleTracks.Items.Add(Path.GetFileName(openFileDialog.FileName));
drp_subtitleTracks.SelectedItem = Path.GetFileName(openFileDialog.FileName);
}
- private void btn_RemoveSubTrack_Click(object sender, EventArgs e)
+ private void BtnRemoveSubTrackClick(object sender, EventArgs e)
{
RemoveTrack();
}
// Secondary Controls
- private void lb_subList_SelectedIndexChanged(object sender, EventArgs e)
+ private void LbSubListSelectedIndexChanged(object sender, EventArgs e)
{
// Set the dropdown controls based on the selected item in the List.
if (lv_subList.Items.Count != 0 && lv_subList.SelectedIndices.Count != 0)
{
- SubtitleInfo track = SubList[lv_subList.SelectedIndices[0]];
+ SubtitleInfo track = subList[lv_subList.SelectedIndices[0]];
int c = 0;
if (lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[0].Text.ToLower().Contains(".srt")) // We have an SRT
@@ -153,7 +152,7 @@ namespace Handbrake.Controls
}
// Bitmap / CC / SRT Controls
- private void drp_subtitleTracks_SelectedIndexChanged(object sender, EventArgs e)
+ private void DrpSubtitleTracksSelectedIndexChanged(object sender, EventArgs e)
{
if (drp_subtitleTracks.SelectedItem.ToString().Contains(".srt"))
{
@@ -186,18 +185,18 @@ namespace Handbrake.Controls
lv_subList.Select();
}
- SubList[lv_subList.SelectedIndices[0]].Track = drp_subtitleTracks.SelectedItem.ToString(); // Update SubList List<SubtitleInfo>
+ subList[lv_subList.SelectedIndices[0]].Track = drp_subtitleTracks.SelectedItem.ToString(); // Update SubList List<SubtitleInfo>
}
- private void check_forced_CheckedChanged(object sender, EventArgs e)
+ private void CheckForcedCheckedChanged(object sender, EventArgs e)
{
if (lv_subList.Items.Count == 0 || lv_subList.SelectedIndices.Count == 0) return;
lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[1].Text = check_forced.Checked ? "Yes" : "No";
lv_subList.Select();
- SubList[lv_subList.SelectedIndices[0]].Forced = check_forced.Checked ? "Yes" : "No"; // Update SubList List<SubtitleInfo>
+ subList[lv_subList.SelectedIndices[0]].Forced = check_forced.Checked ? "Yes" : "No"; // Update SubList List<SubtitleInfo>
}
- private void check_burned_CheckedChanged(object sender, EventArgs e)
+ private void CheckBurnedCheckedChanged(object sender, EventArgs e)
{
if (lv_subList.Items.Count == 0 || lv_subList.SelectedIndices.Count == 0) return;
@@ -207,9 +206,9 @@ namespace Handbrake.Controls
lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[2].Text = check_burned.Checked ? "Yes" : "No";
lv_subList.Select();
- SubList[lv_subList.SelectedIndices[0]].Burned = check_burned.Checked ? "Yes" : "No"; // Update SubList List<SubtitleInfo>
+ subList[lv_subList.SelectedIndices[0]].Burned = check_burned.Checked ? "Yes" : "No"; // Update SubList List<SubtitleInfo>
}
- private void check_default_CheckedChanged(object sender, EventArgs e)
+ private void CheckDefaultCheckedChanged(object sender, EventArgs e)
{
if (lv_subList.Items.Count == 0 || lv_subList.SelectedIndices.Count == 0) return;
@@ -222,9 +221,9 @@ namespace Handbrake.Controls
lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[3].Text = check_default.Checked ? "Yes" : "No";
lv_subList.Select();
- SubList[lv_subList.SelectedIndices[0]].Default = check_default.Checked ? "Yes" : "No"; // Update SubList List<SubtitleInfo>
+ subList[lv_subList.SelectedIndices[0]].Default = check_default.Checked ? "Yes" : "No"; // Update SubList List<SubtitleInfo>
}
- private void srt_offset_ValueChanged(object sender, EventArgs e)
+ private void SrtOffsetValueChanged(object sender, EventArgs e)
{
// Update an item in the list if required.
if (lv_subList.Items.Count == 0 || lv_subList.SelectedIndices.Count == 0)
@@ -233,29 +232,29 @@ namespace Handbrake.Controls
lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[6].Text = srt_offset.Value.ToString();
lv_subList.Select();
- SubList[lv_subList.SelectedIndices[0]].SrtOffset = (int)srt_offset.Value; // Update SubList List<SubtitleInfo>
+ subList[lv_subList.SelectedIndices[0]].SrtOffset = (int)srt_offset.Value; // Update SubList List<SubtitleInfo>
}
- private void srt_charcode_SelectedIndexChanged(object sender, EventArgs e)
+ private void SrtCharcodeSelectedIndexChanged(object sender, EventArgs e)
{
if (lv_subList.Items.Count == 0 || lv_subList.SelectedIndices.Count == 0) return;
lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[5].Text = srt_charcode.SelectedItem.ToString();
lv_subList.Select();
- SubList[lv_subList.SelectedIndices[0]].SrtCharCode = srt_charcode.SelectedItem.ToString(); // Update SubList List<SubtitleInfo>
+ subList[lv_subList.SelectedIndices[0]].SrtCharCode = srt_charcode.SelectedItem.ToString(); // Update SubList List<SubtitleInfo>
}
- private void srt_lang_SelectedIndexChanged(object sender, EventArgs e)
+ private void SrtLangSelectedIndexChanged(object sender, EventArgs e)
{
if (lv_subList.Items.Count == 0 || lv_subList.SelectedIndices.Count == 0) return;
lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[4].Text = srt_lang.SelectedItem.ToString();
lv_subList.Select();
- SubList[lv_subList.SelectedIndices[0]].SrtLang = srt_lang.SelectedItem.ToString(); // Update SubList List<SubtitleInfo>
+ subList[lv_subList.SelectedIndices[0]].SrtLang = srt_lang.SelectedItem.ToString(); // Update SubList List<SubtitleInfo>
}
// Right Click Menu
- private void mnu_moveup_Click(object sender, EventArgs e)
+ private void MnuMoveupClick(object sender, EventArgs e)
{
if (lv_subList.SelectedIndices.Count != 0)
{
@@ -272,7 +271,7 @@ namespace Handbrake.Controls
}
}
}
- private void mnu_movedown_Click(object sender, EventArgs e)
+ private void MnuMovedownClick(object sender, EventArgs e)
{
if (lv_subList.SelectedIndices.Count != 0)
{
@@ -289,7 +288,7 @@ namespace Handbrake.Controls
}
}
}
- private void mnu_remove_Click(object sender, EventArgs e)
+ private void MnuRemoveClick(object sender, EventArgs e)
{
RemoveTrack();
}
@@ -300,12 +299,12 @@ namespace Handbrake.Controls
int c = 0;
foreach (ListViewItem item in lv_subList.Items)
{
- if (SubList[c].SrtPath == "-")
+ if (subList[c].SrtPath == "-")
{
if (item.SubItems[3].Text == "Yes")
{
item.SubItems[3].Text = "No";
- SubList[c].Default = "No";
+ subList[c].Default = "No";
}
}
c++;
@@ -317,12 +316,12 @@ namespace Handbrake.Controls
int c = 0;
foreach (ListViewItem item in lv_subList.Items)
{
- if (SubList[c].SrtPath != "-")
+ if (subList[c].SrtPath != "-")
{
if (item.SubItems[3].Text == "Yes")
{
item.SubItems[3].Text = "No";
- SubList[c].Default = "No";
+ subList[c].Default = "No";
}
}
c++;
@@ -336,7 +335,7 @@ namespace Handbrake.Controls
if (item.SubItems[2].Text == "Yes")
{
item.SubItems[2].Text = "No";
- SubList[c].Burned = "No";
+ subList[c].Burned = "No";
}
c++;
}
@@ -351,7 +350,7 @@ namespace Handbrake.Controls
int selectedInd = lv_subList.SelectedIndices[0];
lv_subList.Items.RemoveAt(selectedInd);
- SubList.RemoveAt(selectedInd);
+ subList.RemoveAt(selectedInd);
// Now reslect the correct item and give focus to the list.
if (lv_subList.Items.Count != 0)
@@ -366,18 +365,29 @@ namespace Handbrake.Controls
}
}
- // Public Functions
+ /// <summary>
+ /// Clear the Subtitle List
+ /// </summary>
public void Clear()
{
lv_subList.Items.Clear();
- SubList.Clear();
+ subList.Clear();
}
+
+ /// <summary>
+ /// Cleverly Clear the subtitle list. Only remove tracks that are not available for the current source.
+ /// </summary>
public void SmartClear()
{
/* Smart clear will only remove subtitle tracks that do not have an equivlent
for the new source / title which the user has selected. */
throw new NotImplementedException();
}
+
+ /// <summary>
+ /// Checks of the current settings will require the m4v file extension
+ /// </summary>
+ /// <returns>True if Yes</returns>
public Boolean RequiresM4V()
{
foreach (ListViewItem item in lv_subList.Items)
@@ -390,6 +400,12 @@ namespace Handbrake.Controls
}
return false;
}
+
+ /// <summary>
+ /// Automatically setup the subtitle tracks.
+ /// This handles the automatic setup of subitles which the user can control from the program options
+ /// </summary>
+ /// <param name="subs"></param>
public void SetSubtitleTrackAuto(object[] subs)
{
drp_subtitleTracks.Items.Clear();
@@ -412,15 +428,20 @@ namespace Handbrake.Controls
i++;
}
- btn_addSubTrack_Click(this, new EventArgs());
+ BtnAddSubTrackClick(this, new EventArgs());
}
}
}
+
+ /// <summary>
+ /// Set the file container which is currently in use.
+ /// </summary>
+ /// <param name="value"></param>
public void SetContainer(int value)
{
- FileContainer = value;
+ fileContainer = value;
Boolean trigger = false;
- if (FileContainer != 1)
+ if (fileContainer != 1)
foreach (ListViewItem item in lv_subList.Items)
{
if (item.SubItems[1].Text.Contains("Bitmap"))
@@ -431,9 +452,131 @@ namespace Handbrake.Controls
}
}
}
+
+ /// <summary>
+ /// Get the list of subtitles.
+ /// </summary>
+ /// <returns></returns>
public List<SubtitleInfo> GetSubtitleInfoList()
{
- return SubList;
+ return subList;
+ }
+
+ /// <summary>
+ /// Get the CLI Query for this panel
+ /// </summary>
+ /// <returns></returns>
+ public string GetCliQuery
+ {
+ get
+ {
+ string query = string.Empty;
+ if (lv_subList.Items.Count != 0) // If we have subtitle tracks
+ {
+ // BitMap and CC's
+ string subtitleTracks = String.Empty;
+ string subtitleForced = String.Empty;
+ string subtitleBurn = String.Empty;
+ string subtitleDefault = String.Empty;
+
+ // SRT
+ string srtFile = String.Empty;
+ string srtCodeset = String.Empty;
+ string srtOffset = String.Empty;
+ string srtLang = String.Empty;
+ string srtDefault = String.Empty;
+ int srtCount = 0;
+
+ foreach (SubtitleInfo item in subList)
+ {
+ string itemToAdd, trackId;
+
+ if (item.IsSrtSubtitle) // We have an SRT file
+ {
+ srtCount++; // SRT track id.
+
+ srtLang += srtLang == "" ? langMap[item.SrtLang] : "," + langMap[item.SrtLang];
+ srtCodeset += srtCodeset == "" ? item.SrtCharCode : "," + item.SrtCharCode;
+
+ if (item.Default == "Yes")
+ srtDefault = srtCount.ToString();
+
+ itemToAdd = item.SrtPath;
+ srtFile += srtFile == "" ? itemToAdd : "," + itemToAdd;
+
+ itemToAdd = item.SrtOffset.ToString();
+ srtOffset += srtOffset == "" ? itemToAdd : "," + itemToAdd;
+ }
+ else // We have Bitmap or CC
+ {
+ string[] tempSub;
+
+ // Find --subtitle <string>
+ if (item.Track.Contains("Foreign Audio Search"))
+ itemToAdd = "scan";
+ else
+ {
+ tempSub = item.Track.Split(' ');
+ itemToAdd = tempSub[0];
+ }
+
+ subtitleTracks += subtitleTracks == "" ? itemToAdd : "," + itemToAdd;
+
+ // Find --subtitle-forced
+ itemToAdd = "";
+ tempSub = item.Track.Split(' ');
+ trackId = tempSub[0];
+
+ if (item.Forced == "Yes")
+ itemToAdd = "scan";
+
+ if (itemToAdd != "")
+ subtitleForced += subtitleForced == "" ? itemToAdd : "," + itemToAdd;
+
+ // Find --subtitle-burn and --subtitle-default
+ trackId = tempSub[0];
+
+ if (trackId.Trim() == "Foreign") // foreign audio search
+ trackId = "scan";
+
+ if (item.Burned == "Yes") // burn
+ subtitleBurn = trackId;
+
+ if (item.Default == "Yes") // default
+ subtitleDefault = trackId;
+ }
+ }
+
+ // Build The CLI Subtitles Query
+ if (subtitleTracks != "")
+ {
+ query += " --subtitle " + subtitleTracks;
+
+ if (subtitleForced != "")
+ query += " --subtitle-forced=" + subtitleForced;
+ if (subtitleBurn != "")
+ query += " --subtitle-burn=" + subtitleBurn;
+ if (subtitleDefault != "")
+ query += " --subtitle-default=" + subtitleDefault;
+ }
+
+ if (srtFile != "") // SRTs
+ {
+ query += " --srt-file " + "\"" + srtFile + "\"";
+
+ if (srtCodeset != "")
+ query += " --srt-codeset " + srtCodeset;
+ if (srtOffset != "")
+ query += " --srt-offset " + srtOffset;
+ if (srtLang != "")
+ query += " --srt-lang " + srtLang;
+ if (srtDefault != "")
+ query += " --srt-default=" + srtDefault;
+ }
+
+ }
+ return query;
+ }
}
}
} \ No newline at end of file
diff --git a/win/C#/Controls/x264Panel.cs b/win/C#/Controls/x264Panel.cs
index 78480b2de..56146a0ae 100644
--- a/win/C#/Controls/x264Panel.cs
+++ b/win/C#/Controls/x264Panel.cs
@@ -34,7 +34,7 @@ namespace Handbrake.Controls
/// </summary>
public string X264Query
{
- get { return rtf_x264Query.Text; }
+ get { return " -x " + rtf_x264Query.Text; }
set { rtf_x264Query.Text = value; }
}