OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Wed, 1 Apr 2009 23:48:34 +0000 (23:48 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Wed, 1 Apr 2009 23:48:34 +0000 (23:48 +0000)
- Just some minor code tweaks to clean things up.

git-svn-id: svn://localhost/HandBrake/trunk@2291 b64f7644-9d1e-0410-96f1-a4d463321fa5

17 files changed:
win/C#/Controls/Decomb.cs
win/C#/Controls/Deinterlace.cs
win/C#/Controls/Detelecine.cs
win/C#/Controls/x264Panel.cs
win/C#/Functions/AppcastReader.cs
win/C#/Functions/Encode.cs
win/C#/Functions/Main.cs
win/C#/Functions/QueryParser.cs
win/C#/Parsing/AudioTrack.cs
win/C#/Parsing/Chapter.cs
win/C#/Parsing/Parser.cs
win/C#/Parsing/Subtitle.cs
win/C#/Parsing/Title.cs
win/C#/Presets/PresetsHandler.cs
win/C#/Queue/QueueHandler.cs
win/C#/frmMain/PresetLoader.cs
win/C#/frmMain/QueryGenerator.cs

index 6762bfb..35c613a 100644 (file)
@@ -19,10 +19,7 @@ namespace Handbrake
 \r
         private void drop_decomb_SelectedIndexChanged(object sender, EventArgs e)\r
         {\r
-            if (drop_decomb.Text == "Custom")\r
-                text_custom.Visible = true;\r
-            else\r
-                text_custom.Visible = false;\r
+            text_custom.Visible = drop_decomb.Text == "Custom";\r
 \r
             valueChanged(null);\r
         }\r
index 7acfed8..2ff9b33 100644 (file)
@@ -18,10 +18,7 @@ namespace Handbrake
 \r
         private void drop_detelecine_SelectedIndexChanged(object sender, EventArgs e)\r
         {\r
-            if (drop_deinterlace.Text == "Custom")\r
-                text_custom.Visible = true;\r
-            else\r
-                text_custom.Visible = false;\r
+            text_custom.Visible = drop_deinterlace.Text == "Custom";\r
 \r
             valueChanged(null);\r
         }\r
index 6eaf462..4c2e0b2 100644 (file)
@@ -19,10 +19,7 @@ namespace Handbrake
 \r
         private void drop_detelecine_SelectedIndexChanged(object sender, EventArgs e)\r
         {\r
-            if (drop_detelecine.Text == "Custom")\r
-                text_custom.Visible = true;\r
-            else\r
-                text_custom.Visible = false;\r
+            text_custom.Visible = drop_detelecine.Text == "Custom";\r
         }\r
 \r
         public string getDropValue\r
index 55a7bc0..6790bb7 100644 (file)
@@ -227,7 +227,7 @@ namespace Handbrake.Controls
         /// </summary>\r
         /// <param name="cleanOptNameString"></param>\r
         /// <returns></returns>\r
-        private string X264_StandardizeOptNames(String cleanOptNameString)\r
+        private static string X264_StandardizeOptNames(String cleanOptNameString)\r
         {\r
             String input = cleanOptNameString;\r
 \r
index 11f75fe..b52c22d 100644 (file)
@@ -26,20 +26,19 @@ namespace Handbrake.Functions
         /// </summary>\r
         public void getInfo()\r
         {\r
-            Match ver;\r
-            int stable_build, unstable_build = 0;\r
-            string input, unstable_description = "", stable_description, unstable_version = "", stable_version;\r
-            string stable_file, unstable_file = "";\r
+            int unstable_build = 0;\r
+            string unstable_description = "", unstable_version = "";\r
+            string unstable_file = "";\r
 \r
             // Check the stable appcast and get the stable build number\r
             readRss(new XmlTextReader(Properties.Settings.Default.appcast));\r
-            input = nodeItem.InnerXml;\r
-            ver = Regex.Match(input, @"sparkle:version=""([0-9]*)\""");\r
-            stable_build = int.Parse(ver.ToString().Replace("sparkle:version=", "").Replace("\"", ""));\r
+            string input = nodeItem.InnerXml;\r
+            Match ver = Regex.Match(input, @"sparkle:version=""([0-9]*)\""");\r
+            int stable_build = int.Parse(ver.ToString().Replace("sparkle:version=", "").Replace("\"", ""));\r
             ver = Regex.Match(input, @"sparkle:shortVersionString=""([0-9].[0-9].[0-9]*)\""");\r
-            stable_version = ver.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");\r
-            stable_description = nodeItem["description"].InnerText;\r
-            stable_file = nodeItem["windows"].InnerText;\r
+            string stable_version = ver.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");\r
+            string stable_description = nodeItem["description"].InnerText;\r
+            string stable_file = nodeItem["windows"].InnerText;\r
 \r
             // If this is a snapshot release, or the user wants to check for snapshot releases\r
             if (Properties.Settings.Default.checkSnapshot == "Checked" || Properties.Settings.Default.hb_build.ToString().EndsWith("1"))\r
@@ -76,7 +75,7 @@ namespace Handbrake.Functions
         /// Read the RSS file.\r
         /// </summary>\r
         /// <param name="rssReader"></param>\r
-        private void readRss(XmlTextReader rssReader)\r
+        private void readRss(XmlReader rssReader)\r
         {\r
             rssDoc = new XmlDocument();\r
             rssDoc.Load(rssReader);\r
index ed8920c..1cd3de4 100644 (file)
@@ -45,35 +45,36 @@ namespace Handbrake.Functions
                 encoding = true;\r
 \r
                 // Set the process Priority \r
-                switch (Properties.Settings.Default.processPriority)\r
-                {\r
-                    case "Realtime":\r
-                        hbProc.PriorityClass = ProcessPriorityClass.RealTime;\r
-                        break;\r
-                    case "High":\r
-                        hbProc.PriorityClass = ProcessPriorityClass.High;\r
-                        break;\r
-                    case "Above Normal":\r
-                        hbProc.PriorityClass = ProcessPriorityClass.AboveNormal;\r
-                        break;\r
-                    case "Normal":\r
-                        hbProc.PriorityClass = ProcessPriorityClass.Normal;\r
-                        break;\r
-                    case "Low":\r
-                        hbProc.PriorityClass = ProcessPriorityClass.Idle;\r
-                        break;\r
-                    default:\r
-                        hbProc.PriorityClass = ProcessPriorityClass.BelowNormal;\r
-                        break;\r
-                }\r
+                if (hbProc != null)\r
+                    switch (Properties.Settings.Default.processPriority)\r
+                    {\r
+                        case "Realtime":\r
+                            hbProc.PriorityClass = ProcessPriorityClass.RealTime;\r
+                            break;\r
+                        case "High":\r
+                            hbProc.PriorityClass = ProcessPriorityClass.High;\r
+                            break;\r
+                        case "Above Normal":\r
+                            hbProc.PriorityClass = ProcessPriorityClass.AboveNormal;\r
+                            break;\r
+                        case "Normal":\r
+                            hbProc.PriorityClass = ProcessPriorityClass.Normal;\r
+                            break;\r
+                        case "Low":\r
+                            hbProc.PriorityClass = ProcessPriorityClass.Idle;\r
+                            break;\r
+                        default:\r
+                            hbProc.PriorityClass = ProcessPriorityClass.BelowNormal;\r
+                            break;\r
+                    }\r
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("An error occured in runCli()\n Error Information: \n\n" + exc.ToString());\r
+                MessageBox.Show("An error occured in runCli()\n Error Information: \n\n" + exc);\r
             }\r
             return hbProc;\r
         }\r
-        \r
+\r
         /// <summary>\r
         /// Perform an action after an encode. e.g a shutdown, standby, restart etc.\r
         /// </summary>\r
@@ -149,7 +150,7 @@ namespace Handbrake.Functions
                         destinationFile += destName[i] + "\\";\r
                     }\r
 \r
-                    destinationFile += DateTime.Now.ToString().Replace("/", "-").Replace(":", "-") + " " + destName[destName.Length - 1] + ".txt"; \r
+                    destinationFile += DateTime.Now.ToString().Replace("/", "-").Replace(":", "-") + " " + destName[destName.Length - 1] + ".txt";\r
 \r
                     File.Copy(logPath, destinationFile);\r
                 }\r
index 59af6bf..6830674 100644 (file)
@@ -18,7 +18,7 @@ namespace Handbrake.Functions
     class Main\r
     {\r
         // Private Variables\r
-        private static XmlSerializer ser = new XmlSerializer(typeof(List<Queue.QueueItem>));\r
+        private static readonly XmlSerializer ser = new XmlSerializer(typeof(List<Queue.QueueItem>));\r
 \r
         /// <summary>\r
         /// Calculate the duration of the selected title and chapters\r
@@ -256,7 +256,7 @@ namespace Handbrake.Functions
         {\r
             try\r
             {\r
-                Functions.AppcastReader rssRead = new AppcastReader();\r
+                AppcastReader rssRead = new AppcastReader();\r
                 rssRead.getInfo(); // Initializes the class.\r
                 string build = rssRead.build();\r
 \r
@@ -290,11 +290,13 @@ namespace Handbrake.Functions
             // 0 = SVN Build / Version\r
             // 1 = Build Date\r
             Process cliProcess = new Process();\r
-            ProcessStartInfo handBrakeCLI = new ProcessStartInfo("HandBrakeCLI.exe", " -u");\r
-            handBrakeCLI.UseShellExecute = false;\r
-            handBrakeCLI.RedirectStandardError = true;\r
-            handBrakeCLI.RedirectStandardOutput = true;\r
-            handBrakeCLI.CreateNoWindow = true;\r
+            ProcessStartInfo handBrakeCLI = new ProcessStartInfo("HandBrakeCLI.exe", " -u")\r
+                                                {\r
+                                                    UseShellExecute = false,\r
+                                                    RedirectStandardError = true,\r
+                                                    RedirectStandardOutput = true,\r
+                                                    CreateNoWindow = true\r
+                                                };\r
             cliProcess.StartInfo = handBrakeCLI;\r
 \r
             try\r
@@ -305,8 +307,7 @@ namespace Handbrake.Functions
 \r
                 while (!cliProcess.HasExited)\r
                 {\r
-                    line = stdOutput.ReadLine();\r
-                    if (line == null) line = "";\r
+                    line = stdOutput.ReadLine() ?? "";\r
                     Match m = Regex.Match(line, @"HandBrake ([0-9\.]*)*(svn[0-9]*[M]*)* \([0-9]*\)");\r
 \r
                     if (m.Success)\r
@@ -331,13 +332,13 @@ namespace Handbrake.Functions
             cliVersionData.Add("0");\r
             return cliVersionData;\r
         }\r
-        private void killCLI()\r
+        private static 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
+            Process[] prs = Process.GetProcesses();\r
+            foreach (Process proces in prs)\r
             {\r
                 if (proces.ProcessName.ToUpper() == AppName)\r
                 {\r
@@ -363,8 +364,9 @@ namespace Handbrake.Functions
                     using (FileStream strm = new FileStream(tempPath, FileMode.Open, FileAccess.Read))\r
                     {\r
                         List<Queue.QueueItem> list = ser.Deserialize(strm) as List<Queue.QueueItem>;\r
-                        if (list.Count != 0)\r
-                            return true;\r
+                        if (list != null)\r
+                            if (list.Count != 0)\r
+                                return true;\r
                     }\r
                 }\r
                 return false;\r
index b3c8a70..eb6c060 100644 (file)
@@ -1042,12 +1042,7 @@ namespace Handbrake.Functions
                 if (subtitles.Success)\r
                     thisQuery.q_subtitles = subtitles.ToString().Replace("-s ", "");\r
                 else\r
-                {\r
-                    if (subScan.Success)\r
-                        thisQuery.q_subtitles = "Autoselect";\r
-                    else\r
-                        thisQuery.q_subtitles = "None";\r
-                }\r
+                    thisQuery.q_subtitles = subScan.Success ? "Autoselect" : "None";\r
 \r
                 thisQuery.q_forcedSubs = forcedSubtitles.Success;\r
 \r
index d2d6f3f..86c2b6e 100644 (file)
@@ -79,8 +79,8 @@ namespace Handbrake.Parsing
         {\r
             if (m_subFormat == null)\r
                 return string.Format("{0} {1} ({2})", m_trackNumber, m_language, m_format);\r
-            else\r
-                return string.Format("{0} {1} ({2}) ({3})", m_trackNumber, m_language, m_format, m_subFormat);\r
+            \r
+            return string.Format("{0} {1} ({2}) ({3})", m_trackNumber, m_language, m_format, m_subFormat);\r
         }\r
 \r
         public static AudioTrack Parse(StringReader output)\r
@@ -91,25 +91,30 @@ namespace Handbrake.Parsing
             Match y = Regex.Match(audio_track, @"^    \+ ([0-9]*), ([A-Za-z0-9]*) \((.*)\)");\r
             if (m.Success)\r
             {\r
-                var thisTrack = new AudioTrack();\r
-                thisTrack.m_trackNumber = int.Parse(m.Groups[1].Value.Trim());\r
-                thisTrack.m_language = m.Groups[2].Value;\r
-                thisTrack.m_format = m.Groups[3].Value;\r
-                thisTrack.m_subFormat = m.Groups[4].Value;\r
-                thisTrack.m_frequency = int.Parse(m.Groups[5].Value.Trim());\r
-                thisTrack.m_bitrate = int.Parse(m.Groups[6].Value.Trim());\r
+                var thisTrack = new AudioTrack\r
+                                    {\r
+                                        m_trackNumber = int.Parse(m.Groups[1].Value.Trim()),\r
+                                        m_language = m.Groups[2].Value,\r
+                                        m_format = m.Groups[3].Value,\r
+                                        m_subFormat = m.Groups[4].Value,\r
+                                        m_frequency = int.Parse(m.Groups[5].Value.Trim()),\r
+                                        m_bitrate = int.Parse(m.Groups[6].Value.Trim())\r
+                                    };\r
                 return thisTrack;\r
             }\r
-            else if (y.Success)\r
+            \r
+            if (y.Success)\r
             {\r
-                var thisTrack = new AudioTrack();\r
-                thisTrack.m_trackNumber = int.Parse(y.Groups[1].Value.Trim());\r
-                thisTrack.m_language = y.Groups[2].Value;\r
-                thisTrack.m_format = y.Groups[3].Value;\r
+                var thisTrack = new AudioTrack\r
+                                    {\r
+                                        m_trackNumber = int.Parse(y.Groups[1].Value.Trim()),\r
+                                        m_language = y.Groups[2].Value,\r
+                                        m_format = y.Groups[3].Value\r
+                                    };\r
                 return thisTrack;\r
             }\r
-            else\r
-                return null;\r
+            \r
+            return null;\r
         }\r
 \r
         public static AudioTrack[] ParseList(StringReader output)\r
index 301fa57..1bf38f4 100644 (file)
@@ -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})");\r
             if (m.Success)\r
             {\r
-                var thisChapter = new Chapter();\r
-                thisChapter.m_chapterNumber = int.Parse(m.Groups[1].Value.Trim());\r
-                thisChapter.m_duration = TimeSpan.Parse(m.Groups[5].Value);\r
+                var thisChapter = new Chapter\r
+                                      {\r
+                                          m_chapterNumber = int.Parse(m.Groups[1].Value.Trim()),\r
+                                          m_duration = TimeSpan.Parse(m.Groups[5].Value)\r
+                                      };\r
                 return thisChapter;\r
             }\r
-            else\r
-                return null;\r
+            return null;\r
         }\r
 \r
         public static Chapter[] ParseList(StringReader output)\r
index 24dcef4..c152750 100644 (file)
@@ -37,7 +37,7 @@ namespace Handbrake.Parsing
         {\r
             get\r
             {\r
-                return this.m_buffer;\r
+                return m_buffer;\r
             }\r
         }\r
 \r
@@ -64,14 +64,14 @@ namespace Handbrake.Parsing
         public Parser(Stream baseStream)\r
             : base(baseStream)\r
         {\r
-            this.m_buffer = string.Empty;\r
+            m_buffer = string.Empty;\r
         }\r
 \r
         public override string ReadLine()\r
         {\r
             string tmp = base.ReadLine();\r
 \r
-            this.m_buffer += tmp;\r
+            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
@@ -86,7 +86,7 @@ namespace Handbrake.Parsing
         {\r
             string tmp = base.ReadToEnd();\r
 \r
-            this.m_buffer += tmp;\r
+            m_buffer += tmp;\r
             if (OnReadToEnd != null)\r
                 OnReadToEnd(this, tmp);\r
 \r
index 71e0012..e3ff72a 100644 (file)
@@ -50,13 +50,14 @@ namespace Handbrake.Parsing
             Match m = Regex.Match(curLine, @"^    \+ ([0-9]*), ([A-Za-z, ]*) \((.*)\)");\r
             if (m.Success && !curLine.Contains("HandBrake has exited."))\r
             {\r
-                var thisSubtitle = new Subtitle();\r
-                thisSubtitle.m_trackNumber = int.Parse(m.Groups[1].Value.Trim());\r
-                thisSubtitle.m_language = m.Groups[2].Value;\r
+                var thisSubtitle = new Subtitle\r
+                                       {\r
+                                           m_trackNumber = int.Parse(m.Groups[1].Value.Trim()),\r
+                                           m_language = m.Groups[2].Value\r
+                                       };\r
                 return thisSubtitle;\r
             }\r
-            else\r
-                return null;\r
+            return null;\r
         }\r
 \r
         public static Subtitle[] ParseList(StringReader output)\r
index 74ccab7..8073606 100644 (file)
@@ -126,7 +126,7 @@ namespace Handbrake.Parsing
             if (m.Success)\r
                 thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value.Trim());\r
 \r
-            String testData = output.ReadLine();\r
+            output.ReadLine();\r
 \r
             // Get duration for this title\r
 \r
@@ -146,7 +146,7 @@ namespace Handbrake.Parsing
             // 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]\r
+                thisTitle.m_autoCrop = new int[]\r
                                            {\r
                                                int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value),\r
                                                int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value)\r
index aa52d06..e29c4d2 100644 (file)
@@ -12,7 +12,7 @@ namespace Handbrake.Presets
     {\r
         List<Preset> presets = new List<Preset>();  // Category+Level+Preset Name: Query\r
         List<Preset> user_presets = new List<Preset>(); // Preset Name: Query\r
-        private static XmlSerializer ser = new XmlSerializer(typeof(List<Preset>));\r
+        private static readonly XmlSerializer ser = new XmlSerializer(typeof(List<Preset>));\r
 \r
         /// <summary>\r
         /// Add a new preset to the system\r
@@ -24,19 +24,13 @@ namespace Handbrake.Presets
         {\r
             if (checkIfPresetExists(presetName) == false)\r
             {\r
-                Preset newPreset = new Preset();\r
-                newPreset.Name = presetName;\r
-                newPreset.Query = query;\r
-                newPreset.PictureSettings = pictureSettings;\r
+                Preset newPreset = new Preset {Name = presetName, Query = query, PictureSettings = pictureSettings};\r
                 user_presets.Add(newPreset);\r
                 updateUserPresetsFile();\r
                 return true;\r
             }\r
-            else\r
-            {\r
-                MessageBox.Show("Sorry, that preset name already exists. Please choose another!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
-                return false;\r
-            }\r
+            MessageBox.Show("Sorry, that preset name already exists. Please choose another!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+            return false;\r
         }\r
 \r
         /// <summary>\r
@@ -155,13 +149,16 @@ namespace Handbrake.Presets
 \r
             string strCmdLine = String.Format(@"cmd /c """"{0}"" --preset-list >""{1}"" 2>&1""", handbrakeCLIPath, presetsPath);\r
 \r
-            ProcessStartInfo hbGetPresets = new ProcessStartInfo("CMD.exe", strCmdLine);\r
-            hbGetPresets.WindowStyle = ProcessWindowStyle.Hidden;\r
+            ProcessStartInfo hbGetPresets = new ProcessStartInfo("CMD.exe", strCmdLine)\r
+                                                {WindowStyle = ProcessWindowStyle.Hidden};\r
 \r
             Process hbproc = Process.Start(hbGetPresets);\r
-            hbproc.WaitForExit();\r
-            hbproc.Dispose();\r
-            hbproc.Close();\r
+            if (hbproc != null)\r
+            {\r
+                hbproc.WaitForExit();\r
+                hbproc.Dispose();\r
+                hbproc.Close();\r
+            }\r
 \r
             // Clear the current built in presets and now parse the tempory presets file.\r
             presets.Clear();\r
@@ -200,11 +197,13 @@ namespace Handbrake.Presets
                         Regex r = new Regex("(:  )"); // Split on hyphens. \r
                         string[] presetName = r.Split(line);\r
 \r
-                        Preset newPreset = new Preset();\r
-                        newPreset.Level = level;\r
-                        newPreset.Category = category;\r
-                        newPreset.Name = presetName[0].Replace("+", "").Trim();\r
-                        newPreset.Query = presetName[2];\r
+                        Preset newPreset = new Preset\r
+                                               {\r
+                                                   Level = level,\r
+                                                   Category = category,\r
+                                                   Name = presetName[0].Replace("+", "").Trim(),\r
+                                                   Query = presetName[2]\r
+                                               };\r
                         presets.Add(newPreset);\r
                     }\r
                 }\r
@@ -236,8 +235,9 @@ namespace Handbrake.Presets
                     {\r
                         List<Preset> list = ser.Deserialize(strm) as List<Preset>;\r
 \r
-                        foreach (Preset preset in list)\r
-                            presets.Add(preset);\r
+                        if (list != null)\r
+                            foreach (Preset preset in list)\r
+                                presets.Add(preset);\r
                     }\r
                 }\r
             }\r
@@ -252,8 +252,9 @@ namespace Handbrake.Presets
                     {\r
                         List<Preset> list = ser.Deserialize(strm) as List<Preset>;\r
 \r
-                        foreach (Preset preset in list)\r
-                            user_presets.Add(preset);\r
+                        if (list != null)\r
+                            foreach (Preset preset in list)\r
+                                user_presets.Add(preset);\r
                     }\r
                 }\r
             }\r
index 478757e..8008d17 100644 (file)
@@ -204,8 +204,9 @@ namespace Handbrake.Queue
                     {\r
                         List<QueueItem> list = ser.Deserialize(strm) as List<QueueItem>;\r
 \r
-                        foreach (QueueItem item in list)\r
-                            queue.Add(item);\r
+                        if (list != null)\r
+                            foreach (QueueItem item in list)\r
+                                queue.Add(item);\r
 \r
                         if (file != "hb_queue_recovery.xml")\r
                             write2disk("hb_queue_recovery.xml");\r
index f10b722..0a2ad32 100644 (file)
@@ -61,15 +61,9 @@ namespace Handbrake
                     mainWindow.drop_format.SelectedIndex = 1;\r
             }\r
 \r
-            if (presetQuery.IpodAtom)\r
-                mainWindow.check_iPodAtom.CheckState = CheckState.Checked;\r
-            else\r
-                mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked;\r
+            mainWindow.check_iPodAtom.CheckState = presetQuery.IpodAtom ? CheckState.Checked : CheckState.Unchecked;\r
 \r
-            if (presetQuery.OptimizeMP4)\r
-                mainWindow.check_optimiseMP4.CheckState = CheckState.Checked;\r
-            else\r
-                mainWindow.check_optimiseMP4.CheckState = CheckState.Unchecked;\r
+            mainWindow.check_optimiseMP4.CheckState = presetQuery.OptimizeMP4 ? CheckState.Checked : CheckState.Unchecked;\r
 \r
             #endregion\r
 \r
@@ -107,10 +101,7 @@ namespace Handbrake
                     mainWindow.text_height.Text = presetQuery.Height.ToString();\r
             }\r
 \r
-            if (presetQuery.Anamorphic)\r
-                mainWindow.drp_anamorphic.SelectedIndex = 1;\r
-            else\r
-                mainWindow.drp_anamorphic.SelectedIndex = 0;\r
+            mainWindow.drp_anamorphic.SelectedIndex = presetQuery.Anamorphic ? 1 : 0;\r
 \r
             if (presetQuery.LooseAnamorphic)\r
                 mainWindow.drp_anamorphic.SelectedIndex = 2;\r
@@ -184,7 +175,7 @@ namespace Handbrake
                     int value;\r
                     System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");\r
 \r
-                    double presetValue, calculated, x264step;\r
+                    double presetValue, x264step;\r
                     double.TryParse(presetQuery.VideoQuality.ToString(),\r
                                     System.Globalization.NumberStyles.Number,\r
                                     culture,\r
@@ -196,7 +187,7 @@ namespace Handbrake
 \r
                     double x = 51 / x264step;\r
 \r
-                    calculated = presetValue / x264step;\r
+                    double calculated = presetValue / x264step;\r
                     calculated = x - calculated;\r
 \r
                     int.TryParse(calculated.ToString(), out value);\r
@@ -219,22 +210,13 @@ namespace Handbrake
                 }\r
             }\r
 \r
-            if (presetQuery.TwoPass)\r
-                mainWindow.check_2PassEncode.CheckState = CheckState.Checked;\r
-            else\r
-                mainWindow.check_2PassEncode.CheckState = CheckState.Unchecked;\r
+            mainWindow.check_2PassEncode.CheckState = presetQuery.TwoPass ? CheckState.Checked : CheckState.Unchecked;\r
 \r
-            if (presetQuery.Grayscale)\r
-                mainWindow.check_grayscale.CheckState = CheckState.Checked;\r
-            else\r
-                mainWindow.check_grayscale.CheckState = CheckState.Unchecked;\r
+            mainWindow.check_grayscale.CheckState = presetQuery.Grayscale ? CheckState.Checked : CheckState.Unchecked;\r
 \r
             mainWindow.drp_videoFramerate.Text = presetQuery.VideoFramerate;\r
 \r
-            if (presetQuery.TurboFirstPass)\r
-                mainWindow.check_turbo.CheckState = CheckState.Checked;\r
-            else\r
-                mainWindow.check_turbo.CheckState = CheckState.Unchecked;\r
+            mainWindow.check_turbo.CheckState = presetQuery.TurboFirstPass ? CheckState.Checked : CheckState.Unchecked;\r
 \r
             if (presetQuery.LargeMP4)\r
                 mainWindow.check_largeFile.CheckState = CheckState.Checked;\r
index 6c01286..586c7a8 100644 (file)
@@ -219,7 +219,7 @@ namespace Handbrake
                         break;\r
                     case "H.264 (x264)":\r
                         double divided;\r
-                        System.Globalization.CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");\r
+                        CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");\r
                         double.TryParse(Properties.Settings.Default.x264cqstep,\r
                                         NumberStyles.Number,\r
                                         culture,\r
@@ -410,11 +410,9 @@ namespace Handbrake
             {\r
                 if (dest_name.Trim() != String.Empty)\r
                 {\r
-                    string path;\r
-                    if (source_title != "Automatic")\r
-                        path = Path.Combine(Path.GetTempPath(), dest_name + "-" + source_title + "-chapters.csv");\r
-                    else\r
-                        path = Path.Combine(Path.GetTempPath(), dest_name + "-chapters.csv");\r
+                    string path = source_title != "Automatic" \r
+                                      ? Path.Combine(Path.GetTempPath(), dest_name + "-" + source_title + "-chapters.csv") \r
+                                      : Path.Combine(Path.GetTempPath(), dest_name + "-chapters.csv");\r
 \r
                     if (chapterCSVSave(mainWindow, path) == false)\r
                         query += " -m ";\r
@@ -448,7 +446,7 @@ namespace Handbrake
         /// <param name="selectedAudio"></param>\r
         /// <returns></returns>\r
         /// \r
-        private string getMixDown(string selectedAudio)\r
+        private static string getMixDown(string selectedAudio)\r
         {\r
             switch (selectedAudio)\r
             {\r
@@ -475,7 +473,7 @@ namespace Handbrake
         /// <param name="selectedEncoder"></param>\r
         /// <returns></returns>\r
         /// \r
-        private string getAudioEncoder(string selectedEncoder)\r
+        private static string getAudioEncoder(string selectedEncoder)\r
         {\r
             switch (selectedEncoder)\r
             {\r
@@ -499,7 +497,7 @@ namespace Handbrake
         /// <param name="mainWindow"></param>\r
         /// <param name="file_path_name"></param>\r
         /// <returns></returns>\r
-        private Boolean chapterCSVSave(frmMain mainWindow, string file_path_name)\r
+        private static Boolean chapterCSVSave(frmMain mainWindow, string file_path_name)\r
         {\r
             try\r
             {\r