summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsr55 <[email protected]>2009-04-01 23:48:34 +0000
committersr55 <[email protected]>2009-04-01 23:48:34 +0000
commit414d6a56cc67f2fa56353ee3ce80adaa8cfeb45f (patch)
tree171172730223e0e525b68f4afb3ea6ff2e5ccc9c
parent683faec1c917365b32332d86693e72479ba315bf (diff)
WinGui:
- Just some minor code tweaks to clean things up. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2291 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--win/C#/Controls/Decomb.cs5
-rw-r--r--win/C#/Controls/Deinterlace.cs5
-rw-r--r--win/C#/Controls/Detelecine.cs5
-rw-r--r--win/C#/Controls/x264Panel.cs2
-rw-r--r--win/C#/Functions/AppcastReader.cs21
-rw-r--r--win/C#/Functions/Encode.cs49
-rw-r--r--win/C#/Functions/Main.cs30
-rw-r--r--win/C#/Functions/QueryParser.cs7
-rw-r--r--win/C#/Parsing/AudioTrack.cs37
-rw-r--r--win/C#/Parsing/Chapter.cs11
-rw-r--r--win/C#/Parsing/Parser.cs8
-rw-r--r--win/C#/Parsing/Subtitle.cs11
-rw-r--r--win/C#/Parsing/Title.cs4
-rw-r--r--win/C#/Presets/PresetsHandler.cs49
-rw-r--r--win/C#/Queue/QueueHandler.cs5
-rw-r--r--win/C#/frmMain/PresetLoader.cs34
-rw-r--r--win/C#/frmMain/QueryGenerator.cs16
17 files changed, 138 insertions, 161 deletions
diff --git a/win/C#/Controls/Decomb.cs b/win/C#/Controls/Decomb.cs
index 6762bfb8b..35c613ae4 100644
--- a/win/C#/Controls/Decomb.cs
+++ b/win/C#/Controls/Decomb.cs
@@ -19,10 +19,7 @@ namespace Handbrake
private void drop_decomb_SelectedIndexChanged(object sender, EventArgs e)
{
- if (drop_decomb.Text == "Custom")
- text_custom.Visible = true;
- else
- text_custom.Visible = false;
+ text_custom.Visible = drop_decomb.Text == "Custom";
valueChanged(null);
}
diff --git a/win/C#/Controls/Deinterlace.cs b/win/C#/Controls/Deinterlace.cs
index 7acfed826..2ff9b33ef 100644
--- a/win/C#/Controls/Deinterlace.cs
+++ b/win/C#/Controls/Deinterlace.cs
@@ -18,10 +18,7 @@ namespace Handbrake
private void drop_detelecine_SelectedIndexChanged(object sender, EventArgs e)
{
- if (drop_deinterlace.Text == "Custom")
- text_custom.Visible = true;
- else
- text_custom.Visible = false;
+ text_custom.Visible = drop_deinterlace.Text == "Custom";
valueChanged(null);
}
diff --git a/win/C#/Controls/Detelecine.cs b/win/C#/Controls/Detelecine.cs
index 6eaf4621b..4c2e0b237 100644
--- a/win/C#/Controls/Detelecine.cs
+++ b/win/C#/Controls/Detelecine.cs
@@ -19,10 +19,7 @@ namespace Handbrake
private void drop_detelecine_SelectedIndexChanged(object sender, EventArgs e)
{
- if (drop_detelecine.Text == "Custom")
- text_custom.Visible = true;
- else
- text_custom.Visible = false;
+ text_custom.Visible = drop_detelecine.Text == "Custom";
}
public string getDropValue
diff --git a/win/C#/Controls/x264Panel.cs b/win/C#/Controls/x264Panel.cs
index 55a7bc076..6790bb743 100644
--- a/win/C#/Controls/x264Panel.cs
+++ b/win/C#/Controls/x264Panel.cs
@@ -227,7 +227,7 @@ namespace Handbrake.Controls
/// </summary>
/// <param name="cleanOptNameString"></param>
/// <returns></returns>
- private string X264_StandardizeOptNames(String cleanOptNameString)
+ private static string X264_StandardizeOptNames(String cleanOptNameString)
{
String input = cleanOptNameString;
diff --git a/win/C#/Functions/AppcastReader.cs b/win/C#/Functions/AppcastReader.cs
index 11f75fe09..b52c22d77 100644
--- a/win/C#/Functions/AppcastReader.cs
+++ b/win/C#/Functions/AppcastReader.cs
@@ -26,20 +26,19 @@ namespace Handbrake.Functions
/// </summary>
public void getInfo()
{
- Match ver;
- int stable_build, unstable_build = 0;
- string input, unstable_description = "", stable_description, unstable_version = "", stable_version;
- string stable_file, unstable_file = "";
+ int unstable_build = 0;
+ string unstable_description = "", unstable_version = "";
+ string unstable_file = "";
// Check the stable appcast and get the stable build number
readRss(new XmlTextReader(Properties.Settings.Default.appcast));
- input = nodeItem.InnerXml;
- ver = Regex.Match(input, @"sparkle:version=""([0-9]*)\""");
- stable_build = int.Parse(ver.ToString().Replace("sparkle:version=", "").Replace("\"", ""));
+ string input = nodeItem.InnerXml;
+ Match ver = Regex.Match(input, @"sparkle:version=""([0-9]*)\""");
+ int stable_build = int.Parse(ver.ToString().Replace("sparkle:version=", "").Replace("\"", ""));
ver = Regex.Match(input, @"sparkle:shortVersionString=""([0-9].[0-9].[0-9]*)\""");
- stable_version = ver.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");
- stable_description = nodeItem["description"].InnerText;
- stable_file = nodeItem["windows"].InnerText;
+ string stable_version = ver.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");
+ string stable_description = nodeItem["description"].InnerText;
+ string stable_file = nodeItem["windows"].InnerText;
// If this is a snapshot release, or the user wants to check for snapshot releases
if (Properties.Settings.Default.checkSnapshot == "Checked" || Properties.Settings.Default.hb_build.ToString().EndsWith("1"))
@@ -76,7 +75,7 @@ namespace Handbrake.Functions
/// Read the RSS file.
/// </summary>
/// <param name="rssReader"></param>
- private void readRss(XmlTextReader rssReader)
+ private void readRss(XmlReader rssReader)
{
rssDoc = new XmlDocument();
rssDoc.Load(rssReader);
diff --git a/win/C#/Functions/Encode.cs b/win/C#/Functions/Encode.cs
index ed8920c91..1cd3de4ae 100644
--- a/win/C#/Functions/Encode.cs
+++ b/win/C#/Functions/Encode.cs
@@ -45,35 +45,36 @@ namespace Handbrake.Functions
encoding = true;
// Set the process Priority
- switch (Properties.Settings.Default.processPriority)
- {
- case "Realtime":
- hbProc.PriorityClass = ProcessPriorityClass.RealTime;
- break;
- case "High":
- hbProc.PriorityClass = ProcessPriorityClass.High;
- break;
- case "Above Normal":
- hbProc.PriorityClass = ProcessPriorityClass.AboveNormal;
- break;
- case "Normal":
- hbProc.PriorityClass = ProcessPriorityClass.Normal;
- break;
- case "Low":
- hbProc.PriorityClass = ProcessPriorityClass.Idle;
- break;
- default:
- hbProc.PriorityClass = ProcessPriorityClass.BelowNormal;
- break;
- }
+ if (hbProc != null)
+ switch (Properties.Settings.Default.processPriority)
+ {
+ case "Realtime":
+ hbProc.PriorityClass = ProcessPriorityClass.RealTime;
+ break;
+ case "High":
+ hbProc.PriorityClass = ProcessPriorityClass.High;
+ break;
+ case "Above Normal":
+ hbProc.PriorityClass = ProcessPriorityClass.AboveNormal;
+ break;
+ case "Normal":
+ hbProc.PriorityClass = ProcessPriorityClass.Normal;
+ break;
+ case "Low":
+ hbProc.PriorityClass = ProcessPriorityClass.Idle;
+ break;
+ default:
+ hbProc.PriorityClass = ProcessPriorityClass.BelowNormal;
+ break;
+ }
}
catch (Exception exc)
{
- MessageBox.Show("An error occured in runCli()\n Error Information: \n\n" + exc.ToString());
+ MessageBox.Show("An error occured in runCli()\n Error Information: \n\n" + exc);
}
return hbProc;
}
-
+
/// <summary>
/// Perform an action after an encode. e.g a shutdown, standby, restart etc.
/// </summary>
@@ -149,7 +150,7 @@ namespace Handbrake.Functions
destinationFile += destName[i] + "\\";
}
- destinationFile += DateTime.Now.ToString().Replace("/", "-").Replace(":", "-") + " " + destName[destName.Length - 1] + ".txt";
+ destinationFile += DateTime.Now.ToString().Replace("/", "-").Replace(":", "-") + " " + destName[destName.Length - 1] + ".txt";
File.Copy(logPath, destinationFile);
}
diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs
index 59af6bf85..68306748a 100644
--- a/win/C#/Functions/Main.cs
+++ b/win/C#/Functions/Main.cs
@@ -18,7 +18,7 @@ namespace Handbrake.Functions
class Main
{
// Private Variables
- private static XmlSerializer ser = new XmlSerializer(typeof(List<Queue.QueueItem>));
+ private static readonly XmlSerializer ser = new XmlSerializer(typeof(List<Queue.QueueItem>));
/// <summary>
/// Calculate the duration of the selected title and chapters
@@ -256,7 +256,7 @@ namespace Handbrake.Functions
{
try
{
- Functions.AppcastReader rssRead = new AppcastReader();
+ AppcastReader rssRead = new AppcastReader();
rssRead.getInfo(); // Initializes the class.
string build = rssRead.build();
@@ -290,11 +290,13 @@ namespace Handbrake.Functions
// 0 = SVN Build / Version
// 1 = Build Date
Process cliProcess = new Process();
- ProcessStartInfo handBrakeCLI = new ProcessStartInfo("HandBrakeCLI.exe", " -u");
- handBrakeCLI.UseShellExecute = false;
- handBrakeCLI.RedirectStandardError = true;
- handBrakeCLI.RedirectStandardOutput = true;
- handBrakeCLI.CreateNoWindow = true;
+ ProcessStartInfo handBrakeCLI = new ProcessStartInfo("HandBrakeCLI.exe", " -u")
+ {
+ UseShellExecute = false,
+ RedirectStandardError = true,
+ RedirectStandardOutput = true,
+ CreateNoWindow = true
+ };
cliProcess.StartInfo = handBrakeCLI;
try
@@ -305,8 +307,7 @@ namespace Handbrake.Functions
while (!cliProcess.HasExited)
{
- line = stdOutput.ReadLine();
- if (line == null) line = "";
+ line = stdOutput.ReadLine() ?? "";
Match m = Regex.Match(line, @"HandBrake ([0-9\.]*)*(svn[0-9]*[M]*)* \([0-9]*\)");
if (m.Success)
@@ -331,13 +332,13 @@ namespace Handbrake.Functions
cliVersionData.Add("0");
return cliVersionData;
}
- private void killCLI()
+ private static void killCLI()
{
string AppName = "HandBrakeCLI";
AppName = AppName.ToUpper();
- System.Diagnostics.Process[] prs = Process.GetProcesses();
- foreach (System.Diagnostics.Process proces in prs)
+ Process[] prs = Process.GetProcesses();
+ foreach (Process proces in prs)
{
if (proces.ProcessName.ToUpper() == AppName)
{
@@ -363,8 +364,9 @@ namespace Handbrake.Functions
using (FileStream strm = new FileStream(tempPath, FileMode.Open, FileAccess.Read))
{
List<Queue.QueueItem> list = ser.Deserialize(strm) as List<Queue.QueueItem>;
- if (list.Count != 0)
- return true;
+ if (list != null)
+ if (list.Count != 0)
+ return true;
}
}
return false;
diff --git a/win/C#/Functions/QueryParser.cs b/win/C#/Functions/QueryParser.cs
index b3c8a70c3..eb6c06016 100644
--- a/win/C#/Functions/QueryParser.cs
+++ b/win/C#/Functions/QueryParser.cs
@@ -1042,12 +1042,7 @@ namespace Handbrake.Functions
if (subtitles.Success)
thisQuery.q_subtitles = subtitles.ToString().Replace("-s ", "");
else
- {
- if (subScan.Success)
- thisQuery.q_subtitles = "Autoselect";
- else
- thisQuery.q_subtitles = "None";
- }
+ thisQuery.q_subtitles = subScan.Success ? "Autoselect" : "None";
thisQuery.q_forcedSubs = forcedSubtitles.Success;
diff --git a/win/C#/Parsing/AudioTrack.cs b/win/C#/Parsing/AudioTrack.cs
index d2d6f3fac..86c2b6e05 100644
--- a/win/C#/Parsing/AudioTrack.cs
+++ b/win/C#/Parsing/AudioTrack.cs
@@ -79,8 +79,8 @@ namespace Handbrake.Parsing
{
if (m_subFormat == null)
return string.Format("{0} {1} ({2})", m_trackNumber, m_language, m_format);
- else
- return string.Format("{0} {1} ({2}) ({3})", m_trackNumber, m_language, m_format, m_subFormat);
+
+ return string.Format("{0} {1} ({2}) ({3})", m_trackNumber, m_language, m_format, m_subFormat);
}
public static AudioTrack Parse(StringReader output)
@@ -91,25 +91,30 @@ namespace Handbrake.Parsing
Match y = Regex.Match(audio_track, @"^ \+ ([0-9]*), ([A-Za-z0-9]*) \((.*)\)");
if (m.Success)
{
- var thisTrack = new AudioTrack();
- thisTrack.m_trackNumber = int.Parse(m.Groups[1].Value.Trim());
- thisTrack.m_language = m.Groups[2].Value;
- thisTrack.m_format = m.Groups[3].Value;
- thisTrack.m_subFormat = m.Groups[4].Value;
- thisTrack.m_frequency = int.Parse(m.Groups[5].Value.Trim());
- thisTrack.m_bitrate = int.Parse(m.Groups[6].Value.Trim());
+ var thisTrack = new AudioTrack
+ {
+ m_trackNumber = int.Parse(m.Groups[1].Value.Trim()),
+ m_language = m.Groups[2].Value,
+ m_format = m.Groups[3].Value,
+ m_subFormat = m.Groups[4].Value,
+ m_frequency = int.Parse(m.Groups[5].Value.Trim()),
+ m_bitrate = int.Parse(m.Groups[6].Value.Trim())
+ };
return thisTrack;
}
- else if (y.Success)
+
+ if (y.Success)
{
- var thisTrack = new AudioTrack();
- thisTrack.m_trackNumber = int.Parse(y.Groups[1].Value.Trim());
- thisTrack.m_language = y.Groups[2].Value;
- thisTrack.m_format = y.Groups[3].Value;
+ var thisTrack = new AudioTrack
+ {
+ m_trackNumber = int.Parse(y.Groups[1].Value.Trim()),
+ m_language = y.Groups[2].Value,
+ m_format = y.Groups[3].Value
+ };
return thisTrack;
}
- else
- return null;
+
+ return null;
}
public static AudioTrack[] ParseList(StringReader output)
diff --git a/win/C#/Parsing/Chapter.cs b/win/C#/Parsing/Chapter.cs
index 301fa5719..1bf38f4d8 100644
--- a/win/C#/Parsing/Chapter.cs
+++ b/win/C#/Parsing/Chapter.cs
@@ -51,13 +51,14 @@ namespace Handbrake.Parsing
@"^ \+ ([0-9]*): cells ([0-9]*)->([0-9]*), ([0-9]*) blocks, duration ([0-9]{2}:[0-9]{2}:[0-9]{2})");
if (m.Success)
{
- var thisChapter = new Chapter();
- thisChapter.m_chapterNumber = int.Parse(m.Groups[1].Value.Trim());
- thisChapter.m_duration = TimeSpan.Parse(m.Groups[5].Value);
+ var thisChapter = new Chapter
+ {
+ m_chapterNumber = int.Parse(m.Groups[1].Value.Trim()),
+ m_duration = TimeSpan.Parse(m.Groups[5].Value)
+ };
return thisChapter;
}
- else
- return null;
+ return null;
}
public static Chapter[] ParseList(StringReader output)
diff --git a/win/C#/Parsing/Parser.cs b/win/C#/Parsing/Parser.cs
index 24dcef40f..c15275030 100644
--- a/win/C#/Parsing/Parser.cs
+++ b/win/C#/Parsing/Parser.cs
@@ -37,7 +37,7 @@ namespace Handbrake.Parsing
{
get
{
- return this.m_buffer;
+ return m_buffer;
}
}
@@ -64,14 +64,14 @@ namespace Handbrake.Parsing
public Parser(Stream baseStream)
: base(baseStream)
{
- this.m_buffer = string.Empty;
+ m_buffer = string.Empty;
}
public override string ReadLine()
{
string tmp = base.ReadLine();
- this.m_buffer += tmp;
+ m_buffer += tmp;
Match m = Regex.Match(tmp, "^Scanning title ([0-9]*) of ([0-9]*)");
if (OnReadLine != null)
OnReadLine(this, tmp);
@@ -86,7 +86,7 @@ namespace Handbrake.Parsing
{
string tmp = base.ReadToEnd();
- this.m_buffer += tmp;
+ m_buffer += tmp;
if (OnReadToEnd != null)
OnReadToEnd(this, tmp);
diff --git a/win/C#/Parsing/Subtitle.cs b/win/C#/Parsing/Subtitle.cs
index 71e00121e..e3ff72af0 100644
--- a/win/C#/Parsing/Subtitle.cs
+++ b/win/C#/Parsing/Subtitle.cs
@@ -50,13 +50,14 @@ namespace Handbrake.Parsing
Match m = Regex.Match(curLine, @"^ \+ ([0-9]*), ([A-Za-z, ]*) \((.*)\)");
if (m.Success && !curLine.Contains("HandBrake has exited."))
{
- var thisSubtitle = new Subtitle();
- thisSubtitle.m_trackNumber = int.Parse(m.Groups[1].Value.Trim());
- thisSubtitle.m_language = m.Groups[2].Value;
+ var thisSubtitle = new Subtitle
+ {
+ m_trackNumber = int.Parse(m.Groups[1].Value.Trim()),
+ m_language = m.Groups[2].Value
+ };
return thisSubtitle;
}
- else
- return null;
+ return null;
}
public static Subtitle[] ParseList(StringReader output)
diff --git a/win/C#/Parsing/Title.cs b/win/C#/Parsing/Title.cs
index 74ccab752..80736064b 100644
--- a/win/C#/Parsing/Title.cs
+++ b/win/C#/Parsing/Title.cs
@@ -126,7 +126,7 @@ namespace Handbrake.Parsing
if (m.Success)
thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value.Trim());
- String testData = output.ReadLine();
+ output.ReadLine();
// Get duration for this title
@@ -146,7 +146,7 @@ namespace Handbrake.Parsing
// Get autocrop region for this title
m = Regex.Match(output.ReadLine(), @"^ \+ autocrop: ([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)");
if (m.Success)
- thisTitle.m_autoCrop = new int[4]
+ thisTitle.m_autoCrop = new int[]
{
int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value),
int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value)
diff --git a/win/C#/Presets/PresetsHandler.cs b/win/C#/Presets/PresetsHandler.cs
index aa52d0685..e29c4d227 100644
--- a/win/C#/Presets/PresetsHandler.cs
+++ b/win/C#/Presets/PresetsHandler.cs
@@ -12,7 +12,7 @@ namespace Handbrake.Presets
{
List<Preset> presets = new List<Preset>(); // Category+Level+Preset Name: Query
List<Preset> user_presets = new List<Preset>(); // Preset Name: Query
- private static XmlSerializer ser = new XmlSerializer(typeof(List<Preset>));
+ private static readonly XmlSerializer ser = new XmlSerializer(typeof(List<Preset>));
/// <summary>
/// Add a new preset to the system
@@ -24,19 +24,13 @@ namespace Handbrake.Presets
{
if (checkIfPresetExists(presetName) == false)
{
- Preset newPreset = new Preset();
- newPreset.Name = presetName;
- newPreset.Query = query;
- newPreset.PictureSettings = pictureSettings;
+ Preset newPreset = new Preset {Name = presetName, Query = query, PictureSettings = pictureSettings};
user_presets.Add(newPreset);
updateUserPresetsFile();
return true;
}
- else
- {
- MessageBox.Show("Sorry, that preset name already exists. Please choose another!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
+ MessageBox.Show("Sorry, that preset name already exists. Please choose another!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ return false;
}
/// <summary>
@@ -155,13 +149,16 @@ namespace Handbrake.Presets
string strCmdLine = String.Format(@"cmd /c """"{0}"" --preset-list >""{1}"" 2>&1""", handbrakeCLIPath, presetsPath);
- ProcessStartInfo hbGetPresets = new ProcessStartInfo("CMD.exe", strCmdLine);
- hbGetPresets.WindowStyle = ProcessWindowStyle.Hidden;
+ ProcessStartInfo hbGetPresets = new ProcessStartInfo("CMD.exe", strCmdLine)
+ {WindowStyle = ProcessWindowStyle.Hidden};
Process hbproc = Process.Start(hbGetPresets);
- hbproc.WaitForExit();
- hbproc.Dispose();
- hbproc.Close();
+ if (hbproc != null)
+ {
+ hbproc.WaitForExit();
+ hbproc.Dispose();
+ hbproc.Close();
+ }
// Clear the current built in presets and now parse the tempory presets file.
presets.Clear();
@@ -200,11 +197,13 @@ namespace Handbrake.Presets
Regex r = new Regex("(: )"); // Split on hyphens.
string[] presetName = r.Split(line);
- Preset newPreset = new Preset();
- newPreset.Level = level;
- newPreset.Category = category;
- newPreset.Name = presetName[0].Replace("+", "").Trim();
- newPreset.Query = presetName[2];
+ Preset newPreset = new Preset
+ {
+ Level = level,
+ Category = category,
+ Name = presetName[0].Replace("+", "").Trim(),
+ Query = presetName[2]
+ };
presets.Add(newPreset);
}
}
@@ -236,8 +235,9 @@ namespace Handbrake.Presets
{
List<Preset> list = ser.Deserialize(strm) as List<Preset>;
- foreach (Preset preset in list)
- presets.Add(preset);
+ if (list != null)
+ foreach (Preset preset in list)
+ presets.Add(preset);
}
}
}
@@ -252,8 +252,9 @@ namespace Handbrake.Presets
{
List<Preset> list = ser.Deserialize(strm) as List<Preset>;
- foreach (Preset preset in list)
- user_presets.Add(preset);
+ if (list != null)
+ foreach (Preset preset in list)
+ user_presets.Add(preset);
}
}
}
diff --git a/win/C#/Queue/QueueHandler.cs b/win/C#/Queue/QueueHandler.cs
index 478757e95..8008d17ea 100644
--- a/win/C#/Queue/QueueHandler.cs
+++ b/win/C#/Queue/QueueHandler.cs
@@ -204,8 +204,9 @@ namespace Handbrake.Queue
{
List<QueueItem> list = ser.Deserialize(strm) as List<QueueItem>;
- foreach (QueueItem item in list)
- queue.Add(item);
+ if (list != null)
+ foreach (QueueItem item in list)
+ queue.Add(item);
if (file != "hb_queue_recovery.xml")
write2disk("hb_queue_recovery.xml");
diff --git a/win/C#/frmMain/PresetLoader.cs b/win/C#/frmMain/PresetLoader.cs
index f10b7227d..0a2ad328a 100644
--- a/win/C#/frmMain/PresetLoader.cs
+++ b/win/C#/frmMain/PresetLoader.cs
@@ -61,15 +61,9 @@ namespace Handbrake
mainWindow.drop_format.SelectedIndex = 1;
}
- if (presetQuery.IpodAtom)
- mainWindow.check_iPodAtom.CheckState = CheckState.Checked;
- else
- mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked;
+ mainWindow.check_iPodAtom.CheckState = presetQuery.IpodAtom ? CheckState.Checked : CheckState.Unchecked;
- if (presetQuery.OptimizeMP4)
- mainWindow.check_optimiseMP4.CheckState = CheckState.Checked;
- else
- mainWindow.check_optimiseMP4.CheckState = CheckState.Unchecked;
+ mainWindow.check_optimiseMP4.CheckState = presetQuery.OptimizeMP4 ? CheckState.Checked : CheckState.Unchecked;
#endregion
@@ -107,10 +101,7 @@ namespace Handbrake
mainWindow.text_height.Text = presetQuery.Height.ToString();
}
- if (presetQuery.Anamorphic)
- mainWindow.drp_anamorphic.SelectedIndex = 1;
- else
- mainWindow.drp_anamorphic.SelectedIndex = 0;
+ mainWindow.drp_anamorphic.SelectedIndex = presetQuery.Anamorphic ? 1 : 0;
if (presetQuery.LooseAnamorphic)
mainWindow.drp_anamorphic.SelectedIndex = 2;
@@ -184,7 +175,7 @@ namespace Handbrake
int value;
System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
- double presetValue, calculated, x264step;
+ double presetValue, x264step;
double.TryParse(presetQuery.VideoQuality.ToString(),
System.Globalization.NumberStyles.Number,
culture,
@@ -196,7 +187,7 @@ namespace Handbrake
double x = 51 / x264step;
- calculated = presetValue / x264step;
+ double calculated = presetValue / x264step;
calculated = x - calculated;
int.TryParse(calculated.ToString(), out value);
@@ -219,22 +210,13 @@ namespace Handbrake
}
}
- if (presetQuery.TwoPass)
- mainWindow.check_2PassEncode.CheckState = CheckState.Checked;
- else
- mainWindow.check_2PassEncode.CheckState = CheckState.Unchecked;
+ mainWindow.check_2PassEncode.CheckState = presetQuery.TwoPass ? CheckState.Checked : CheckState.Unchecked;
- if (presetQuery.Grayscale)
- mainWindow.check_grayscale.CheckState = CheckState.Checked;
- else
- mainWindow.check_grayscale.CheckState = CheckState.Unchecked;
+ mainWindow.check_grayscale.CheckState = presetQuery.Grayscale ? CheckState.Checked : CheckState.Unchecked;
mainWindow.drp_videoFramerate.Text = presetQuery.VideoFramerate;
- if (presetQuery.TurboFirstPass)
- mainWindow.check_turbo.CheckState = CheckState.Checked;
- else
- mainWindow.check_turbo.CheckState = CheckState.Unchecked;
+ mainWindow.check_turbo.CheckState = presetQuery.TurboFirstPass ? CheckState.Checked : CheckState.Unchecked;
if (presetQuery.LargeMP4)
mainWindow.check_largeFile.CheckState = CheckState.Checked;
diff --git a/win/C#/frmMain/QueryGenerator.cs b/win/C#/frmMain/QueryGenerator.cs
index 6c01286dd..586c7a88a 100644
--- a/win/C#/frmMain/QueryGenerator.cs
+++ b/win/C#/frmMain/QueryGenerator.cs
@@ -219,7 +219,7 @@ namespace Handbrake
break;
case "H.264 (x264)":
double divided;
- System.Globalization.CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
+ CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
double.TryParse(Properties.Settings.Default.x264cqstep,
NumberStyles.Number,
culture,
@@ -410,11 +410,9 @@ namespace Handbrake
{
if (dest_name.Trim() != String.Empty)
{
- string path;
- if (source_title != "Automatic")
- path = Path.Combine(Path.GetTempPath(), dest_name + "-" + source_title + "-chapters.csv");
- else
- path = Path.Combine(Path.GetTempPath(), dest_name + "-chapters.csv");
+ string path = source_title != "Automatic"
+ ? Path.Combine(Path.GetTempPath(), dest_name + "-" + source_title + "-chapters.csv")
+ : Path.Combine(Path.GetTempPath(), dest_name + "-chapters.csv");
if (chapterCSVSave(mainWindow, path) == false)
query += " -m ";
@@ -448,7 +446,7 @@ namespace Handbrake
/// <param name="selectedAudio"></param>
/// <returns></returns>
///
- private string getMixDown(string selectedAudio)
+ private static string getMixDown(string selectedAudio)
{
switch (selectedAudio)
{
@@ -475,7 +473,7 @@ namespace Handbrake
/// <param name="selectedEncoder"></param>
/// <returns></returns>
///
- private string getAudioEncoder(string selectedEncoder)
+ private static string getAudioEncoder(string selectedEncoder)
{
switch (selectedEncoder)
{
@@ -499,7 +497,7 @@ namespace Handbrake
/// <param name="mainWindow"></param>
/// <param name="file_path_name"></param>
/// <returns></returns>
- private Boolean chapterCSVSave(frmMain mainWindow, string file_path_name)
+ private static Boolean chapterCSVSave(frmMain mainWindow, string file_path_name)
{
try
{