diff options
author | sr55 <[email protected]> | 2010-02-20 22:30:12 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2010-02-20 22:30:12 +0000 |
commit | 3678fc6353c1b1bbea23723891cbf950f66ab452 (patch) | |
tree | 401d6f9b859ecac9fdf13fe432dd564589ac7276 /win/C#/Controls | |
parent | b59b7b8733533aed4b97da6679e455df63049e23 (diff) |
WinGui:
- Cleanup more StyleCop warnings.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3131 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Controls')
-rw-r--r-- | win/C#/Controls/AudioPanel.cs | 66 | ||||
-rw-r--r-- | win/C#/Controls/Filters.cs | 42 | ||||
-rw-r--r-- | win/C#/Controls/PictureSettings.cs | 126 | ||||
-rw-r--r-- | win/C#/Controls/Subtitles.cs | 143 | ||||
-rw-r--r-- | win/C#/Controls/x264Panel.cs | 201 |
5 files changed, 327 insertions, 251 deletions
diff --git a/win/C#/Controls/AudioPanel.cs b/win/C#/Controls/AudioPanel.cs index b60bf767e..c377edd0b 100644 --- a/win/C#/Controls/AudioPanel.cs +++ b/win/C#/Controls/AudioPanel.cs @@ -4,14 +4,15 @@ Homepage: <http://handbrake.fr>.
It may be used under the terms of the GNU General Public License. */
-using System;
-using System.Collections;
-using System.Linq;
-using System.Windows.Forms;
-using Handbrake.Model;
-
namespace Handbrake.Controls
{
+ using System;
+ using System.Collections;
+ using System.Linq;
+ using System.Windows.Forms;
+ using Parsing;
+ using AudioTrack = Model.AudioTrack;
+
public partial class AudioPanel : UserControl
{
/// <summary>
@@ -20,6 +21,7 @@ namespace Handbrake.Controls public event EventHandler AudioListChanged;
/// <summary>
+ /// Initializes a new instance of the <see cref="AudioPanel"/> class.
/// Create a new instance of the Audio Panel
/// </summary>
public AudioPanel()
@@ -42,7 +44,7 @@ namespace Handbrake.Controls /// Set the File Container. This funciton is used to limit the available options for each file container.
/// </summary>
/// <param name="path"></param>
- public void SetContainer(String path)
+ public void SetContainer(string path)
{
string oldval = drp_audioEncoder.Text;
if ((path.Contains("MP4")) || (path.Contains("M4V")))
@@ -54,7 +56,6 @@ namespace Handbrake.Controls drp_audioEncoder.SelectedIndex = 0;
else
drp_audioEncoder.SelectedItem = oldval;
-
}
else if (path.Contains("MKV"))
{
@@ -82,7 +83,7 @@ namespace Handbrake.Controls /// Checks if the settings used required the .m4v (rather than .mp4) extension
/// </summary>
/// <returns></returns>
- public Boolean RequiresM4V()
+ public bool RequiresM4V()
{
return lv_audioList.Items.Cast<ListViewItem>().Any(item => item.SubItems[2].Text.Contains("AC3"));
}
@@ -116,7 +117,7 @@ namespace Handbrake.Controls /// Set the Track list dropdown from the parsed title captured during the scan
/// </summary>
/// <param name="selectedTitle"></param>
- public void SetTrackList(Parsing.Title selectedTitle)
+ public void SetTrackList(Title selectedTitle)
{
drp_audioTrack.Items.Clear();
drp_audioTrack.Items.Add("Automatic");
@@ -154,7 +155,8 @@ namespace Handbrake.Controls }
}
else
- drp_audioTrack.SelectedIndex = drp_audioTrack.Items.Count >= 3 ? 2 : 0; // "Use Foreign language audio and Subtitles"
+ drp_audioTrack.SelectedIndex = drp_audioTrack.Items.Count >= 3 ? 2 : 0;
+ // "Use Foreign language audio and Subtitles"
}
drp_audioMix.SelectedIndex = 0;
}
@@ -162,7 +164,7 @@ namespace Handbrake.Controls // Control and ListView
private void controlChanged(object sender, EventArgs e)
{
- Control ctl = (Control)sender;
+ Control ctl = (Control) sender;
switch (ctl.Name)
{
@@ -177,13 +179,19 @@ namespace Handbrake.Controls // Configure the widgets with values
if (drp_audioEncoder.Text.Contains("AC3") || drp_audioEncoder.Text.Contains("DTS"))
{
- drp_audioMix.Enabled = drp_audioBitrate.Enabled = drp_audioSample.Enabled = tb_drc.Enabled = false;
- lbl_bitrate.Enabled = lbl_drc.Enabled = lbl_drcHeader.Enabled = lbl_mixdown.Enabled = lbl_sampleRate.Enabled = false;
+ drp_audioMix.Enabled =
+ drp_audioBitrate.Enabled = drp_audioSample.Enabled = tb_drc.Enabled = false;
+ lbl_bitrate.Enabled =
+ lbl_drc.Enabled =
+ lbl_drcHeader.Enabled = lbl_mixdown.Enabled = lbl_sampleRate.Enabled = false;
}
else
{
- drp_audioMix.Enabled = drp_audioBitrate.Enabled = drp_audioSample.Enabled = tb_drc.Enabled = true;
- lbl_bitrate.Enabled = lbl_drc.Enabled = lbl_drcHeader.Enabled = lbl_mixdown.Enabled = lbl_sampleRate.Enabled = true;
+ drp_audioMix.Enabled =
+ drp_audioBitrate.Enabled = drp_audioSample.Enabled = tb_drc.Enabled = true;
+ lbl_bitrate.Enabled =
+ lbl_drc.Enabled =
+ lbl_drcHeader.Enabled = lbl_mixdown.Enabled = lbl_sampleRate.Enabled = true;
}
// Update an item in the Audio list if required.
@@ -209,7 +217,7 @@ namespace Handbrake.Controls double value;
if (tb_drc.Value == 0) value = 0;
else
- value = ((tb_drc.Value - 1) / 10.0) + 1;
+ value = ((tb_drc.Value - 1)/10.0) + 1;
lbl_drc.Text = value.ToString();
@@ -224,6 +232,7 @@ namespace Handbrake.Controls lv_audioList.Select();
}
+
private void lv_audioList_SelectedIndexChanged(object sender, EventArgs e)
{
// Set the dropdown controls based on the selected item in the Audio List.
@@ -234,15 +243,17 @@ namespace Handbrake.Controls drp_audioMix.SelectedItem = lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[3].Text;
drp_audioSample.SelectedItem = lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[4].Text;
drp_audioBitrate.SelectedItem = lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[5].Text;
- double drcValue; int drcCalculated;
+ double drcValue;
+ int drcCalculated;
double.TryParse(lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[6].Text, out drcValue);
if (drcValue != 0)
- drcValue = ((drcValue * 10) + 1) - 10;
+ drcValue = ((drcValue*10) + 1) - 10;
int.TryParse(drcValue.ToString(), out drcCalculated);
tb_drc.Value = drcCalculated;
lbl_drc.Text = lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[6].Text;
- AudioTrackGroup.Text = "Selected Track: " + lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[0].Text;
+ AudioTrackGroup.Text = "Selected Track: " +
+ lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[0].Text;
}
else
AudioTrackGroup.Text = "Selected Track: None (Click \"Add Track\" to add)";
@@ -253,7 +264,7 @@ namespace Handbrake.Controls {
double value = 0;
if (tb_drc.Value != 0)
- value = ((tb_drc.Value - 1) / 10.0) + 1;
+ value = ((tb_drc.Value - 1)/10.0) + 1;
// Create a new row for the Audio list based on the currently selected items in the dropdown.
ListViewItem newTrack = new ListViewItem(GetNewID().ToString());
@@ -273,6 +284,7 @@ namespace Handbrake.Controls lv_audioList.Items[lv_audioList.Items.Count - 1].Selected = true;
lv_audioList.Select();
}
+
private void btn_RemoveAudioTrack_Click(object sender, EventArgs e)
{
RemoveTrack();
@@ -283,10 +295,12 @@ namespace Handbrake.Controls {
MoveTrack(true);
}
+
private void audioList_movedown_Click(object sender, EventArgs e)
{
MoveTrack(false);
}
+
private void audioList_remove_Click(object sender, EventArgs e)
{
RemoveTrack();
@@ -299,16 +313,19 @@ namespace Handbrake.Controls if (this.AudioListChanged != null)
this.AudioListChanged(this, new EventArgs());
}
+
private void ClearAudioList()
{
lv_audioList.Items.Clear();
if (this.AudioListChanged != null)
this.AudioListChanged(this, new EventArgs());
}
+
private int GetNewID()
{
return lv_audioList.Items.Count + 1;
}
+
private void RemoveTrack()
{
// Remove the Item and reselect the control if the following conditions are met.
@@ -337,6 +354,7 @@ namespace Handbrake.Controls ReGenerateListIDs();
}
}
+
private void MoveTrack(bool up)
{
if (lv_audioList.SelectedIndices.Count == 0) return;
@@ -344,7 +362,8 @@ namespace Handbrake.Controls ListViewItem item = lv_audioList.SelectedItems[0];
int index = item.Index;
- if (up) index--; else index++;
+ if (up) index--;
+ else index++;
if (index < lv_audioList.Items.Count || (lv_audioList.Items.Count > index && index >= 0))
{
@@ -354,6 +373,7 @@ namespace Handbrake.Controls lv_audioList.Focus();
}
}
+
private void ReGenerateListIDs()
{
int i = 1;
@@ -363,6 +383,7 @@ namespace Handbrake.Controls i++;
}
}
+
private void SetBitrate()
{
int max = 0;
@@ -418,6 +439,7 @@ namespace Handbrake.Controls if (drp_audioBitrate.SelectedItem == null)
drp_audioBitrate.SelectedIndex = drp_audioBitrate.Items.Count - 1;
}
+
private void SetMixDown()
{
drp_audioMix.Items.Clear();
diff --git a/win/C#/Controls/Filters.cs b/win/C#/Controls/Filters.cs index adf7bde16..47657b57e 100644 --- a/win/C#/Controls/Filters.cs +++ b/win/C#/Controls/Filters.cs @@ -4,11 +4,11 @@ Homepage: <http://handbrake.fr>.
It may be used under the terms of the GNU General Public License. */
-using System;
-using System.Windows.Forms;
-
namespace Handbrake.Controls
{
+ using System;
+ using System.Windows.Forms;
+
public partial class Filters : UserControl
{
/// <summary>
@@ -17,6 +17,7 @@ namespace Handbrake.Controls public event EventHandler FilterSettingsChanged;
/// <summary>
+ /// Initializes a new instance of the <see cref="Filters"/> class.
/// Creates a new instance of Filters
/// </summary>
public Filters()
@@ -35,12 +36,12 @@ namespace Handbrake.Controls {
get
{
- string query = "";
+ string query = string.Empty;
- switch (drop_detelecine.Text) // DeTelecine
+ switch (drop_detelecine.Text) // DeTelecine
{
case "Off":
- query += "";
+ query += string.Empty;
break;
case "Default":
query += " --detelecine";
@@ -49,7 +50,7 @@ namespace Handbrake.Controls query += " --detelecine=\"" + text_customDT.Text + "\"";
break;
default:
- query += "";
+ query += string.Empty;
break;
}
@@ -57,7 +58,7 @@ namespace Handbrake.Controls switch (drop_decomb.Text) // Decomb
{
case "Off":
- query += "";
+ query += string.Empty;
break;
case "Default":
query += " --decomb";
@@ -66,14 +67,14 @@ namespace Handbrake.Controls query += " --decomb=\"" + text_customDC.Text + "\"";
break;
default:
- query += "";
+ query += string.Empty;
break;
}
switch (drop_deinterlace.Text) // DeInterlace
{
case "None":
- query += "";
+ query += string.Empty;
break;
case "Fast":
query += " --deinterlace=\"fast\"";
@@ -88,14 +89,14 @@ namespace Handbrake.Controls query += " --deinterlace=\"" + text_customDI.Text + "\"";
break;
default:
- query += "";
+ query += string.Empty;
break;
}
switch (drop_denoise.Text) // Denoise
{
case "None":
- query += "";
+ query += string.Empty;
break;
case "Weak":
query += " --denoise=\"weak\"";
@@ -110,7 +111,7 @@ namespace Handbrake.Controls query += " --denoise=\"" + text_customDN.Text + "\"";
break;
default:
- query += "";
+ query += string.Empty;
break;
}
@@ -130,7 +131,7 @@ namespace Handbrake.Controls /// <param name="value">The value part of the CLI string</param>
public void SetDeTelecine(string value)
{
- text_customDT.Text = "";
+ text_customDT.Text = string.Empty;
text_customDT.Visible = false;
switch (value)
{
@@ -154,7 +155,7 @@ namespace Handbrake.Controls /// <param name="value">The value part of the CLI string</param>
public void SetDeNoise(string value)
{
- text_customDN.Text = "";
+ text_customDN.Text = string.Empty;
text_customDN.Visible = false;
switch (value)
{
@@ -184,11 +185,10 @@ namespace Handbrake.Controls /// <param name="value">The value part of the CLI string</param>
public void SetDeInterlace(string value)
{
- text_customDI.Text = "";
+ text_customDI.Text = string.Empty;
text_customDI.Visible = false;
switch (value)
{
-
case "Off":
drop_deinterlace.SelectedIndex = 0;
break;
@@ -216,7 +216,7 @@ namespace Handbrake.Controls /// <param name="value">The value part of the CLI string</param>
public void SetDecomb(string value)
{
- text_customDC.Text = "";
+ text_customDC.Text = string.Empty;
text_customDC.Visible = false;
switch (value)
{
@@ -269,6 +269,7 @@ namespace Handbrake.Controls if (this.FilterSettingsChanged != null)
this.FilterSettingsChanged(this, new EventArgs());
}
+
private void DropDecombSelectedIndexChanged(object sender, EventArgs e)
{
text_customDC.Visible = drop_decomb.Text == "Custom";
@@ -279,6 +280,7 @@ namespace Handbrake.Controls if (this.FilterSettingsChanged != null)
this.FilterSettingsChanged(this, new EventArgs());
}
+
private void DropDeinterlaceSelectedIndexChanged(object sender, EventArgs e)
{
text_customDI.Visible = drop_deinterlace.Text == "Custom";
@@ -289,6 +291,7 @@ namespace Handbrake.Controls if (this.FilterSettingsChanged != null)
this.FilterSettingsChanged(this, new EventArgs());
}
+
private void DropDenoiseSelectedIndexChanged(object sender, EventArgs e)
{
text_customDN.Visible = drop_denoise.Text == "Custom";
@@ -297,6 +300,7 @@ namespace Handbrake.Controls if (this.FilterSettingsChanged != null)
this.FilterSettingsChanged(this, new EventArgs());
}
+
private void SliderDeblockScroll(object sender, EventArgs e)
{
lbl_deblockVal.Text = slider_deblock.Value == 4 ? "Off" : slider_deblock.Value.ToString();
@@ -306,4 +310,4 @@ namespace Handbrake.Controls this.FilterSettingsChanged(this, new EventArgs());
}
}
-}
+}
\ No newline at end of file diff --git a/win/C#/Controls/PictureSettings.cs b/win/C#/Controls/PictureSettings.cs index 5eedf24df..44de20038 100644 --- a/win/C#/Controls/PictureSettings.cs +++ b/win/C#/Controls/PictureSettings.cs @@ -4,27 +4,31 @@ Homepage: <http://handbrake.fr>.
It may be used under the terms of the GNU General Public License. */
-using System;
-using System.ComponentModel;
-using System.Drawing;
-using System.Globalization;
-using System.Windows.Forms;
-using Handbrake.Parsing;
-using Handbrake.Presets;
-
namespace Handbrake.Controls
{
+ using System;
+ using System.Drawing;
+ using System.Globalization;
+ using System.Windows.Forms;
+ using Parsing;
+ using Presets;
+
public partial class PictureSettings : UserControl
{
private readonly CultureInfo culture = new CultureInfo("en-US", false);
public event EventHandler PictureSettingsChanged;
- private Boolean preventChangingWidth, preventChangingHeight, preventChangingCustom, preventChangingDisplayWidth;
- private int presetMaximumWidth, presetMaximumHeight;
+ private bool preventChangingWidth;
+ private bool preventChangingHeight;
+ private bool preventChangingCustom;
+ private bool preventChangingDisplayWidth;
+ private int presetMaximumWidth;
+ private int presetMaximumHeight;
private double cachedDar;
private Title sourceTitle;
/// <summary>
+ /// Initializes a new instance of the <see cref="PictureSettings"/> class.
/// Creates a new instance of the Picture Settings Class
/// </summary>
public PictureSettings()
@@ -73,7 +77,7 @@ namespace Handbrake.Controls else if (value.Height != 0)
lbl_max.Text = "Max Height";
else
- lbl_max.Text = "";
+ lbl_max.Text = string.Empty;
}
}
@@ -100,7 +104,8 @@ namespace Handbrake.Controls 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)
+ if ((CurrentlySelectedPreset != null && CurrentlySelectedPreset.PictureSettings == false) ||
+ CurrentlySelectedPreset == null)
{
crop_top.Value = GetCropMod2Clean(sourceTitle.AutoCropDimensions[0]);
crop_bottom.Value = GetCropMod2Clean(sourceTitle.AutoCropDimensions[1]);
@@ -120,10 +125,11 @@ namespace Handbrake.Controls }
else
{
- if (text_width.Value == 0 && text_height.Value == 0)// Only update the values if the fields don't already have values.
+ 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;
+ text_height.Value = sourceTitle.Resolution.Height - (int) crop_top.Value - (int) crop_bottom.Value;
}
labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height;
@@ -133,10 +139,10 @@ namespace Handbrake.Controls updownParHeight.Value = sourceTitle.ParVal.Height;
Size croppedDar = CalculateAnamorphicSizes();
- cachedDar = (double)croppedDar.Width / croppedDar.Height;
+ cachedDar = (double) croppedDar.Width/croppedDar.Height;
updownDisplayWidth.Value = croppedDar.Width;
}
-
+
// Picture Controls
private void TextWidthValueChanged(object sender, EventArgs e)
{
@@ -158,17 +164,17 @@ namespace Handbrake.Controls {
preventChangingHeight = true;
- int width = (int)text_width.Value;
+ int width = (int) text_width.Value;
- 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;
+ 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;
if (SourceAspect.Width == 0 && SourceAspect.Height == 0)
break;
- double newHeight = ((double)width * Source.Resolution.Width * SourceAspect.Height * crop_height) /
- (Source.Resolution.Height * SourceAspect.Width * crop_width);
- text_height.Value = (decimal)GetModulusValue(newHeight);
+ double newHeight = ((double) width*Source.Resolution.Width*SourceAspect.Height*crop_height)/
+ (Source.Resolution.Height*SourceAspect.Width*crop_width);
+ text_height.Value = (decimal) GetModulusValue(newHeight);
preventChangingHeight = false;
}
@@ -180,7 +186,7 @@ namespace Handbrake.Controls break;
preventChangingDisplayWidth = true;
- updownDisplayWidth.Value = text_width.Value * updownParWidth.Value / updownParHeight.Value;
+ updownDisplayWidth.Value = text_width.Value*updownParWidth.Value/updownParHeight.Value;
preventChangingDisplayWidth = false;
labelDisplaySize.Text = Math.Truncate(updownDisplayWidth.Value) + "x" + text_height.Value;
@@ -199,6 +205,7 @@ namespace Handbrake.Controls preventChangingWidth = false;
}
+
private void TextHeightValueChanged(object sender, EventArgs e)
{
if (Properties.Settings.Default.disableResCalc)
@@ -218,13 +225,14 @@ namespace Handbrake.Controls {
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;
+ 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;
- double new_width = ((double)text_height.Value * Source.Resolution.Height * SourceAspect.Width * crop_width) /
- (Source.Resolution.Width * SourceAspect.Height * crop_height);
+ double new_width = ((double) text_height.Value*Source.Resolution.Height*SourceAspect.Width*
+ crop_width)/
+ (Source.Resolution.Width*SourceAspect.Height*crop_height);
- text_width.Value = (decimal)GetModulusValue(new_width);
+ text_width.Value = (decimal) GetModulusValue(new_width);
preventChangingWidth = false;
}
@@ -239,12 +247,12 @@ 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;
- updownDisplayWidth.Value = (decimal)rawCalculatedDisplayWidth;
+ updownDisplayWidth.Value = (decimal) rawCalculatedDisplayWidth;
updownParWidth.Value = updownDisplayWidth.Value;
updownParHeight.Value = text_width.Value;
@@ -260,12 +268,13 @@ namespace Handbrake.Controls preventChangingHeight = false;
}
+
private void CheckKeepArCheckedChanged(object sender, EventArgs e)
{
if (Properties.Settings.Default.disableResCalc)
return;
- //Force TextWidth to recalc height
+ // Force TextWidth to recalc height
if (check_KeepAR.Checked)
TextWidthValueChanged(this, new EventArgs());
@@ -280,6 +289,7 @@ namespace Handbrake.Controls if (PictureSettingsChanged != null)
PictureSettingsChanged(this, new EventArgs());
}
+
private void UpdownDisplayWidthValueChanged(object sender, EventArgs e)
{
if (Properties.Settings.Default.disableResCalc)
@@ -305,17 +315,16 @@ namespace Handbrake.Controls if (!int.TryParse(drp_modulus.SelectedItem.ToString(), out modulus))
modulus = 16;
- int rawCalculatedHeight = (int)((int)updownDisplayWidth.Value / cachedDar);
- int modulusHeight = rawCalculatedHeight - (rawCalculatedHeight % modulus);
+ int rawCalculatedHeight = (int) ((int) updownDisplayWidth.Value/cachedDar);
+ int modulusHeight = rawCalculatedHeight - (rawCalculatedHeight%modulus);
// Update value
preventChangingHeight = true;
- text_height.Value = (decimal)modulusHeight;
+ text_height.Value = (decimal) modulusHeight;
updownParWidth.Value = updownDisplayWidth.Value;
updownParHeight.Value = text_width.Value;
preventChangingHeight = false;
}
-
}
// Anamorphic Controls
@@ -376,7 +385,6 @@ namespace Handbrake.Controls updownParWidth.Enabled = !check_KeepAR.Checked;
updownParHeight.Enabled = !check_KeepAR.Checked;
break;
-
}
labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height;
@@ -387,13 +395,14 @@ namespace Handbrake.Controls if (PictureSettingsChanged != null)
PictureSettingsChanged(this, new EventArgs());
}
+
private void DrpModulusSelectedIndexChanged(object sender, EventArgs e)
{
preventChangingWidth = true;
preventChangingHeight = true;
- text_width.Value = (decimal)GetModulusValue((double)text_width.Value);
- text_height.Value = (decimal)GetModulusValue((double)text_height.Value);
+ text_width.Value = (decimal) GetModulusValue((double) text_width.Value);
+ text_height.Value = (decimal) GetModulusValue((double) text_height.Value);
preventChangingWidth = false;
preventChangingHeight = false;
@@ -421,6 +430,7 @@ namespace Handbrake.Controls crop_right.Value = Source.AutoCropDimensions[3];
}
}
+
private void CropValueChanged(object sender, EventArgs e)
{
TextWidthValueChanged(this, new EventArgs());
@@ -446,22 +456,24 @@ namespace Handbrake.Controls get
{
if (Source != null) // display aspect = (width * par_width) / (height * par_height)
- return new Size((Source.ParVal.Width * Source.Resolution.Width), (Source.ParVal.Height * Source.Resolution.Height));
+ return new Size((Source.ParVal.Width*Source.Resolution.Width),
+ (Source.ParVal.Height*Source.Resolution.Height));
return new Size(0, 0); // Fall over to 16:9 and hope for the best
}
}
+
private Size CalculateAnamorphicSizes()
{
if (Source != null)
{
/* Set up some variables to make the math easier to follow. */
- 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;
+ 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 sourceDisplayWidth = (double)croppedWidth * Source.ParVal.Width / Source.ParVal.Height;
+ double sourceDisplayWidth = (double) croppedWidth*Source.ParVal.Width/Source.ParVal.Height;
/*
3 different ways of deciding output dimensions:
@@ -475,31 +487,31 @@ namespace Handbrake.Controls default:
case 1:
/* Strict anamorphic */
- double displayWidth = ((double)croppedWidth * 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, croppedHeight);
+ Size output = new Size((int) displayWidth, croppedHeight);
return output;
case 2:
/* "Loose" anamorphic.
- Uses mod16-compliant dimensions,
- Allows users to set the width
*/
- width = (int)text_width.Value;
+ width = (int) text_width.Value;
width = GetModulusValue(width); /* Time to get picture width that divide cleanly.*/
- height = (width / storageAspect) + 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 pixelAspectWidth = height * sourceDisplayWidth / croppedHeight;
+ double pixelAspectWidth = height*sourceDisplayWidth/croppedHeight;
double pixelAspectHeight = width;
- double disWidthLoose = (width * pixelAspectWidth / pixelAspectHeight);
+ double disWidthLoose = (width*pixelAspectWidth/pixelAspectHeight);
if (double.IsNaN(disWidthLoose))
disWidthLoose = 0;
- return new Size((int)disWidthLoose, (int)height);
+ return new Size((int) disWidthLoose, (int) height);
case 3:
// Get the User Interface Values
@@ -507,31 +519,33 @@ namespace Handbrake.Controls double.TryParse(updownDisplayWidth.Text, out UIdisplayWidth);
/* Anamorphic 3: Power User Jamboree - Set everything based on specified values */
- height = GetModulusValue((double)text_height.Value);
+ height = GetModulusValue((double) text_height.Value);
if (check_KeepAR.Checked)
- return new Size((int)Math.Truncate(UIdisplayWidth), (int)height);
+ return new Size((int) Math.Truncate(UIdisplayWidth), (int) height);
- return new Size((int)Math.Truncate(UIdisplayWidth), (int)height);
+ return new Size((int) Math.Truncate(UIdisplayWidth), (int) height);
}
}
// Return a default value of 0,0 to indicate failure
return new Size(0, 0);
}
+
private double GetModulusValue(double value)
{
int mod = int.Parse(drp_modulus.SelectedItem.ToString());
- double remainder = value % mod;
+ double remainder = value%mod;
if (remainder == 0)
return value;
- return remainder >= ((double)mod / 2) ? value + (mod - remainder) : value - remainder;
+ return remainder >= ((double) mod/2) ? value + (mod - remainder) : value - remainder;
}
+
private static int GetCropMod2Clean(int value)
{
- int remainder = value % 2;
+ int remainder = value%2;
if (remainder == 0) return value;
return (value + remainder);
}
diff --git a/win/C#/Controls/Subtitles.cs b/win/C#/Controls/Subtitles.cs index 34e2cddf3..af4f5d89c 100644 --- a/win/C#/Controls/Subtitles.cs +++ b/win/C#/Controls/Subtitles.cs @@ -4,21 +4,20 @@ Homepage: <http://handbrake.fr>.
It may be used under the terms of the GNU General Public License. */
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Windows.Forms;
-using Handbrake.Functions;
-using Handbrake.Model;
-
namespace Handbrake.Controls
{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
using System.Linq;
+ using System.Windows.Forms;
+ using Functions;
+ using Model;
public partial class Subtitles : UserControl
{
- readonly IDictionary<string, string> langMap = new Dictionary<string, string>();
- readonly List<SubtitleInfo> subList = new List<SubtitleInfo>();
+ private readonly IDictionary<string, string> langMap = new Dictionary<string, string>();
+ private readonly List<SubtitleInfo> subList = new List<SubtitleInfo>();
private int fileContainer;
public Subtitles()
@@ -39,7 +38,10 @@ namespace Handbrake.Controls // Logic
string forcedVal = check_forced.CheckState == CheckState.Checked ? "Yes" : "No";
string defaultSub = check_default.CheckState == CheckState.Checked ? "Yes" : "No";
- string burnedVal = check_burned.CheckState == CheckState.Checked && (!drp_subtitleTracks.Text.Contains("Text")) ? "Yes" : "No";
+ string burnedVal = check_burned.CheckState == CheckState.Checked &&
+ (!drp_subtitleTracks.Text.Contains("Text"))
+ ? "Yes"
+ : "No";
string srtCode = "-", srtLangVal = "-", srtPath = "-", srtFile = "-";
int srtOffsetMs = 0;
@@ -51,25 +53,28 @@ namespace Handbrake.Controls srtFile = Path.GetFileName(openFileDialog.FileName);
srtLangVal = srt_lang.SelectedItem.ToString();
srtCode = srt_charcode.SelectedItem.ToString();
- srtOffsetMs = (int)srt_offset.Value;
+ srtOffsetMs = (int) srt_offset.Value;
if (defaultSub == "Yes") SetNoSrtDefault();
- } else
+ }
+ else
{
if (defaultSub == "Yes") SetNoDefault();
if (burnedVal == "Yes") SetNoBurned();
if (fileContainer == 0)
- burnedVal = "Yes"; // MP4 must have bitmap subs burned in.
+ burnedVal = "Yes"; // MP4 must have bitmap subs burned in.
}
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"))
+ if (drp_subtitleTracks.SelectedItem != null &&
+ drp_subtitleTracks.SelectedItem.ToString().Contains("Bitmap"))
{
if (lv_subList.Items.Cast<ListViewItem>().Any(item => 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.",
+ 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;
}
@@ -77,27 +82,27 @@ namespace Handbrake.Controls }
string trackName = (drp_subtitleTracks.SelectedItem.ToString().Contains(".srt"))
- ? srtLangVal + " (" + srtFile + ")"
- : drp_subtitleTracks.SelectedItem.ToString();
+ ? srtLangVal + " (" + srtFile + ")"
+ : drp_subtitleTracks.SelectedItem.ToString();
SubtitleInfo track = new SubtitleInfo
{
- Track = trackName,
- Forced = forcedVal,
- Burned = burnedVal,
- Default = defaultSub,
- SrtLang = srtLangVal,
- SrtCharCode = srtCode,
- SrtOffset = srtOffsetMs,
- SrtPath = srtPath,
+ Track = trackName,
+ Forced = forcedVal,
+ Burned = burnedVal,
+ Default = defaultSub,
+ SrtLang = srtLangVal,
+ SrtCharCode = srtCode,
+ SrtOffset = srtOffsetMs,
+ SrtPath = srtPath,
SrtFileName = srtFile
};
lv_subList.Items.Add(track.ListView);
subList.Add(track);
-
}
+
private void BtnSrtAddClick(object sender, EventArgs e)
{
if (openFileDialog.ShowDialog() != DialogResult.OK)
@@ -105,6 +110,7 @@ namespace Handbrake.Controls drp_subtitleTracks.Items.Add(Path.GetFileName(openFileDialog.FileName));
drp_subtitleTracks.SelectedItem = Path.GetFileName(openFileDialog.FileName);
}
+
private void BtnRemoveSubTrackClick(object sender, EventArgs e)
{
RemoveTrack();
@@ -119,7 +125,8 @@ namespace Handbrake.Controls 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
+ if (lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[0].Text.ToLower().Contains(".srt"))
+ // We have an SRT
{
foreach (var item in drp_subtitleTracks.Items)
{
@@ -133,7 +140,7 @@ namespace Handbrake.Controls check_default.CheckState = track.Default == "Yes" ? CheckState.Checked : CheckState.Unchecked;
SubGroupBox.Text = "Selected Track: " + track.Track;
}
- else // We have Bitmap/CC
+ else // We have Bitmap/CC
{
foreach (var item in drp_subtitleTracks.Items)
{
@@ -144,7 +151,8 @@ namespace Handbrake.Controls check_forced.CheckState = track.Forced == "Yes" ? CheckState.Checked : CheckState.Unchecked;
check_burned.CheckState = track.Burned == "Yes" ? CheckState.Checked : CheckState.Unchecked;
check_default.CheckState = track.Default == "Yes" ? CheckState.Checked : CheckState.Unchecked;
- SubGroupBox.Text = "Selected Track: " + lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[0].Text;
+ SubGroupBox.Text = "Selected Track: " +
+ lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[0].Text;
}
}
else
@@ -176,17 +184,20 @@ namespace Handbrake.Controls if (drp_subtitleTracks.SelectedItem.ToString().Contains(".srt"))
{
lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[0].Text = srt_lang.SelectedItem + "(" +
- drp_subtitleTracks.SelectedItem + ")";
+ drp_subtitleTracks.SelectedItem + ")";
lv_subList.Select();
- } else
+ }
+ else
{
lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[0].Text =
drp_subtitleTracks.SelectedItem.ToString();
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 CheckForcedCheckedChanged(object sender, EventArgs e)
{
if (lv_subList.Items.Count == 0 || lv_subList.SelectedIndices.Count == 0) return;
@@ -194,8 +205,10 @@ namespace Handbrake.Controls 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 CheckBurnedCheckedChanged(object sender, EventArgs e)
{
if (lv_subList.Items.Count == 0 || lv_subList.SelectedIndices.Count == 0) return;
@@ -206,8 +219,10 @@ 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 CheckDefaultCheckedChanged(object sender, EventArgs e)
{
if (lv_subList.Items.Count == 0 || lv_subList.SelectedIndices.Count == 0) return;
@@ -221,8 +236,10 @@ 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 SrtOffsetValueChanged(object sender, EventArgs e)
{
// Update an item in the list if required.
@@ -232,8 +249,10 @@ 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 SrtCharcodeSelectedIndexChanged(object sender, EventArgs e)
{
if (lv_subList.Items.Count == 0 || lv_subList.SelectedIndices.Count == 0) return;
@@ -241,8 +260,10 @@ namespace Handbrake.Controls 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 SrtLangSelectedIndexChanged(object sender, EventArgs e)
{
if (lv_subList.Items.Count == 0 || lv_subList.SelectedIndices.Count == 0) return;
@@ -250,7 +271,8 @@ namespace Handbrake.Controls 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
@@ -271,6 +293,7 @@ namespace Handbrake.Controls }
}
}
+
private void MnuMovedownClick(object sender, EventArgs e)
{
if (lv_subList.SelectedIndices.Count != 0)
@@ -288,6 +311,7 @@ namespace Handbrake.Controls }
}
}
+
private void MnuRemoveClick(object sender, EventArgs e)
{
RemoveTrack();
@@ -305,7 +329,7 @@ namespace Handbrake.Controls {
item.SubItems[3].Text = "No";
subList[c].Default = "No";
- }
+ }
}
c++;
}
@@ -330,6 +354,7 @@ namespace Handbrake.Controls c++;
}
}
+
private void SetNoBurned()
{
int c = 0;
@@ -343,6 +368,7 @@ namespace Handbrake.Controls c++;
}
}
+
private void RemoveTrack()
{
// Remove the Item and reselect the control if the following conditions are met.
@@ -391,7 +417,7 @@ namespace Handbrake.Controls /// Checks of the current settings will require the m4v file extension
/// </summary>
/// <returns>True if Yes</returns>
- public Boolean RequiresM4V()
+ public bool RequiresM4V()
{
foreach (ListViewItem item in lv_subList.Items)
{
@@ -443,7 +469,7 @@ namespace Handbrake.Controls public void SetContainer(int value)
{
fileContainer = value;
- Boolean trigger = false;
+ bool trigger = false;
if (fileContainer != 1)
foreach (ListViewItem item in lv_subList.Items)
{
@@ -498,17 +524,17 @@ namespace Handbrake.Controls {
srtCount++; // SRT track id.
- srtLang += srtLang == "" ? langMap[item.SrtLang] : "," + langMap[item.SrtLang];
- srtCodeset += srtCodeset == "" ? item.SrtCharCode : "," + item.SrtCharCode;
+ srtLang += srtLang == string.Empty ? langMap[item.SrtLang] : "," + langMap[item.SrtLang];
+ srtCodeset += srtCodeset == string.Empty ? item.SrtCharCode : "," + item.SrtCharCode;
if (item.Default == "Yes")
srtDefault = srtCount.ToString();
itemToAdd = item.SrtPath;
- srtFile += srtFile == "" ? itemToAdd : "," + itemToAdd;
+ srtFile += srtFile == string.Empty ? itemToAdd : "," + itemToAdd;
itemToAdd = item.SrtOffset.ToString();
- srtOffset += srtOffset == "" ? itemToAdd : "," + itemToAdd;
+ srtOffset += srtOffset == string.Empty ? itemToAdd : "," + itemToAdd;
}
else // We have Bitmap or CC
{
@@ -523,18 +549,18 @@ namespace Handbrake.Controls itemToAdd = tempSub[0];
}
- subtitleTracks += subtitleTracks == "" ? itemToAdd : "," + itemToAdd;
+ subtitleTracks += subtitleTracks == string.Empty ? itemToAdd : "," + itemToAdd;
// Find --subtitle-forced
- itemToAdd = "";
+ itemToAdd = string.Empty;
tempSub = item.Track.Split(' ');
trackId = tempSub[0];
if (item.Forced == "Yes")
itemToAdd = "scan";
- if (itemToAdd != "")
- subtitleForced += subtitleForced == "" ? itemToAdd : "," + itemToAdd;
+ if (itemToAdd != string.Empty)
+ subtitleForced += subtitleForced == string.Empty ? itemToAdd : "," + itemToAdd;
// Find --subtitle-burn and --subtitle-default
trackId = tempSub[0];
@@ -551,32 +577,31 @@ namespace Handbrake.Controls }
// Build The CLI Subtitles Query
- if (subtitleTracks != "")
+ if (subtitleTracks != string.Empty)
{
query += " --subtitle " + subtitleTracks;
- if (subtitleForced != "")
+ if (subtitleForced != string.Empty)
query += " --subtitle-forced=" + subtitleForced;
- if (subtitleBurn != "")
+ if (subtitleBurn != string.Empty)
query += " --subtitle-burn=" + subtitleBurn;
- if (subtitleDefault != "")
+ if (subtitleDefault != string.Empty)
query += " --subtitle-default=" + subtitleDefault;
}
- if (srtFile != "") // SRTs
+ if (srtFile != string.Empty) // SRTs
{
query += " --srt-file " + "\"" + srtFile + "\"";
- if (srtCodeset != "")
+ if (srtCodeset != string.Empty)
query += " --srt-codeset " + srtCodeset;
- if (srtOffset != "")
+ if (srtOffset != string.Empty)
query += " --srt-offset " + srtOffset;
- if (srtLang != "")
+ if (srtLang != string.Empty)
query += " --srt-lang " + srtLang;
- if (srtDefault != "")
+ if (srtDefault != string.Empty)
query += " --srt-default=" + srtDefault;
}
-
}
return query;
}
diff --git a/win/C#/Controls/x264Panel.cs b/win/C#/Controls/x264Panel.cs index 56146a0ae..27809415a 100644 --- a/win/C#/Controls/x264Panel.cs +++ b/win/C#/Controls/x264Panel.cs @@ -4,11 +4,11 @@ Homepage: <http://handbrake.fr>.
It may be used under the terms of the GNU General Public License. */
-using System;
-using System.Windows.Forms;
-
namespace Handbrake.Controls
{
+ using System;
+ using System.Windows.Forms;
+
public partial class x264Panel : UserControl
{
/*
@@ -17,6 +17,7 @@ namespace Handbrake.Controls */
/// <summary>
+ /// Initializes a new instance of the <see cref="x264Panel"/> class.
/// Initializes a new instance of the x264 panel user control
/// </summary>
public x264Panel()
@@ -37,7 +38,7 @@ namespace Handbrake.Controls get { return " -x " + rtf_x264Query.Text; }
set { rtf_x264Query.Text = value; }
}
-
+
/// <summary>
/// Reset all components to defaults and clears the x264 rtf box
/// </summary>
@@ -64,7 +65,7 @@ namespace Handbrake.Controls slider_psytrellis.Value = 0;
drop_adaptBFrames.SelectedIndex = 0;
- rtf_x264Query.Text = "";
+ rtf_x264Query.Text = string.Empty;
}
/// <summary>
@@ -73,14 +74,14 @@ namespace Handbrake.Controls public void X264_StandardizeOptString()
{
/* Set widgets depending on the opt string in field */
- String thisOpt; // The separated option such as "bframes=3"
- String optName; // The option name such as "bframes"
- String optValue;// The option value such as "3"
- String changedOptString = "";
- String[] currentOptsArray;
+ string thisOpt; // The separated option such as "bframes=3"
+ string optName; // The option name such as "bframes"
+ string optValue; // The option value such as "3"
+ string changedOptString = string.Empty;
+ string[] currentOptsArray;
/*First, we get an opt string to process */
- String currentOptString = rtf_x264Query.Text;
+ string currentOptString = rtf_x264Query.Text;
/*verify there is an opt string to process */
if (currentOptString.Contains("="))
@@ -97,8 +98,8 @@ namespace Handbrake.Controls if (currentOptsArray[currentOptsArrayCount - 1] == string.Empty)
break;
- String[] splitOptRange = thisOpt.Split('=');
- if (thisOpt != "")
+ string[] splitOptRange = thisOpt.Split('=');
+ if (thisOpt != string.Empty)
{
if (thisOpt.Contains("="))
{
@@ -132,7 +133,7 @@ namespace Handbrake.Controls }
/* Change the option string to reflect the new standardized option string */
- if (changedOptString != "")
+ if (changedOptString != string.Empty)
rtf_x264Query.Text = changedOptString;
}
@@ -143,9 +144,9 @@ namespace Handbrake.Controls /// </summary>
/// <param name="cleanOptNameString"></param>
/// <returns></returns>
- private static string X264_StandardizeOptNames(String cleanOptNameString)
+ private static string X264_StandardizeOptNames(string cleanOptNameString)
{
- String input = cleanOptNameString;
+ string input = cleanOptNameString;
if (input.Equals("ref") || input.Equals("frameref"))
cleanOptNameString = "ref";
@@ -195,13 +196,13 @@ namespace Handbrake.Controls public void X264_SetCurrentSettingsInPanel()
{
/* Set widgets depending on the opt string in field */
- String thisOpt; // The separated option such as "bframes=3"
- String optName; // The option name such as "bframes"
- String optValue;// The option value such as "3"
- String[] currentOptsArray;
+ string thisOpt; // The separated option such as "bframes=3"
+ string optName; // The option name such as "bframes"
+ string optValue; // The option value such as "3"
+ string[] currentOptsArray;
- //Set currentOptString to the contents of the text box.
- String currentOptString = rtf_x264Query.Text.Replace("\n", "");
+ // Set currentOptString to the contents of the text box.
+ string currentOptString = rtf_x264Query.Text.Replace("\n", string.Empty);
/*verify there is an opt string to process */
if (currentOptString.Contains("="))
@@ -217,7 +218,7 @@ namespace Handbrake.Controls for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
{
thisOpt = currentOptsArray[loopcounter];
- String[] splitOptRange = thisOpt.Split('=');
+ string[] splitOptRange = thisOpt.Split('=');
if (thisOpt.Contains("="))
{
@@ -282,9 +283,9 @@ namespace Handbrake.Controls if (optValue == "auto")
optValue = "Automatic";
- if (optValue != "")
+ if (optValue != string.Empty)
{
- Char[] letters = optValue.ToCharArray();
+ char[] letters = optValue.ToCharArray();
letters[0] = Char.ToUpper(letters[0]);
optValue = new string(letters);
}
@@ -296,7 +297,7 @@ namespace Handbrake.Controls string alphaDeblock = splitDeblock[0];
string betaDeblock = splitDeblock[1];
- if (alphaDeblock.Equals("0") && betaDeblock.Replace("\n", "").Equals("0"))
+ if (alphaDeblock.Equals("0") && betaDeblock.Replace("\n", string.Empty).Equals("0"))
{
drop_deblockAlpha.SelectedItem = "Default (0)";
drop_deblockBeta.SelectedItem = "Default (0)";
@@ -305,7 +306,9 @@ namespace Handbrake.Controls {
drop_deblockAlpha.SelectedItem = !alphaDeblock.Equals("0") ? alphaDeblock : "0";
- drop_deblockBeta.SelectedItem = !betaDeblock.Replace("\n", "").Equals("0") ? betaDeblock.Replace("\n", "") : "0";
+ drop_deblockBeta.SelectedItem = !betaDeblock.Replace("\n", string.Empty).Equals("0")
+ ? betaDeblock.Replace("\n", string.Empty)
+ : "0";
}
continue;
case "analyse":
@@ -329,9 +332,9 @@ namespace Handbrake.Controls int val, val2;
// default psy-rd = 1 (10 for the slider)
- psyrd = double.TryParse(x[0], out psyrd) ? psyrd * 10 : 10.0;
+ psyrd = double.TryParse(x[0], out psyrd) ? psyrd*10 : 10.0;
// default psy-trellis = 0
- psytrellis = double.TryParse(x[1], out psytrellis) ? psytrellis * 10 : 0.0;
+ psytrellis = double.TryParse(x[1], out psytrellis) ? psytrellis*10 : 0.0;
int.TryParse(psyrd.ToString(), out val);
int.TryParse(psytrellis.ToString(), out val2);
@@ -351,16 +354,17 @@ namespace Handbrake.Controls private void OnX264WidgetChange(string sender)
{
Animate(sender);
- String optNameToChange = sender;
- String currentOptString = rtf_x264Query.Text;
+ string optNameToChange = sender;
+ string currentOptString = rtf_x264Query.Text;
/*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after
the first character of the opt string (hence the ":") */
- String checkOptNameToChange = ":" + optNameToChange + "=";
- String checkOptNameToChangeBegin = optNameToChange + "=";
+ string checkOptNameToChange = ":" + optNameToChange + "=";
+ string checkOptNameToChangeBegin = optNameToChange + "=";
// IF the current H264 Option String Contains Multiple Items or Just 1 Item
- if ((currentOptString.Contains(checkOptNameToChange)) || (currentOptString.StartsWith(checkOptNameToChangeBegin)))
+ if ((currentOptString.Contains(checkOptNameToChange)) ||
+ (currentOptString.StartsWith(checkOptNameToChangeBegin)))
HasOptions(currentOptString, optNameToChange);
else // IF there is no options in the rich text box!
HasNoOptions(optNameToChange);
@@ -374,12 +378,12 @@ namespace Handbrake.Controls /// <param name="optNameToChange"></param>
private void HasOptions(string currentOptString, string optNameToChange)
{
- String thisOpt; // The separated option such as "bframes=3"
- String optName; // The option name such as "bframes"
- String[] currentOptsArray;
+ string thisOpt; // The separated option such as "bframes=3"
+ string optName; // The option name such as "bframes"
+ string[] currentOptsArray;
/* Create new empty opt string*/
- String changedOptString = "";
+ string changedOptString = string.Empty;
/*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
currentOptsArray = currentOptString.Split(':');
@@ -393,7 +397,7 @@ namespace Handbrake.Controls {
string[] splitOptRange = thisOpt.Split('=');
- optName = splitOptRange[0]; // e.g bframes
+ optName = splitOptRange[0]; // e.g bframes
/*
* Run through the available widgets for x264 opts and set them, as you add widgets,
@@ -405,14 +409,15 @@ namespace Handbrake.Controls {
if (optNameToChange.Equals("deblock"))
{
- String da = drop_deblockAlpha.SelectedItem.ToString();
- String db = drop_deblockBeta.SelectedItem.ToString();
+ string da = drop_deblockAlpha.SelectedItem.ToString();
+ string db = drop_deblockBeta.SelectedItem.ToString();
- if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
+ if (((da.Contains("Default")) && (db.Contains("Default"))) ||
+ ((da.Contains("0")) && (db.Contains("0"))))
{
drop_deblockBeta.SelectedItem = "Default (0)";
drop_deblockAlpha.SelectedItem = "Default (0)";
- thisOpt = "";
+ thisOpt = string.Empty;
}
else if ((!da.Contains("Default")) && (db.Contains("Default")))
{
@@ -430,11 +435,11 @@ namespace Handbrake.Controls else if (optNameToChange.Equals("psy-rd"))
{
if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
- thisOpt = "";
+ thisOpt = string.Empty;
else
{
- double psyrd = slider_psyrd.Value * 0.1;
- double psytre = slider_psytrellis.Value * 0.1;
+ double psyrd = slider_psyrd.Value*0.1;
+ double psytre = slider_psytrellis.Value*0.1;
string rd = psyrd.ToString("f1");
string rt = psytre.ToString("f1");
@@ -443,19 +448,21 @@ namespace Handbrake.Controls }
}
else if (optNameToChange.Equals("mixed-refs"))
- thisOpt = check_mixedReferences.CheckState == CheckState.Checked ? "mixed-refs=1" : "mixed-refs=0";
+ thisOpt = check_mixedReferences.CheckState == CheckState.Checked
+ ? "mixed-refs=1"
+ : "mixed-refs=0";
else if (optNameToChange.Equals("weightb"))
- thisOpt = check_weightedBFrames.CheckState == CheckState.Checked ? "" : "weightb=0";
+ thisOpt = check_weightedBFrames.CheckState == CheckState.Checked ? string.Empty : "weightb=0";
else if (optNameToChange.Equals("b-pyramid"))
- thisOpt = check_pyrmidalBFrames.CheckState == CheckState.Checked ? "b-pyramid=1" : "";
+ thisOpt = check_pyrmidalBFrames.CheckState == CheckState.Checked ? "b-pyramid=1" : string.Empty;
else if (optNameToChange.Equals("no-fast-pskip"))
- thisOpt = check_noFastPSkip.CheckState == CheckState.Checked ? "no-fast-pskip=1" : "";
+ thisOpt = check_noFastPSkip.CheckState == CheckState.Checked ? "no-fast-pskip=1" : string.Empty;
else if (optNameToChange.Equals("no-dct-decimate"))
- thisOpt = check_noDCTDecimate.CheckState == CheckState.Checked ? "no-dct-decimate=1" : "";
+ thisOpt = check_noDCTDecimate.CheckState == CheckState.Checked ? "no-dct-decimate=1" : string.Empty;
else if (optNameToChange.Equals("8x8dct"))
thisOpt = check_8x8DCT.CheckState == CheckState.Checked ? "8x8dct=1" : "8x8dct=0";
else if (optNameToChange.Equals("cabac"))
- thisOpt = check_Cabac.CheckState == CheckState.Checked ? "" : "cabac=0";
+ thisOpt = check_Cabac.CheckState == CheckState.Checked ? string.Empty : "cabac=0";
else if (optNameToChange.Equals("me"))
{
switch (drop_MotionEstimationMethod.SelectedIndex)
@@ -481,7 +488,7 @@ namespace Handbrake.Controls break;
default:
- thisOpt = "";
+ thisOpt = string.Empty;
break;
}
}
@@ -506,7 +513,7 @@ namespace Handbrake.Controls break;
default:
- thisOpt = "";
+ thisOpt = string.Empty;
break;
}
}
@@ -523,7 +530,7 @@ namespace Handbrake.Controls break;
default:
- thisOpt = "";
+ thisOpt = string.Empty;
break;
}
}
@@ -531,47 +538,47 @@ namespace Handbrake.Controls {
thisOpt = !drop_MotionEstimationRange.SelectedItem.ToString().Contains("Default")
? "merange=" + drop_MotionEstimationRange.SelectedItem
- : "";
+ : string.Empty;
}
else if (optNameToChange.Equals("b-adapt"))
{
thisOpt = !drop_adaptBFrames.SelectedItem.ToString().Contains("Default")
? "b-adapt=" + (drop_adaptBFrames.SelectedIndex - 1)
- : "";
+ : string.Empty;
}
else if (optNameToChange.Equals("ref"))
{
thisOpt = !drop_refFrames.SelectedItem.ToString().Contains("Default")
? "ref=" + drop_refFrames.SelectedItem
- : "";
+ : string.Empty;
}
else if (optNameToChange.Equals("bframes"))
{
- String value = drop_bFrames.SelectedItem.ToString();
+ string value = drop_bFrames.SelectedItem.ToString();
thisOpt = !drop_bFrames.SelectedItem.ToString().Contains("Default")
? "bframes=" + value
- : "";
+ : string.Empty;
}
else if (optNameToChange.Equals("subq"))
{
- String value = drop_subpixelMotionEstimation.SelectedItem.ToString();
+ string value = drop_subpixelMotionEstimation.SelectedItem.ToString();
thisOpt = !drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default")
? "subq=" + value
- : "";
+ : string.Empty;
}
else if (optNameToChange.Equals("trellis"))
{
- String value = drop_trellis.SelectedItem.ToString();
+ string value = drop_trellis.SelectedItem.ToString();
thisOpt = !drop_trellis.SelectedItem.ToString().Contains("Default")
? "trellis=" + value
- : "";
+ : string.Empty;
}
}
}
/* Construct New String for opts here */
- if (!thisOpt.Equals(""))
- changedOptString = changedOptString.Equals("") ? thisOpt : changedOptString + ":" + thisOpt;
+ if (!thisOpt.Equals(string.Empty))
+ changedOptString = changedOptString.Equals(string.Empty) ? thisOpt : changedOptString + ":" + thisOpt;
}
/* Change the option string to reflect the new mod settings */
@@ -586,8 +593,8 @@ namespace Handbrake.Controls /// <param name="optNameToChange"></param>
private void HasNoOptions(IEquatable<string> optNameToChange)
{
- string colon = "";
- if (rtf_x264Query.Text != "")
+ string colon = string.Empty;
+ if (rtf_x264Query.Text != string.Empty)
colon = ":";
string query = rtf_x264Query.Text;
@@ -669,11 +676,10 @@ namespace Handbrake.Controls int value = drop_adaptBFrames.SelectedIndex - 1;
query = query + colon + "b-adapt=" + value;
}
-
else if (optNameToChange.Equals("deblock"))
{
- String da = drop_deblockAlpha.SelectedItem.ToString();
- String db = drop_deblockBeta.Text;
+ string da = drop_deblockAlpha.SelectedItem.ToString();
+ string db = drop_deblockBeta.Text;
if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
{
@@ -694,11 +700,11 @@ namespace Handbrake.Controls else if (optNameToChange.Equals("psy-rd"))
{
if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
- query += "";
+ query += string.Empty;
else
{
- double psyrd = slider_psyrd.Value * 0.1;
- double psytre = slider_psytrellis.Value * 0.1;
+ double psyrd = slider_psyrd.Value*0.1;
+ double psytre = slider_psytrellis.Value*0.1;
string rd = psyrd.ToString("f1");
string rt = psytre.ToString("f1");
@@ -750,13 +756,13 @@ namespace Handbrake.Controls }
else if (optNameToChange.Equals("bframes"))
{
- String value = drop_bFrames.SelectedItem.ToString();
+ string value = drop_bFrames.SelectedItem.ToString();
if (!drop_bFrames.SelectedItem.ToString().Contains("Default"))
query = query + colon + "bframes=" + value;
}
else if (optNameToChange.Equals("subq"))
{
- String value = drop_subpixelMotionEstimation.SelectedItem.ToString();
+ string value = drop_subpixelMotionEstimation.SelectedItem.ToString();
if (!drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))
query = query + colon + "subq=" + value;
}
@@ -784,10 +790,10 @@ namespace Handbrake.Controls - trellis (if 0, turn off psy-trel)
*/
- switch(sender)
+ switch (sender)
{
case "bframes":
- if (drop_bFrames.SelectedIndex >0 && drop_bFrames.SelectedIndex < 2 )
+ if (drop_bFrames.SelectedIndex > 0 && drop_bFrames.SelectedIndex < 2)
{
/* If the b-frame widget is at 0 or 1, the user has chosen
not to use b-frames at all. So disable the options
@@ -828,7 +834,7 @@ namespace Handbrake.Controls drop_adaptBFrames.Visible = true;
lbl_adaptBFrames.Visible = true;
}
- break;
+ break;
case "cabac":
if (check_Cabac.Checked == false)
{
@@ -842,7 +848,7 @@ namespace Handbrake.Controls drop_trellis.Visible = true;
lbl_trellis.Visible = true;
}
- break;
+ break;
case "analyse":
if (drop_analysis.SelectedIndex == 1)
{
@@ -853,7 +859,7 @@ namespace Handbrake.Controls }
else
check_8x8DCT.Visible = true;
- break;
+ break;
case "ref":
if (drop_refFrames.SelectedIndex > 0 && drop_refFrames.SelectedIndex < 3)
{
@@ -863,8 +869,8 @@ namespace Handbrake.Controls }
else
check_mixedReferences.Visible = true;
- break;
- case "me": // Motion Estimation
+ break;
+ case "me": // Motion Estimation
if (drop_MotionEstimationMethod.SelectedIndex < 3)
{
drop_MotionEstimationRange.Visible = false;
@@ -876,9 +882,10 @@ namespace Handbrake.Controls drop_MotionEstimationRange.Visible = true;
lbl_merange.Visible = true;
}
- break;
- case "subq": // subme
- if (drop_subpixelMotionEstimation.SelectedIndex != 0 && drop_subpixelMotionEstimation.SelectedIndex < 7)
+ break;
+ case "subq": // subme
+ if (drop_subpixelMotionEstimation.SelectedIndex != 0 &&
+ drop_subpixelMotionEstimation.SelectedIndex < 7)
{
slider_psyrd.Visible = false;
slider_psyrd.Value = 10;
@@ -900,9 +907,9 @@ namespace Handbrake.Controls lbl_psytrellis.Visible = true;
}
}
- break;
- case "trellis": // subme
- if (drop_trellis.SelectedIndex > 0 && drop_trellis.SelectedIndex < 2 )
+ break;
+ case "trellis": // subme
+ if (drop_trellis.SelectedIndex > 0 && drop_trellis.SelectedIndex < 2)
{
slider_psytrellis.Visible = false;
slider_psytrellis.Value = 0;
@@ -910,21 +917,23 @@ namespace Handbrake.Controls }
else
{
- if ((drop_subpixelMotionEstimation.SelectedIndex == 0 || drop_subpixelMotionEstimation.SelectedIndex >= 7) && check_Cabac.Checked && slider_psytrellis.Visible == false)
+ if ((drop_subpixelMotionEstimation.SelectedIndex == 0 ||
+ drop_subpixelMotionEstimation.SelectedIndex >= 7) && check_Cabac.Checked &&
+ slider_psytrellis.Visible == false)
{
slider_psytrellis.Visible = true;
lbl_psytrellis.Visible = true;
}
}
- break;
+ break;
}
}
private void widgetControlChanged(object sender, EventArgs e)
{
- Control changedControlName = (Control)sender;
- string controlName = "";
+ Control changedControlName = (Control) sender;
+ string controlName = string.Empty;
switch (changedControlName.Name.Trim())
{
@@ -991,11 +1000,12 @@ namespace Handbrake.Controls }
OnX264WidgetChange(controlName);
}
+
private void rtf_x264Query_TextChanged(object sender, EventArgs e)
{
if (rtf_x264Query.Text.EndsWith("\n"))
{
- string query = rtf_x264Query.Text.Replace("\n", "");
+ string query = rtf_x264Query.Text.Replace("\n", string.Empty);
Reset2Defaults();
rtf_x264Query.Text = query;
X264_StandardizeOptString();
@@ -1005,9 +1015,10 @@ namespace Handbrake.Controls Reset2Defaults();
}
}
+
private void btn_reset_Click(object sender, EventArgs e)
{
- rtf_x264Query.Text = "";
+ rtf_x264Query.Text = string.Empty;
Reset2Defaults();
}
}
|