/// if this feature is enabled in options.\r
/// </summary>\r
/// <param name="query"></param>\r
+ /// <param name="destination"></param>\r
public void copyLog(string query, string destination)\r
{\r
// The user may wish to do something with the log.\r
data_chpt.Rows[n].Cells[1].ValueType = typeof(string);\r
i++;\r
}\r
- \r
+\r
return data_chpt;\r
}\r
\r
if (line == null) line = "";\r
Match m = Regex.Match(line, @"HandBrake ([0-9\.]*)*(svn[0-9]*[M]*)* \([0-9]*\)");\r
\r
- if (m.Success != false)\r
+ if (m.Success)\r
{\r
string data = line.Replace("(", "").Replace(")", "").Replace("HandBrake ", "");\r
string[] arr = data.Split(' ');\r
cliVersionData.Add(arr[1]);\r
return cliVersionData;\r
}\r
+ if (cliProcess.TotalProcessorTime.Seconds > 10) // Don't wait longer than 10 seconds.\r
+ killCLI();\r
+\r
}\r
}\r
catch (Exception e)\r
cliVersionData.Add("0");\r
return cliVersionData;\r
}\r
+ private void killCLI()\r
+ {\r
+ string AppName = "HandBrakeCLI";\r
+ AppName = AppName.ToUpper();\r
+\r
+ System.Diagnostics.Process[] prs = Process.GetProcesses();\r
+ foreach (System.Diagnostics.Process proces in prs)\r
+ {\r
+ if (proces.ProcessName.ToUpper() == AppName)\r
+ {\r
+ proces.Refresh();\r
+ if (!proces.HasExited)\r
+ proces.Kill();\r
+ }\r
+ }\r
+ }\r
\r
/// <summary>\r
/// Check if the queue recovery file contains records.\r
private frmQueue queueWindow;\r
private frmGenPreview vlcpreview;\r
private frmPreview qtpreview;\r
- private string lastAction = null;\r
+ private string lastAction;\r
public int maxWidth = 0;\r
public int maxHeight = 0;\r
\r
tb_preview.Enabled = false;\r
mnu_killCLI.Visible = true;\r
}\r
-\r
private void startScan(String filename)\r
{\r
try\r
/// <param name="mainWindow"></param>\r
/// <param name="presetQuery">The Parsed CLI Query</param>\r
/// <param name="name">Name of the preset</param>\r
+ /// <param name="pictureSettings">Save picture settings in the preset</param>\r
public void presetLoader(frmMain mainWindow, Functions.QueryParser presetQuery, string name, Boolean pictureSettings)\r
{\r
// ---------------------------\r
else if (presetQuery.Format == "ogm")\r
mainWindow.drop_format.SelectedIndex = 4;\r
\r
- if (presetQuery.ChapterMarkers == true && presetQuery.Format == "mp4")\r
+ if (presetQuery.ChapterMarkers && presetQuery.Format == "mp4")\r
mainWindow.drop_format.SelectedIndex = 1;\r
}\r
\r
- if (presetQuery.IpodAtom == true)\r
+ if (presetQuery.IpodAtom)\r
mainWindow.check_iPodAtom.CheckState = CheckState.Checked;\r
else\r
mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked;\r
\r
- if (presetQuery.OptimizeMP4 == true)\r
+ if (presetQuery.OptimizeMP4)\r
mainWindow.check_optimiseMP4.CheckState = CheckState.Checked;\r
else\r
mainWindow.check_optimiseMP4.CheckState = CheckState.Unchecked;\r
mainWindow.text_width.Text = "";\r
mainWindow.text_height.Text = "";\r
\r
- if (pictureSettings == true)\r
+ if (pictureSettings)\r
{\r
if (presetQuery.CropTop != null)\r
{\r
mainWindow.drp_deInterlace_option.Text = presetQuery.DeInterlace;\r
mainWindow.drp_deNoise.Text = presetQuery.DeNoise;\r
\r
- if (presetQuery.Decomb == true)\r
+ if (presetQuery.Decomb)\r
mainWindow.check_decomb.CheckState = CheckState.Checked;\r
else\r
mainWindow.check_decomb.CheckState = CheckState.Unchecked;\r
\r
- if (presetQuery.DeTelecine == true)\r
+ if (presetQuery.DeTelecine)\r
mainWindow.check_detelecine.CheckState = CheckState.Checked;\r
else\r
mainWindow.check_detelecine.CheckState = CheckState.Unchecked;\r
mainWindow.lbl_deblockVal.Text = "Off";\r
}\r
\r
- if (presetQuery.Anamorphic == true)\r
+ if (presetQuery.Anamorphic)\r
mainWindow.drp_anamorphic.SelectedIndex = 1;\r
else\r
mainWindow.drp_anamorphic.SelectedIndex = 0;\r
\r
- if (presetQuery.LooseAnamorphic == true)\r
+ if (presetQuery.LooseAnamorphic)\r
mainWindow.drp_anamorphic.SelectedIndex = 2;\r
else\r
{\r
if (mainWindow.slider_videoQuality.Value != 0)\r
{\r
int ql = presetQuery.VideoQuality;\r
- mainWindow.SliderValue.Text = ql.ToString() + "%";\r
+ mainWindow.SliderValue.Text = ql + "%";\r
}\r
\r
- if (presetQuery.TwoPass == true)\r
+ if (presetQuery.TwoPass)\r
mainWindow.check_2PassEncode.CheckState = CheckState.Checked;\r
else\r
mainWindow.check_2PassEncode.CheckState = CheckState.Unchecked;\r
\r
- if (presetQuery.Grayscale == true)\r
+ if (presetQuery.Grayscale)\r
mainWindow.check_grayscale.CheckState = CheckState.Checked;\r
else\r
mainWindow.check_grayscale.CheckState = CheckState.Unchecked;\r
\r
mainWindow.drp_videoFramerate.Text = presetQuery.VideoFramerate;\r
\r
- if (presetQuery.TurboFirstPass == true)\r
+ if (presetQuery.TurboFirstPass)\r
mainWindow.check_turbo.CheckState = CheckState.Checked;\r
else\r
mainWindow.check_turbo.CheckState = CheckState.Unchecked;\r
\r
- if (presetQuery.LargeMP4 == true)\r
+ if (presetQuery.LargeMP4)\r
mainWindow.check_largeFile.CheckState = CheckState.Checked;\r
else\r
{\r
// Chapter Markers Tab\r
#region Chapter Markers\r
\r
- if (presetQuery.ChapterMarkers == true)\r
+ if (presetQuery.ChapterMarkers)\r
{\r
mainWindow.Check_ChapterMarkers.CheckState = CheckState.Checked;\r
mainWindow.Check_ChapterMarkers.Enabled = true;\r
// Subtitle Stuff\r
mainWindow.drp_subtitle.Text = presetQuery.Subtitles;\r
\r
- if (presetQuery.ForcedSubtitles == true)\r
+ if (presetQuery.ForcedSubtitles)\r
{\r
mainWindow.check_forced.CheckState = CheckState.Checked;\r
mainWindow.check_forced.Enabled = true;\r
/// This basically forces a shortened version of the encdode.\r
/// </summary>\r
/// <param name="mainWindow"></param>\r
+ /// <param name="duration">Duration</param>\r
+ /// <param name="preview">Start at preview</param>\r
/// <returns>Returns a CLI query String.</returns>\r
public string GeneratePreviewQuery(frmMain mainWindow, string duration, string preview)\r
{\r
- int seconds = 0;\r
+ int seconds;\r
int.TryParse(duration, out seconds);\r
\r
// Source tab\r
/// Generates part of the CLI query, for the tabbed components only.\r
/// </summary>\r
/// <param name="mainWindow"></param>\r
- /// <param name="source"></param>\r
/// <returns></returns>\r
public string generateTabbedComponentsQuery(frmMain mainWindow)\r
{\r
\r
foreach (String item in tracks)\r
{\r
- if (firstLoop == true)\r
+ if (firstLoop)\r
{\r
audioItems = item; firstLoop = false;\r
}\r
// Audio Codec (-E)\r
foreach (String item in codecs)\r
{\r
- if (firstLoop == true)\r
+ if (firstLoop)\r
{\r
audioItems = item; firstLoop = false;\r
}\r
// Audio Mixdown (-6)\r
foreach (String item in mixdowns)\r
{\r
- if (firstLoop == true)\r
+ if (firstLoop)\r
{\r
audioItems = item; firstLoop = false;\r
}\r
// Sample Rate (-R)\r
foreach (String item in samplerates)\r
{\r
- if (firstLoop == true)\r
+ if (firstLoop)\r
{\r
audioItems = item; firstLoop = false;\r
}\r
// Audio Bitrate (-B)\r
foreach (String item in bitrates)\r
{\r
- if (firstLoop == true)\r
+ if (firstLoop)\r
{\r
audioItems = item; firstLoop = false;\r
}\r
// DRC (-D)\r
foreach (String item in drcs)\r
{\r
- if (firstLoop == true)\r
+ if (firstLoop)\r
{\r
audioItems = item; firstLoop = false;\r
}\r
audioItems += "," + item;\r
}\r
query += " -D " + audioItems;\r
- firstLoop = true; audioItems = ""; // Reset for another pass.\r
-\r
\r
// Subtitles\r
string subtitles = mainWindow.drp_subtitle.Text;\r
using System;\r
-using System.Collections.Generic;\r
-using System.Text;\r
using System.Windows.Forms;\r
\r
namespace Handbrake\r
{\r
/* Set widgets depending on the opt string in field */\r
String thisOpt; // The separated option such as "bframes=3"\r
- String optName = ""; // The option name such as "bframes"\r
- String optValue = "";// The option value such as "3"\r
+ String optName; // The option name such as "bframes"\r
+ String optValue;// The option value such as "3"\r
String[] currentOptsArray;\r
\r
//Set currentOptString to the contents of the text box.\r
/*Deblocking NSPopUpButtons*/\r
else if (optName.Equals("deblock"))\r
{\r
- string alphaDeblock = "";\r
- string betaDeblock = "";\r
-\r
string[] splitDeblock = optValue.Split(',');\r
- alphaDeblock = splitDeblock[0];\r
- betaDeblock = splitDeblock[1];\r
+ string alphaDeblock = splitDeblock[0];\r
+ string betaDeblock = splitDeblock[1];\r
\r
if (alphaDeblock.Equals("0") && betaDeblock.Replace("\n", "").Equals("0"))\r
{\r
{\r
/* Set widgets depending on the opt string in field */\r
String thisOpt; // The separated option such as "bframes=3"\r
- String optName = ""; // The option name such as "bframes"\r
- String optValue = "";// The option value such as "3"\r
+ String optName; // The option name such as "bframes"\r
+ String optValue;// The option value such as "3"\r
String changedOptString = "";\r
String[] currentOptsArray;\r
\r
private void hasOptions(string currentOptString, string optNameToChange, frmMain mainWindow)\r
{\r
String thisOpt; // The separated option such as "bframes=3"\r
- String optName = ""; // The option name such as "bframes"\r
- String optValue = ""; // The option value such as "3"\r
+ String optName; // The option name such as "bframes"\r
String[] currentOptsArray;\r
\r
/* Create new empty opt string*/\r
string[] splitOptRange = thisOpt.Split('=');\r
\r
optName = splitOptRange[0]; // e.g bframes\r
- optValue = splitOptRange[1]; // e.g 2\r
\r
/* \r
* Run through the available widgets for x264 opts and set them, as you add widgets,\r
else if (optNameToChange.Equals("merange"))\r
{\r
if (!mainWindow.drop_MotionEstimationRange.SelectedItem.ToString().Contains("Default"))\r
- thisOpt = "merange=" + mainWindow.drop_MotionEstimationRange.SelectedItem.ToString();\r
+ thisOpt = "merange=" + mainWindow.drop_MotionEstimationRange.SelectedItem;\r
else\r
thisOpt = "";\r
}\r
else if (optNameToChange.Equals("ref"))\r
{\r
if (!mainWindow.drop_refFrames.SelectedItem.ToString().Contains("Default"))\r
- thisOpt = "ref=" + mainWindow.drop_refFrames.SelectedItem.ToString();\r
+ thisOpt = "ref=" + mainWindow.drop_refFrames.SelectedItem;\r
else\r
thisOpt = "";\r
}\r
}\r
private void hasNoOptions(string optNameToChange, frmMain mainWindow)\r
{\r
- string query = "";\r
string colon = "";\r
if (mainWindow.rtf_x264Query.Text != "")\r
colon = ":";\r
\r
- query = mainWindow.rtf_x264Query.Text;\r
+ string query = mainWindow.rtf_x264Query.Text;\r
if (optNameToChange.Equals("me"))\r
{\r
switch (mainWindow.drop_MotionEstimationMethod.SelectedIndex)\r
else if (optNameToChange.Equals("merange"))\r
{\r
int value = mainWindow.drop_MotionEstimationRange.SelectedIndex + 3;\r
- query = query + colon + "merange=" + value.ToString();\r
+ query = query + colon + "merange=" + value;\r
}\r
else if (optNameToChange.Equals("deblock"))\r
{\r
String da = mainWindow.drop_deblockAlpha.SelectedItem.ToString();\r
- String db = mainWindow.drop_deblockBeta.Text.ToString();\r
+ String db = mainWindow.drop_deblockBeta.Text;\r
\r
if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))\r
{\r
else if (optNameToChange.Equals("ref"))\r
{\r
if (!mainWindow.drop_refFrames.SelectedItem.ToString().Contains("Default"))\r
- query = query + colon + "ref=" + mainWindow.drop_refFrames.SelectedItem.ToString();\r
+ query = query + colon + "ref=" + mainWindow.drop_refFrames.SelectedItem;\r
}\r
else if (optNameToChange.Equals("bframes"))\r
{\r
else if (optNameToChange.Equals("trellis"))\r
{\r
if (!mainWindow.drop_trellis.SelectedItem.ToString().Contains("Default"))\r
- query = query + colon + "trellis=" + mainWindow.drop_trellis.SelectedItem.ToString();\r
+ query = query + colon + "trellis=" + mainWindow.drop_trellis.SelectedItem;\r
}\r
\r
mainWindow.rtf_x264Query.Text = query;\r