From e98a23579ed5e4ca68d9c82af3ac50dfd833e86e Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 23 Jan 2009 21:08:28 +0000 Subject: 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 --- win/C#/frmMain/PresetLoader.cs | 31 ++++++++++++++++--------------- win/C#/frmMain/QueryGenerator.cs | 19 +++++++++---------- win/C#/frmMain/x264Panel.cs | 36 ++++++++++++++---------------------- 3 files changed, 39 insertions(+), 47 deletions(-) (limited to 'win/C#/frmMain') 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 /// /// The Parsed CLI Query /// Name of the preset + /// Save picture settings in the preset 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. /// /// + /// Duration + /// Start at preview /// Returns a CLI query String. 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. /// /// - /// /// 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; -- cgit v1.2.3