]> granicus.if.org Git - handbrake/commitdiff
WinGui:
authorsr55 <sr55.hb@outlook.com>
Wed, 27 Aug 2008 23:45:44 +0000 (23:45 +0000)
committersr55 <sr55.hb@outlook.com>
Wed, 27 Aug 2008 23:45:44 +0000 (23:45 +0000)
- Code Refactoring and optimization to numerous files

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1655 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/Functions/Common.cs
win/C#/Functions/Presets.cs
win/C#/Functions/Queue.cs
win/C#/Functions/x264Panel.cs
win/C#/Parsing/DVD.cs
win/C#/Parsing/Parser.cs
win/C#/Parsing/Title.cs
win/C#/frmActivityWindow.cs
win/C#/frmDownload.cs
win/C#/frmMain.cs
win/C#/frmUpdater.cs

index 7ff2ec8060a2558ce6eb587eef1f73932ca01d50..02e7628ca00bdaa9fcb5f297c8b932cf9cac49c9 100644 (file)
@@ -235,7 +235,7 @@ namespace Handbrake.Functions
             #region Audio\r
 \r
             // Handle Track 1\r
-            if (presetQuery.AudioTrack1 == "")\r
+            if (presetQuery.AudioTrack1 == string.Empty)\r
                 mainWindow.drp_track1Audio.Text = "Automatic";\r
             else\r
                 mainWindow.drp_track1Audio.Text = presetQuery.AudioTrack1;\r
@@ -527,13 +527,13 @@ namespace Handbrake.Functions
                 query += " --crop 0:0:0:0 ";\r
             else if (mainWindow.drp_crop.Text == "Custom")\r
             {\r
-                if (mainWindow.text_top.Text == "")\r
+                if (mainWindow.text_top.Text == string.Empty)\r
                     cropTop = "0";\r
-                if (mainWindow.text_bottom.Text == "")\r
+                if (mainWindow.text_bottom.Text == string.Empty)\r
                     cropBottom = "0";\r
-                if (mainWindow.text_left.Text == "")\r
+                if (mainWindow.text_left.Text == string.Empty)\r
                     cropLeft = "0";\r
-                if (mainWindow.text_right.Text == "")\r
+                if (mainWindow.text_right.Text == string.Empty)\r
                     cropRight = "0";\r
 \r
                 query += " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;\r
@@ -728,7 +728,7 @@ namespace Handbrake.Functions
 \r
             if (aencoder2 != "")\r
             {\r
-                if (aencoder1 == "")\r
+                if (aencoder1 == string.Empty)\r
                     query += " -E faac," + getAudioEncoder(aencoder2);\r
                 else\r
                     query += "," + getAudioEncoder(aencoder2);\r
@@ -748,7 +748,7 @@ namespace Handbrake.Functions
 \r
             if (audioBitrate2 != "")\r
             {\r
-                if (audioBitrate1 == "")\r
+                if (audioBitrate1 == string.Empty)\r
                     query += " -B 160," + audioBitrate2;\r
                 else\r
                     query += "," + audioBitrate2;\r
@@ -767,7 +767,7 @@ namespace Handbrake.Functions
 \r
             if (audioSampleRate2 != "")\r
             {\r
-                if (audioSampleRate1 == "")\r
+                if (audioSampleRate1 == string.Empty)\r
                     query += " -R 0," + audioSampleRate2.Replace("Auto", "0");\r
                 else\r
                     query += "," + audioSampleRate2.Replace("Auto", "0");\r
@@ -779,7 +779,7 @@ namespace Handbrake.Functions
 \r
                 if ((track2 != "") && (track2 != "None"))\r
                 {\r
-                    if (audioSampleRate1 == "")\r
+                    if (audioSampleRate1 == string.Empty)\r
                         query += " -R 0,0";\r
                     else\r
                         query += ",0";\r
index 2e725c52ddbbcd494c55d90981356cf52571da26..0e176b12a6dc567844635a87489d6e9ff2eb80e9 100644 (file)
@@ -1,5 +1,5 @@
 using System;\r
-using System.Collections;\r
+using System.Collections.Generic;\r
 using System.Text;\r
 using System.Windows.Forms;\r
 using System.IO;\r
@@ -10,8 +10,8 @@ namespace Handbrake.Functions
 {\r
     public class Presets\r
     {\r
-        ArrayList presets = new ArrayList();\r
-        ArrayList user_presets = new ArrayList();\r
+        List<string> presets = new List<string>();\r
+        List<string> user_presets = new List<string>();\r
 \r
         /// <summary>\r
         /// Add a new preset to the system\r
@@ -40,8 +40,8 @@ namespace Handbrake.Functions
         /// <param name="name">String, the preset name</param>\r
         public void remove(string name)\r
         {\r
-            ArrayList newPresets = new ArrayList();\r
-            ArrayList newUserPresets = new ArrayList();\r
+            List<string> newPresets = new List<string>();\r
+            List<string> newUserPresets = new List<string>();\r
 \r
             // Built In Presets\r
             foreach (string item in presets)\r
@@ -91,9 +91,9 @@ namespace Handbrake.Functions
         /// Includes both built in and user presets.\r
         /// </summary>\r
         /// <returns>Arraylist of preset names</returns>\r
-        public ArrayList getPresetNames()\r
+        public List<string> getPresetNames()\r
         {\r
-            ArrayList names = new ArrayList();\r
+            List<string> names = new List<string>();\r
 \r
             // Built In Presets\r
             foreach (string item in presets)\r
@@ -219,7 +219,7 @@ namespace Handbrake.Functions
         // Check if a preset already exists in either the built in or user presets\r
         private Boolean checkIfPresetExists(string name)\r
         {\r
-            if (name == "")\r
+            if (name == string.Empty)\r
                 return true;\r
 \r
             // Built In Presets\r
index ad4ecaf448b4fa92e5f442f1293e575293c7fbaf..dc23453585fde13a3ec837a45d7e991a1d6e9467 100644 (file)
@@ -45,15 +45,8 @@ namespace Handbrake.Functions
         /// <returns>Bolean true if successful</returns>\r
         public Boolean remove(int index)\r
         {\r
-            try\r
-            {\r
-                queue.RemoveAt(index);\r
-                return true;\r
-            }\r
-            catch (Exception)\r
-            {\r
-                return false;\r
-            }\r
+            queue.RemoveAt(index);\r
+            return true;\r
         }\r
 \r
         /// <summary>\r
@@ -125,7 +118,7 @@ namespace Handbrake.Functions
             }\r
             catch (Exception)\r
             {\r
-               // Any Errors will be out of diskspace/permissions problems. Don't report them as they'll annoy the user.\r
+                // Any Errors will be out of diskspace/permissions problems. Don't report them as they'll annoy the user.\r
             }\r
         }\r
 \r
@@ -150,7 +143,7 @@ namespace Handbrake.Functions
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("HandBrake was unable to recover the queue. \nError Information:" + exc.ToString(),"Queue Recovery Error",MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                MessageBox.Show("HandBrake was unable to recover the queue. \nError Information:" + exc.ToString(), "Queue Recovery Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
         }\r
 \r
index 0101f0fcfd50b1474aad6525598c429d7c7c23fc..8a93a2121d6583c589cade18311095885118b869 100644 (file)
@@ -232,7 +232,7 @@ namespace Handbrake.Functions
                 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)\r
                 {\r
                     thisOpt = currentOptsArray[loopcounter];\r
-                    if (currentOptsArray[currentOptsArrayCount - 1] == "")\r
+                    if (currentOptsArray[currentOptsArrayCount - 1] == string.Empty)\r
                         break;\r
 \r
                     String[] splitOptRange = thisOpt.Split('=');\r
@@ -257,11 +257,11 @@ namespace Handbrake.Functions
                     }\r
 \r
                     /* Construct New String for opts here */\r
-                    if (thisOpt == "")\r
+                    if (thisOpt == string.Empty)\r
                         changedOptString = changedOptString + thisOpt;\r
                     else\r
                     {\r
-                        if (changedOptString == "")\r
+                        if (changedOptString == string.Empty)\r
                             changedOptString = thisOpt;\r
                         else\r
                             changedOptString = changedOptString + ":" + thisOpt;\r
index 1637c9154dd730b877b1c39a879d49bbb5981beb..d0802e4c9a0c17dc8f8ce4ba1a93f65403ef8e24 100644 (file)
@@ -11,7 +11,7 @@ using System.IO;
 \r
 namespace Handbrake.Parsing\r
 {\r
-    \r
+\r
     /// <summary>\r
     /// An object representing a scanned DVD\r
     /// </summary>\r
@@ -41,20 +41,15 @@ namespace Handbrake.Parsing
         public static DVD Parse(StreamReader output)\r
         {\r
             DVD thisDVD = new DVD();\r
-            try\r
-            {\r
-                while (!output.EndOfStream)\r
-                {\r
-                    if ((char)output.Peek() == '+')\r
-                        thisDVD.m_titles.AddRange(Title.ParseList(output.ReadToEnd()));\r
-                    else\r
-                       output.ReadLine();\r
-                }\r
-            }\r
-            catch (Exception exc)\r
+\r
+            while (!output.EndOfStream)\r
             {\r
-                MessageBox.Show("DVD.CS - Parse" + exc.ToString());\r
+                if ((char)output.Peek() == '+')\r
+                    thisDVD.m_titles.AddRange(Title.ParseList(output.ReadToEnd()));\r
+                else\r
+                    output.ReadLine();\r
             }\r
+\r
             return thisDVD;\r
         }\r
     }\r
index 86e8a5017d92278d8f5812714146f8700d8cabac..bbafc92957b18757a291beb92b20b8095f4fe0b4 100644 (file)
@@ -64,7 +64,8 @@ namespace Handbrake.Parsing
         /// Default constructor for this object\r
         /// </summary>\r
         /// <param name="baseStream">The stream to parse from</param>\r
-        public Parser(Stream baseStream) : base(baseStream)\r
+        public Parser(Stream baseStream)\r
+            : base(baseStream)\r
         {\r
             this.m_buffer = string.Empty;\r
         }\r
@@ -72,38 +73,26 @@ namespace Handbrake.Parsing
         public override string ReadLine()\r
         {\r
             string tmp = base.ReadLine();\r
-            try\r
-            {\r
-                \r
-                this.m_buffer += tmp;\r
-                Match m = Regex.Match(tmp, "^Scanning title ([0-9]*) of ([0-9]*)");\r
-                if (OnReadLine != null)\r
-                    OnReadLine(this, tmp);\r
-\r
-                if (m.Success && OnScanProgress != null)\r
-                    OnScanProgress(this, int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));\r
-            }\r
-            catch (Exception exc)\r
-            {\r
-                MessageBox.Show("Parser.cs - ReadLine " + exc.ToString());\r
-            }\r
+\r
+            this.m_buffer += tmp;\r
+            Match m = Regex.Match(tmp, "^Scanning title ([0-9]*) of ([0-9]*)");\r
+            if (OnReadLine != null)\r
+                OnReadLine(this, tmp);\r
+\r
+            if (m.Success && OnScanProgress != null)\r
+                OnScanProgress(this, int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));\r
+\r
             return tmp;\r
         }\r
 \r
         public override string ReadToEnd()\r
         {\r
             string tmp = base.ReadToEnd();\r
-            try\r
-            {\r
-                this.m_buffer += tmp;\r
-                if (OnReadToEnd != null)\r
-                    OnReadToEnd(this, tmp);\r
 \r
-            }\r
-            catch (Exception exc)\r
-            {\r
-                MessageBox.Show("Parser.cs - ReadToEnd " + exc.ToString());\r
-            }\r
+            this.m_buffer += tmp;\r
+            if (OnReadToEnd != null)\r
+                OnReadToEnd(this, tmp);\r
+\r
             return tmp;\r
         }\r
     }\r
index 5d21d89cb3e5f39a401e40c6c4a9603b9daae82f..14eacf165353609dfde0753b5dd81158137877f7 100644 (file)
@@ -142,44 +142,38 @@ namespace Handbrake.Parsing
         public static Title Parse(StringReader output)\r
         {\r
             Title thisTitle = new Title();\r
-            try\r
-            {\r
-                Match m = Regex.Match(output.ReadLine(), @"^\+ title ([0-9]*):");\r
-                // Match track number for this title\r
-                if (m.Success)\r
-                    thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value.Trim().ToString());\r
 \r
-                output.ReadLine();\r
+            Match m = Regex.Match(output.ReadLine(), @"^\+ title ([0-9]*):");\r
+            // Match track number for this title\r
+            if (m.Success)\r
+                thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value.Trim().ToString());\r
 \r
-                // Get duration for this title\r
+            output.ReadLine();\r
 \r
-                m = Regex.Match(output.ReadLine(), @"^  \+ duration: ([0-9]{2}:[0-9]{2}:[0-9]{2})");\r
-                if (m.Success)\r
-                    thisTitle.m_duration = TimeSpan.Parse(m.Groups[1].Value);\r
+            // Get duration for this title\r
 \r
-                // Get resolution, aspect ratio and FPS for this title\r
-                m = Regex.Match(output.ReadLine(), @"^  \+ size: ([0-9]*)x([0-9]*), aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps");\r
-                if (m.Success)\r
-                {\r
-                    thisTitle.m_resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));\r
-                    thisTitle.m_aspectRatio = float.Parse(m.Groups[3].Value, Functions.Encode.Culture);\r
-                }\r
+            m = Regex.Match(output.ReadLine(), @"^  \+ duration: ([0-9]{2}:[0-9]{2}:[0-9]{2})");\r
+            if (m.Success)\r
+                thisTitle.m_duration = TimeSpan.Parse(m.Groups[1].Value);\r
 \r
-                // Get autocrop region for this title\r
-                m = Regex.Match(output.ReadLine(), @"^  \+ autocrop: ([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)");\r
-                if (m.Success)\r
-                    thisTitle.m_autoCrop = new int[4] { int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value), int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value) };\r
+            // Get resolution, aspect ratio and FPS for this title\r
+            m = Regex.Match(output.ReadLine(), @"^  \+ size: ([0-9]*)x([0-9]*), aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps");\r
+            if (m.Success)\r
+            {\r
+                thisTitle.m_resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));\r
+                thisTitle.m_aspectRatio = float.Parse(m.Groups[3].Value, Functions.Encode.Culture);\r
+            }\r
 \r
-                thisTitle.m_chapters.AddRange(Chapter.ParseList(output));\r
+            // Get autocrop region for this title\r
+            m = Regex.Match(output.ReadLine(), @"^  \+ autocrop: ([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)");\r
+            if (m.Success)\r
+                thisTitle.m_autoCrop = new int[4] { int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value), int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value) };\r
 \r
-                thisTitle.m_audioTracks.AddRange(AudioTrack.ParseList(output));\r
+            thisTitle.m_chapters.AddRange(Chapter.ParseList(output));\r
 \r
-                thisTitle.m_subtitles.AddRange(Subtitle.ParseList(output));\r
-            }\r
-            catch (Exception exc)\r
-            {\r
-                MessageBox.Show("Title.cs - Parse " + exc.ToString());\r
-            }\r
+            thisTitle.m_audioTracks.AddRange(AudioTrack.ParseList(output));\r
+\r
+            thisTitle.m_subtitles.AddRange(Subtitle.ParseList(output));\r
 \r
             return thisTitle;\r
         }\r
@@ -187,18 +181,13 @@ namespace Handbrake.Parsing
         public static Title[] ParseList(string output)\r
         {\r
             List<Title> titles = new List<Title>();\r
-            try\r
-            {\r
-                StringReader sr = new StringReader(output);\r
-                while ((char)sr.Peek() == '+')\r
-                {\r
-                    titles.Add(Title.Parse(sr));\r
-                }\r
-            }\r
-            catch (Exception exc)\r
+\r
+            StringReader sr = new StringReader(output);\r
+            while ((char)sr.Peek() == '+')\r
             {\r
-                MessageBox.Show("Title.cs - ParseList " + exc.ToString());\r
+                titles.Add(Title.Parse(sr));\r
             }\r
+\r
             return titles.ToArray();\r
         }\r
     }\r
index fad0efcad4e61706cb5003dfef26cfcadce4cac3..f4f6b0442fb08c5a2ca1ea1e0f1c164aa1d34323 100644 (file)
@@ -6,6 +6,7 @@
 \r
 using System;\r
 using System.Collections;\r
+using System.Collections.Generic;\r
 using System.ComponentModel;\r
 using System.Data;\r
 using System.Drawing;\r
@@ -103,9 +104,10 @@ namespace Handbrake
         private void updateTextFromThread()\r
         {\r
             string text = "";\r
-            ArrayList data = readFile();\r
+            List<string> data = readFile();\r
+            int count = data.Count;\r
 \r
-            while (position < data.Count)\r
+            while (position < count)\r
             {\r
                 text = data[position].ToString();\r
                 if (data[position].ToString().Contains("has exited"))\r
@@ -132,11 +134,11 @@ namespace Handbrake
             }\r
         }\r
 \r
-        private ArrayList readFile()\r
+        private List<string> readFile()\r
         {\r
             // Ok, the task here is to, Get an arraylist of log data.\r
             // And update some global varibles which are pointers to the last displayed log line.\r
-            ArrayList logData = new ArrayList();\r
+            List<string> logData = new List<string>();\r
 \r
             try\r
             {\r
index b8b74d2757090eeea81992223d554aecb4d37be5..872ec87e7907d067af0b7ef1394e9c5a7ae7a0f6 100644 (file)
@@ -35,62 +35,53 @@ namespace Handbrake
         {\r
             InitializeComponent();\r
 \r
-            try\r
-            {\r
-                downloadThread = new Thread(Download);\r
-                downloadThread.Start();\r
-            }\r
-            catch (Exception exc)\r
-            {\r
-                MessageBox.Show("An error occured on the Download Thread \n" + exc.ToString(),"Error",MessageBoxButtons.OK, MessageBoxIcon.Error);\r
-            }\r
+            downloadThread = new Thread(Download);\r
+            downloadThread.Start();\r
         }\r
 \r
         private void Download()\r
         {\r
             Functions.AppcastReader rssRead = new Functions.AppcastReader();\r
-\r
             string tempPath = Path.Combine(Path.GetTempPath(), "handbrake-setup.exe");\r
+            string hbUpdate = rssRead.downloadFile();\r
+            WebClient wcDownload = new WebClient();\r
 \r
-            if (File.Exists(tempPath))\r
-                File.Delete(tempPath);\r
+            try\r
+            {\r
+                if (File.Exists(tempPath))\r
+                    File.Delete(tempPath);\r
 \r
-            string hbUpdate = rssRead.downloadFile();\r
+                webRequest = (HttpWebRequest)WebRequest.Create(hbUpdate);\r
+                webRequest.Credentials = CredentialCache.DefaultCredentials;\r
+                webResponse = (HttpWebResponse)webRequest.GetResponse();\r
+                Int64 fileSize = webResponse.ContentLength;\r
 \r
-            WebClient wcDownload = new WebClient();\r
-                try\r
-                {\r
-                    webRequest = (HttpWebRequest)WebRequest.Create(hbUpdate);\r
-                    webRequest.Credentials = CredentialCache.DefaultCredentials;\r
-                    webResponse = (HttpWebResponse)webRequest.GetResponse();\r
-                    Int64 fileSize = webResponse.ContentLength;\r
-\r
-                    responceStream = wcDownload.OpenRead(hbUpdate);\r
-                    loacalStream = new FileStream(tempPath, FileMode.Create, FileAccess.Write, FileShare.None);\r
-\r
-                    int bytesSize = 0;\r
-                    byte[] downBuffer = new byte[2048];\r
-\r
-                    long flength = 0;\r
-                    while ((bytesSize = responceStream.Read(downBuffer, 0, downBuffer.Length)) > 0)\r
-                    {\r
-                        loacalStream.Write(downBuffer, 0, bytesSize);\r
-                        flength = loacalStream.Length;\r
-                        this.Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { loacalStream.Length, fileSize });\r
-                    }\r
-\r
-                    responceStream.Close();\r
-                    loacalStream.Close();\r
-\r
-                    if (flength != fileSize)\r
-                        this.Invoke(new DownloadFailedCallback(this.downloadFailed));\r
-                    else\r
-                        this.Invoke(new DownloadCompleteCallback(this.downloadComplete));\r
-                }\r
-                catch (Exception)\r
+                responceStream = wcDownload.OpenRead(hbUpdate);\r
+                loacalStream = new FileStream(tempPath, FileMode.Create, FileAccess.Write, FileShare.None);\r
+\r
+                int bytesSize = 0;\r
+                byte[] downBuffer = new byte[2048];\r
+\r
+                long flength = 0;\r
+                while ((bytesSize = responceStream.Read(downBuffer, 0, downBuffer.Length)) > 0)\r
                 {\r
-                    // Do Nothing \r
+                    loacalStream.Write(downBuffer, 0, bytesSize);\r
+                    flength = loacalStream.Length;\r
+                    this.Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { loacalStream.Length, fileSize });\r
                 }\r
+\r
+                responceStream.Close();\r
+                loacalStream.Close();\r
+\r
+                if (flength != fileSize)\r
+                    this.Invoke(new DownloadFailedCallback(this.downloadFailed));\r
+                else\r
+                    this.Invoke(new DownloadCompleteCallback(this.downloadComplete));\r
+            }\r
+            catch (Exception)\r
+            {\r
+                // Do Nothing \r
+            }\r
         }\r
 \r
         private void UpdateProgress(Int64 BytesRead, Int64 TotalBytes)\r
index d9a239d4cf2e8807e2d9adcbde5dd6d1c1dbf191..69c2056f54eb5bbcdbc24066e1136cde04c381b6 100644 (file)
@@ -6,6 +6,7 @@
 \r
 using System;\r
 using System.Collections;\r
+using System.Collections.Generic;\r
 using System.Drawing;\r
 using System.Text;\r
 using System.Windows.Forms;\r
@@ -62,7 +63,7 @@ namespace Handbrake
                     Properties.Settings.Default.hb_build = int.Parse(x[1].ToString());\r
                     Properties.Settings.Default.hb_version = x[0].ToString();\r
                 }\r
-                catch (Exception) \r
+                catch (Exception)\r
                 {\r
                     Properties.Settings.Default.hb_build = 0;\r
                     Properties.Settings.Default.hb_version = "0";\r
@@ -160,19 +161,16 @@ namespace Handbrake
         {\r
             // Try to load the users default settings.\r
             string userDefaults = Properties.Settings.Default.defaultUserSettings;\r
-            try\r
-            {\r
-                Functions.QueryParser presetQuery = Functions.QueryParser.Parse(userDefaults);\r
-                hb_common_func.presetLoader(this, presetQuery, "User Defaults ");\r
-            }\r
-            catch (Exception) { /* Do Nothing */ }\r
+\r
+            Functions.QueryParser presetQuery = Functions.QueryParser.Parse(userDefaults);\r
+            hb_common_func.presetLoader(this, presetQuery, "User Defaults ");\r
         }\r
         private void queueRecovery()\r
         {\r
             if (hb_common_func.check_queue_recovery() == true)\r
             {\r
                 DialogResult result;\r
-                result = MessageBox.Show("HandBrake has detected unfinished items on the queue from the last time the application was launched. Would you like to recover these?","Queue Recovery Possible", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+                result = MessageBox.Show("HandBrake has detected unfinished items on the queue from the last time the application was launched. Would you like to recover these?", "Queue Recovery Possible", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
 \r
                 if (result == DialogResult.Yes)\r
                     encodeQueue.recoverQueue(); // Start Recovery\r
@@ -332,7 +330,7 @@ namespace Handbrake
         }\r
         private void btn_start_Click(object sender, EventArgs e)\r
         {\r
-            if (text_source.Text == "" || text_source.Text == "Click 'Source' to continue" || text_destination.Text == "")\r
+            if (text_source.Text == string.Empty || text_source.Text == "Click 'Source' to continue" || text_destination.Text == string.Empty)\r
                 MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
             else\r
             {\r
@@ -354,7 +352,7 @@ namespace Handbrake
         }\r
         private void btn_add2Queue_Click(object sender, EventArgs e)\r
         {\r
-            if (text_source.Text == "" || text_source.Text == "Click 'Source' to continue" || text_destination.Text == "")\r
+            if (text_source.Text == string.Empty || text_source.Text == "Click 'Source' to continue" || text_destination.Text == string.Empty)\r
                 MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
             else\r
             {\r
@@ -542,18 +540,12 @@ namespace Handbrake
             drop_chapterStart.BackColor = Color.White;\r
             if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))\r
             {\r
-                try\r
-                {\r
-                    int chapterFinish = int.Parse(drop_chapterFinish.Text);\r
-                    int chapterStart = int.Parse(drop_chapterStart.Text);\r
+                int chapterFinish, chapterStart = 0;\r
+                int.TryParse(drop_chapterFinish.Text, out chapterFinish);\r
+                int.TryParse(drop_chapterStart.Text, out chapterStart);\r
 \r
-                    if (chapterFinish < chapterStart)\r
-                        drop_chapterStart.BackColor = Color.LightCoral;\r
-                }\r
-                catch (Exception)\r
-                {\r
+                if (chapterFinish < chapterStart)\r
                     drop_chapterStart.BackColor = Color.LightCoral;\r
-                }\r
             }\r
             // Run the Autonaming function\r
             hb_common_func.autoName(this);\r
@@ -565,18 +557,12 @@ namespace Handbrake
             drop_chapterFinish.BackColor = Color.White;\r
             if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))\r
             {\r
-                try\r
-                {\r
-                    int chapterFinish = int.Parse(drop_chapterFinish.Text);\r
-                    int chapterStart = int.Parse(drop_chapterStart.Text);\r
+                int chapterFinish, chapterStart = 0;\r
+                int.TryParse(drop_chapterFinish.Text, out chapterFinish);\r
+                int.TryParse(drop_chapterStart.Text, out chapterStart);\r
 \r
-                    if (chapterFinish < chapterStart)\r
-                        drop_chapterFinish.BackColor = Color.LightCoral;\r
-                }\r
-                catch (Exception)\r
-                {\r
+                if (chapterFinish < chapterStart)\r
                     drop_chapterFinish.BackColor = Color.LightCoral;\r
-                }\r
             }\r
 \r
             // Run the Autonaming function\r
@@ -725,9 +711,11 @@ namespace Handbrake
         //Picture Tab\r
         private void text_width_TextChanged(object sender, EventArgs e)\r
         {\r
-            try\r
+            int width;\r
+            Boolean parsed = int.TryParse(text_width.Text, out width);\r
+            if (parsed != false)\r
             {\r
-                if ((int.Parse(text_width.Text) % 16) != 0)\r
+                if ((width % 16) != 0)\r
                     text_width.BackColor = Color.LightCoral;\r
                 else\r
                     text_width.BackColor = Color.LightGreen;\r
@@ -737,29 +725,23 @@ namespace Handbrake
                 {\r
                     if (drp_anamorphic.Text == "None")\r
                     {\r
-                        int height = cacluateNonAnamorphicHeight(int.Parse(text_width.Text));\r
+                        int height = cacluateNonAnamorphicHeight(width);\r
                         text_height.Text = height.ToString();\r
                     }\r
                 }\r
             }\r
-            catch (Exception)\r
-            {\r
-                // No need to throw an error here.\r
-            }\r
         }\r
         private void text_height_TextChanged(object sender, EventArgs e)\r
         {\r
-            try\r
+            int height;\r
+            Boolean parsed = int.TryParse(text_height.Text, out height);\r
+            if (parsed != false)\r
             {\r
-                if ((int.Parse(text_height.Text) % 16) != 0)\r
+                if ((height % 16) != 0)\r
                     text_height.BackColor = Color.LightCoral;\r
                 else\r
                     text_height.BackColor = Color.LightGreen;\r
             }\r
-            catch (Exception)\r
-            {\r
-                // No need to alert the user.\r
-            }\r
         }\r
         private void drp_crop_SelectedIndexChanged(object sender, EventArgs e)\r
         {\r
@@ -1369,7 +1351,7 @@ namespace Handbrake
                 x264PanelFunctions.X264_StandardizeOptString(this);\r
                 x264PanelFunctions.X264_SetCurrentSettingsInPanel(this);\r
 \r
-                if (rtf_x264Query.Text == "")\r
+                if (rtf_x264Query.Text == string.Empty)\r
                     x264PanelFunctions.reset2Defaults(this);\r
             }\r
         }\r
@@ -1452,29 +1434,24 @@ namespace Handbrake
         // Chapter Selection Duration calculation\r
         public void calculateDuration()\r
         {\r
-            int start_chapter;\r
-            int end_chapter;\r
             TimeSpan Duration = TimeSpan.FromSeconds(0.0);\r
 \r
-            try\r
+            // Get the durations between the 2 chapter points and add them together.\r
+            if (drop_chapterStart.Text != "Auto" && drop_chapterFinish.Text != "Auto")\r
             {\r
-                // Get the durations between the 2 chapter points and add them together.\r
-                if (drop_chapterStart.Text != "Auto" && drop_chapterFinish.Text != "Auto")\r
-                {\r
-                    start_chapter = int.Parse(drop_chapterStart.Text);\r
-                    end_chapter = int.Parse(drop_chapterFinish.Text);\r
+                int start_chapter, end_chapter = 0;\r
+                int.TryParse(drop_chapterStart.Text, out start_chapter);\r
+                int.TryParse(drop_chapterFinish.Text, out end_chapter);\r
 \r
-                    int position = start_chapter - 1;\r
+                int position = start_chapter - 1;\r
 \r
-                    while (position != end_chapter)\r
-                    {\r
-                        TimeSpan dur = selectedTitle.Chapters[position].Duration;\r
-                        Duration = Duration + dur;\r
-                        position++;\r
-                    }\r
+                while (position != end_chapter)\r
+                {\r
+                    TimeSpan dur = selectedTitle.Chapters[position].Duration;\r
+                    Duration = Duration + dur;\r
+                    position++;\r
                 }\r
             }\r
-            catch (Exception) { /* Don't do anything */ }\r
 \r
             // Set the Duration\r
             lbl_duration.Text = Duration.ToString();\r
@@ -1633,7 +1610,7 @@ namespace Handbrake
                 drp_audenc_1.Items.Add("MP3");\r
                 drp_audenc_1.Items.Add("AC3");\r
                 drp_audenc_1.Items.Add("Vorbis");\r
-                if (drp_audenc_1.Text == "")\r
+                if (drp_audenc_1.Text == string.Empty)\r
                     drp_audenc_1.SelectedIndex = 0;\r
 \r
 \r
@@ -1644,7 +1621,7 @@ namespace Handbrake
                 drp_audenc_2.Items.Add("Vorbis");\r
                 if (drp_audenc_2.Enabled)\r
                 {\r
-                    if (drp_audenc_2.Text == "")\r
+                    if (drp_audenc_2.Text == string.Empty)\r
                         drp_audenc_2.SelectedIndex = 0;\r
                 }\r
 \r
@@ -1655,7 +1632,7 @@ namespace Handbrake
                 drp_audenc_3.Items.Add("Vorbis");\r
                 if (drp_audenc_3.Enabled)\r
                 {\r
-                    if (drp_audenc_3.Text == "")\r
+                    if (drp_audenc_3.Text == string.Empty)\r
                         drp_audenc_3.SelectedIndex = 0;\r
                 }\r
 \r
@@ -1666,7 +1643,7 @@ namespace Handbrake
                 drp_audenc_4.Items.Add("Vorbis");\r
                 if (drp_audenc_4.Enabled)\r
                 {\r
-                    if (drp_audenc_4.Text == "")\r
+                    if (drp_audenc_4.Text == string.Empty)\r
                         drp_audenc_4.SelectedIndex = 0;\r
                 }\r
             }\r
@@ -1789,7 +1766,7 @@ namespace Handbrake
             presetHandler.loadPresetFiles();\r
 \r
             treeView_presets.Nodes.Clear();\r
-            ArrayList presetNameList = new ArrayList();\r
+            List<string> presetNameList = new List<string>();\r
             presetNameList = presetHandler.getPresetNames();\r
 \r
             // Adds a new preset name to the preset list.\r
index ac4f7f5c11759d631036b78cb8f3923163832c79..6252bb9b8c475e9dd7ac8b1a04504637f664a2e6 100644 (file)
@@ -18,19 +18,19 @@ namespace Handbrake
         public frmUpdater()\r
         {\r
             InitializeComponent();\r
-          \r
+\r
             getRss();\r
             setVersions();\r
         }\r
 \r
         private void getRss()\r
-        { \r
+        {\r
             wBrowser.DocumentText = "<font face=\"verdana\" size=\"1\">" + rssRead.versionInfo() + "</font>";\r
         }\r
 \r
         private void setVersions()\r
         {\r
-            lbl_oldVersion.Text = "(you have: " + Properties.Settings.Default.hb_version + " / " + Properties.Settings.Default.hb_build  + ").";\r
+            lbl_oldVersion.Text = "(you have: " + Properties.Settings.Default.hb_version + " / " + Properties.Settings.Default.hb_build + ").";\r
             lbl_newVersion.Text = rssRead.version() + " (" + rssRead.build() + ")";\r
         }\r
 \r
@@ -38,7 +38,7 @@ namespace Handbrake
         {\r
             frmDownload download = new frmDownload();\r
             download.Show();\r
-            this.Close(); \r
+            this.Close();\r
         }\r
 \r
         private void btn_remindLater_Click(object sender, EventArgs e)\r
@@ -48,15 +48,9 @@ namespace Handbrake
 \r
         private void btn_skip_Click(object sender, EventArgs e)\r
         {\r
-            try\r
-            {\r
-                Properties.Settings.Default.skipversion = int.Parse(rssRead.build());\r
-                Properties.Settings.Default.Save();\r
-            }\r
-            catch (Exception exc)\r
-            {\r
-                MessageBox.Show(exc.ToString());\r
-            }\r
+            Properties.Settings.Default.skipversion = int.Parse(rssRead.build());\r
+            Properties.Settings.Default.Save();\r
+\r
             this.Close();\r
         }\r
 \r