diff options
author | sr55 <[email protected]> | 2009-01-23 21:08:28 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2009-01-23 21:08:28 +0000 |
commit | e98a23579ed5e4ca68d9c82af3ac50dfd833e86e (patch) | |
tree | d016ac9c57c3190a4f1881e3f747600b6d93bfc2 | |
parent | 041ee4d8203087656775caecb5a312f246bdc2ae (diff) |
WinGui:
- Few more bits of code refactored.
- Added a 10 second limit for the CLI to respond at GUI startup. This will prevent the app from locking if the CLI stalls.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2093 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | win/C#/Functions/Encode.cs | 1 | ||||
-rw-r--r-- | win/C#/Functions/Main.cs | 23 | ||||
-rw-r--r-- | win/C#/frmMain.cs | 3 | ||||
-rw-r--r-- | win/C#/frmMain/PresetLoader.cs | 31 | ||||
-rw-r--r-- | win/C#/frmMain/QueryGenerator.cs | 19 | ||||
-rw-r--r-- | win/C#/frmMain/x264Panel.cs | 36 |
6 files changed, 62 insertions, 51 deletions
diff --git a/win/C#/Functions/Encode.cs b/win/C#/Functions/Encode.cs index b6a4a0a43..3f126d7e5 100644 --- a/win/C#/Functions/Encode.cs +++ b/win/C#/Functions/Encode.cs @@ -136,6 +136,7 @@ namespace Handbrake.Functions /// if this feature is enabled in options.
/// </summary>
/// <param name="query"></param>
+ /// <param name="destination"></param>
public void copyLog(string query, string destination)
{
// The user may wish to do something with the log.
diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs index 05bb00f56..af0ce7f72 100644 --- a/win/C#/Functions/Main.cs +++ b/win/C#/Functions/Main.cs @@ -173,7 +173,7 @@ namespace Handbrake.Functions data_chpt.Rows[n].Cells[1].ValueType = typeof(string);
i++;
}
-
+
return data_chpt;
}
@@ -324,7 +324,7 @@ namespace Handbrake.Functions if (line == null) line = "";
Match m = Regex.Match(line, @"HandBrake ([0-9\.]*)*(svn[0-9]*[M]*)* \([0-9]*\)");
- if (m.Success != false)
+ if (m.Success)
{
string data = line.Replace("(", "").Replace(")", "").Replace("HandBrake ", "");
string[] arr = data.Split(' ');
@@ -332,6 +332,9 @@ namespace Handbrake.Functions cliVersionData.Add(arr[1]);
return cliVersionData;
}
+ if (cliProcess.TotalProcessorTime.Seconds > 10) // Don't wait longer than 10 seconds.
+ killCLI();
+
}
}
catch (Exception e)
@@ -343,6 +346,22 @@ namespace Handbrake.Functions cliVersionData.Add("0");
return cliVersionData;
}
+ private void killCLI()
+ {
+ string AppName = "HandBrakeCLI";
+ AppName = AppName.ToUpper();
+
+ System.Diagnostics.Process[] prs = Process.GetProcesses();
+ foreach (System.Diagnostics.Process proces in prs)
+ {
+ if (proces.ProcessName.ToUpper() == AppName)
+ {
+ proces.Refresh();
+ if (!proces.HasExited)
+ proces.Kill();
+ }
+ }
+ }
/// <summary>
/// Check if the queue recovery file contains records.
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index e3537408c..3c9754ce3 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -35,7 +35,7 @@ namespace Handbrake private frmQueue queueWindow;
private frmGenPreview vlcpreview;
private frmPreview qtpreview;
- private string lastAction = null;
+ private string lastAction;
public int maxWidth = 0;
public int maxHeight = 0;
@@ -1557,7 +1557,6 @@ namespace Handbrake tb_preview.Enabled = false;
mnu_killCLI.Visible = true;
}
-
private void startScan(String filename)
{
try
diff --git a/win/C#/frmMain/PresetLoader.cs b/win/C#/frmMain/PresetLoader.cs index ab4561c71..c486247f0 100644 --- a/win/C#/frmMain/PresetLoader.cs +++ b/win/C#/frmMain/PresetLoader.cs @@ -13,6 +13,7 @@ namespace Handbrake /// <param name="mainWindow"></param>
/// <param name="presetQuery">The Parsed CLI Query</param>
/// <param name="name">Name of the preset</param>
+ /// <param name="pictureSettings">Save picture settings in the preset</param>
public void presetLoader(frmMain mainWindow, Functions.QueryParser presetQuery, string name, Boolean pictureSettings)
{
// ---------------------------
@@ -56,16 +57,16 @@ namespace Handbrake else if (presetQuery.Format == "ogm")
mainWindow.drop_format.SelectedIndex = 4;
- if (presetQuery.ChapterMarkers == true && presetQuery.Format == "mp4")
+ if (presetQuery.ChapterMarkers && presetQuery.Format == "mp4")
mainWindow.drop_format.SelectedIndex = 1;
}
- if (presetQuery.IpodAtom == true)
+ if (presetQuery.IpodAtom)
mainWindow.check_iPodAtom.CheckState = CheckState.Checked;
else
mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked;
- if (presetQuery.OptimizeMP4 == true)
+ if (presetQuery.OptimizeMP4)
mainWindow.check_optimiseMP4.CheckState = CheckState.Checked;
else
mainWindow.check_optimiseMP4.CheckState = CheckState.Unchecked;
@@ -82,7 +83,7 @@ namespace Handbrake mainWindow.text_width.Text = "";
mainWindow.text_height.Text = "";
- if (pictureSettings == true)
+ if (pictureSettings)
{
if (presetQuery.CropTop != null)
{
@@ -109,12 +110,12 @@ namespace Handbrake mainWindow.drp_deInterlace_option.Text = presetQuery.DeInterlace;
mainWindow.drp_deNoise.Text = presetQuery.DeNoise;
- if (presetQuery.Decomb == true)
+ if (presetQuery.Decomb)
mainWindow.check_decomb.CheckState = CheckState.Checked;
else
mainWindow.check_decomb.CheckState = CheckState.Unchecked;
- if (presetQuery.DeTelecine == true)
+ if (presetQuery.DeTelecine)
mainWindow.check_detelecine.CheckState = CheckState.Checked;
else
mainWindow.check_detelecine.CheckState = CheckState.Unchecked;
@@ -130,12 +131,12 @@ namespace Handbrake mainWindow.lbl_deblockVal.Text = "Off";
}
- if (presetQuery.Anamorphic == true)
+ if (presetQuery.Anamorphic)
mainWindow.drp_anamorphic.SelectedIndex = 1;
else
mainWindow.drp_anamorphic.SelectedIndex = 0;
- if (presetQuery.LooseAnamorphic == true)
+ if (presetQuery.LooseAnamorphic)
mainWindow.drp_anamorphic.SelectedIndex = 2;
else
{
@@ -168,27 +169,27 @@ namespace Handbrake if (mainWindow.slider_videoQuality.Value != 0)
{
int ql = presetQuery.VideoQuality;
- mainWindow.SliderValue.Text = ql.ToString() + "%";
+ mainWindow.SliderValue.Text = ql + "%";
}
- if (presetQuery.TwoPass == true)
+ if (presetQuery.TwoPass)
mainWindow.check_2PassEncode.CheckState = CheckState.Checked;
else
mainWindow.check_2PassEncode.CheckState = CheckState.Unchecked;
- if (presetQuery.Grayscale == true)
+ if (presetQuery.Grayscale)
mainWindow.check_grayscale.CheckState = CheckState.Checked;
else
mainWindow.check_grayscale.CheckState = CheckState.Unchecked;
mainWindow.drp_videoFramerate.Text = presetQuery.VideoFramerate;
- if (presetQuery.TurboFirstPass == true)
+ if (presetQuery.TurboFirstPass)
mainWindow.check_turbo.CheckState = CheckState.Checked;
else
mainWindow.check_turbo.CheckState = CheckState.Unchecked;
- if (presetQuery.LargeMP4 == true)
+ if (presetQuery.LargeMP4)
mainWindow.check_largeFile.CheckState = CheckState.Checked;
else
{
@@ -200,7 +201,7 @@ namespace Handbrake // Chapter Markers Tab
#region Chapter Markers
- if (presetQuery.ChapterMarkers == true)
+ if (presetQuery.ChapterMarkers)
{
mainWindow.Check_ChapterMarkers.CheckState = CheckState.Checked;
mainWindow.Check_ChapterMarkers.Enabled = true;
@@ -264,7 +265,7 @@ namespace Handbrake // Subtitle Stuff
mainWindow.drp_subtitle.Text = presetQuery.Subtitles;
- if (presetQuery.ForcedSubtitles == true)
+ if (presetQuery.ForcedSubtitles)
{
mainWindow.check_forced.CheckState = CheckState.Checked;
mainWindow.check_forced.Enabled = true;
diff --git a/win/C#/frmMain/QueryGenerator.cs b/win/C#/frmMain/QueryGenerator.cs index 346657c4d..811783621 100644 --- a/win/C#/frmMain/QueryGenerator.cs +++ b/win/C#/frmMain/QueryGenerator.cs @@ -48,10 +48,12 @@ namespace Handbrake /// This basically forces a shortened version of the encdode.
/// </summary>
/// <param name="mainWindow"></param>
+ /// <param name="duration">Duration</param>
+ /// <param name="preview">Start at preview</param>
/// <returns>Returns a CLI query String.</returns>
public string GeneratePreviewQuery(frmMain mainWindow, string duration, string preview)
{
- int seconds = 0;
+ int seconds;
int.TryParse(duration, out seconds);
// Source tab
@@ -81,7 +83,6 @@ namespace Handbrake /// Generates part of the CLI query, for the tabbed components only.
/// </summary>
/// <param name="mainWindow"></param>
- /// <param name="source"></param>
/// <returns></returns>
public string generateTabbedComponentsQuery(frmMain mainWindow)
{
@@ -315,7 +316,7 @@ namespace Handbrake foreach (String item in tracks)
{
- if (firstLoop == true)
+ if (firstLoop)
{
audioItems = item; firstLoop = false;
}
@@ -329,7 +330,7 @@ namespace Handbrake // Audio Codec (-E)
foreach (String item in codecs)
{
- if (firstLoop == true)
+ if (firstLoop)
{
audioItems = item; firstLoop = false;
}
@@ -342,7 +343,7 @@ namespace Handbrake // Audio Mixdown (-6)
foreach (String item in mixdowns)
{
- if (firstLoop == true)
+ if (firstLoop)
{
audioItems = item; firstLoop = false;
}
@@ -355,7 +356,7 @@ namespace Handbrake // Sample Rate (-R)
foreach (String item in samplerates)
{
- if (firstLoop == true)
+ if (firstLoop)
{
audioItems = item; firstLoop = false;
}
@@ -368,7 +369,7 @@ namespace Handbrake // Audio Bitrate (-B)
foreach (String item in bitrates)
{
- if (firstLoop == true)
+ if (firstLoop)
{
audioItems = item; firstLoop = false;
}
@@ -381,7 +382,7 @@ namespace Handbrake // DRC (-D)
foreach (String item in drcs)
{
- if (firstLoop == true)
+ if (firstLoop)
{
audioItems = item; firstLoop = false;
}
@@ -389,8 +390,6 @@ namespace Handbrake audioItems += "," + item;
}
query += " -D " + audioItems;
- firstLoop = true; audioItems = ""; // Reset for another pass.
-
// Subtitles
string subtitles = mainWindow.drp_subtitle.Text;
diff --git a/win/C#/frmMain/x264Panel.cs b/win/C#/frmMain/x264Panel.cs index e3a52fd65..550c11661 100644 --- a/win/C#/frmMain/x264Panel.cs +++ b/win/C#/frmMain/x264Panel.cs @@ -1,6 +1,4 @@ using System;
-using System.Collections.Generic;
-using System.Text;
using System.Windows.Forms;
namespace Handbrake
@@ -41,8 +39,8 @@ namespace Handbrake {
/* 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 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.
@@ -146,12 +144,9 @@ namespace Handbrake /*Deblocking NSPopUpButtons*/
else if (optName.Equals("deblock"))
{
- string alphaDeblock = "";
- string betaDeblock = "";
-
string[] splitDeblock = optValue.Split(',');
- alphaDeblock = splitDeblock[0];
- betaDeblock = splitDeblock[1];
+ string alphaDeblock = splitDeblock[0];
+ string betaDeblock = splitDeblock[1];
if (alphaDeblock.Equals("0") && betaDeblock.Replace("\n", "").Equals("0"))
{
@@ -201,8 +196,8 @@ namespace Handbrake {
/* 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 optName; // The option name such as "bframes"
+ String optValue;// The option value such as "3"
String changedOptString = "";
String[] currentOptsArray;
@@ -345,8 +340,7 @@ namespace Handbrake private void hasOptions(string currentOptString, string optNameToChange, frmMain mainWindow)
{
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 optName; // The option name such as "bframes"
String[] currentOptsArray;
/* Create new empty opt string*/
@@ -365,7 +359,6 @@ namespace Handbrake string[] splitOptRange = thisOpt.Split('=');
optName = splitOptRange[0]; // e.g bframes
- optValue = splitOptRange[1]; // e.g 2
/*
* Run through the available widgets for x264 opts and set them, as you add widgets,
@@ -519,14 +512,14 @@ namespace Handbrake else if (optNameToChange.Equals("merange"))
{
if (!mainWindow.drop_MotionEstimationRange.SelectedItem.ToString().Contains("Default"))
- thisOpt = "merange=" + mainWindow.drop_MotionEstimationRange.SelectedItem.ToString();
+ thisOpt = "merange=" + mainWindow.drop_MotionEstimationRange.SelectedItem;
else
thisOpt = "";
}
else if (optNameToChange.Equals("ref"))
{
if (!mainWindow.drop_refFrames.SelectedItem.ToString().Contains("Default"))
- thisOpt = "ref=" + mainWindow.drop_refFrames.SelectedItem.ToString();
+ thisOpt = "ref=" + mainWindow.drop_refFrames.SelectedItem;
else
thisOpt = "";
}
@@ -572,12 +565,11 @@ namespace Handbrake }
private void hasNoOptions(string optNameToChange, frmMain mainWindow)
{
- string query = "";
string colon = "";
if (mainWindow.rtf_x264Query.Text != "")
colon = ":";
- query = mainWindow.rtf_x264Query.Text;
+ string query = mainWindow.rtf_x264Query.Text;
if (optNameToChange.Equals("me"))
{
switch (mainWindow.drop_MotionEstimationMethod.SelectedIndex)
@@ -645,12 +637,12 @@ namespace Handbrake else if (optNameToChange.Equals("merange"))
{
int value = mainWindow.drop_MotionEstimationRange.SelectedIndex + 3;
- query = query + colon + "merange=" + value.ToString();
+ query = query + colon + "merange=" + value;
}
else if (optNameToChange.Equals("deblock"))
{
String da = mainWindow.drop_deblockAlpha.SelectedItem.ToString();
- String db = mainWindow.drop_deblockBeta.Text.ToString();
+ String db = mainWindow.drop_deblockBeta.Text;
if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
{
@@ -706,7 +698,7 @@ namespace Handbrake else if (optNameToChange.Equals("ref"))
{
if (!mainWindow.drop_refFrames.SelectedItem.ToString().Contains("Default"))
- query = query + colon + "ref=" + mainWindow.drop_refFrames.SelectedItem.ToString();
+ query = query + colon + "ref=" + mainWindow.drop_refFrames.SelectedItem;
}
else if (optNameToChange.Equals("bframes"))
{
@@ -723,7 +715,7 @@ namespace Handbrake else if (optNameToChange.Equals("trellis"))
{
if (!mainWindow.drop_trellis.SelectedItem.ToString().Contains("Default"))
- query = query + colon + "trellis=" + mainWindow.drop_trellis.SelectedItem.ToString();
+ query = query + colon + "trellis=" + mainWindow.drop_trellis.SelectedItem;
}
mainWindow.rtf_x264Query.Text = query;
|