OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Thu, 29 Jan 2009 21:49:05 +0000 (21:49 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Thu, 29 Jan 2009 21:49:05 +0000 (21:49 +0000)
- Code cleanup

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

win/C#/Functions/Encode.cs
win/C#/Functions/QueryParser.cs
win/C#/frmActivityWindow.cs
win/C#/frmAddPreset.cs
win/C#/frmDownload.cs
win/C#/frmGenPreview.cs
win/C#/frmMain.cs
win/C#/frmOptions.cs
win/C#/frmPreview.cs
win/C#/frmQueue.cs

index 3f126d7..ed8920c 100644 (file)
@@ -7,7 +7,6 @@
 using System;\r
 using System.Diagnostics;\r
 using System.Windows.Forms;\r
-using System.Globalization;\r
 using System.IO;\r
 using System.Runtime.InteropServices;\r
 \r
@@ -23,10 +22,7 @@ namespace Handbrake.Functions
 \r
         // Declarations\r
         Process hbProc = new Process();\r
-        Boolean encoding = false;\r
-\r
-        // CLI output is based on en-US locale,\r
-        static readonly private CultureInfo Culture = new CultureInfo("en-US", false);\r
+        Boolean encoding;\r
 \r
         /// <summary>\r
         /// Execute a HandBrakeCLI process.\r
@@ -88,7 +84,7 @@ namespace Handbrake.Functions
             switch (Properties.Settings.Default.CompletionOption)\r
             {\r
                 case "Shutdown":\r
-                    System.Diagnostics.Process.Start("Shutdown", "-s -t 60");\r
+                    Process.Start("Shutdown", "-s -t 60");\r
                     break;\r
                 case "Log Off":\r
                     ExitWindowsEx(0, 0);\r
@@ -143,7 +139,6 @@ namespace Handbrake.Functions
             if (Properties.Settings.Default.saveLog == "Checked")\r
             {\r
                 string logPath = Path.Combine(Path.GetTempPath(), "hb_encode_log.dat");\r
-                Functions.QueryParser parsed = Functions.QueryParser.Parse(query);\r
 \r
                 if (Properties.Settings.Default.saveLogWithVideo == "Checked")\r
                 {\r
@@ -175,7 +170,7 @@ namespace Handbrake.Functions
         /// </summary>\r
         public Boolean isEncoding\r
         {\r
-            get { if (encoding == false) return false; else return true; }\r
+            get { return encoding; }\r
         }\r
 \r
     }\r
index df048c5..f189e1b 100644 (file)
@@ -718,8 +718,7 @@ namespace Handbrake.Functions
 \r
                 if (chapters.Success)\r
                 {\r
-                    var actTitles = new string[2];\r
-                    actTitles = chapters.ToString().Replace("-c ", "").Split('-');\r
+                    string[] actTitles = chapters.ToString().Replace("-c ", "").Split('-');\r
                     thisQuery.q_chaptersStart = int.Parse(actTitles[0]);\r
                     if (actTitles.Length > 1)\r
                     {\r
@@ -777,8 +776,7 @@ namespace Handbrake.Functions
                 if (crop.Success)\r
                 {\r
                     thisQuery.q_cropValues = crop.ToString().Replace("--crop ", "");\r
-                    var actCropValues = new string[3];\r
-                    actCropValues = thisQuery.q_cropValues.Split(':');\r
+                    string[] actCropValues = thisQuery.q_cropValues.Split(':');\r
                     thisQuery.q_croptop = actCropValues[0];\r
                     thisQuery.q_cropbottom = actCropValues[1];\r
                     thisQuery.q_cropLeft = actCropValues[2];\r
@@ -853,17 +851,14 @@ namespace Handbrake.Functions
                 thisQuery.q_twoPass = twoPass.Success;\r
                 thisQuery.q_turboFirst = turboFirstPass.Success;\r
                 thisQuery.q_largeMp4 = largerMp4.Success;\r
-                if (videoFramerate.Success)\r
-                    thisQuery.q_videoFramerate = videoFramerate.ToString().Replace("-r ", "");\r
-                else\r
-                    thisQuery.q_videoFramerate = "Same as source";\r
+                thisQuery.q_videoFramerate = videoFramerate.Success ? videoFramerate.ToString().Replace("-r ", "") : "Same as source";\r
 \r
                 if (videoBitrate.Success)\r
                     thisQuery.q_avgBitrate = videoBitrate.ToString().Replace("-b ", "");\r
                 if (videoFilesize.Success)\r
                     thisQuery.q_videoTargetSize = videoFilesize.ToString().Replace("-S ", "");\r
 \r
-                double qConvert = 0;\r
+                double qConvert;\r
                 if (videoQuality.Success)\r
                 {\r
                     qConvert = double.Parse(videoQuality.ToString().Replace("-q ", ""), Culture)*100;\r
index 1ad4e09..94597f7 100644 (file)
@@ -21,7 +21,7 @@ namespace Handbrake
         String read_file;\r
         Thread monitor;\r
         Functions.Encode encodeHandler;\r
-        int position = 0;  // Position in the arraylist reached by the current log output in the rtf box.\r
+        int position;  // Position in the arraylist reached by the current log output in the rtf box.\r
 \r
         /// <summary>\r
         /// This window should be used to display the RAW output of the handbrake CLI which is produced during an encode.\r
@@ -29,7 +29,7 @@ namespace Handbrake
         public frmActivityWindow(string file, Functions.Encode eh)\r
         {\r
             InitializeComponent();\r
-            this.rtf_actLog.Text = string.Empty;\r
+            rtf_actLog.Text = string.Empty;\r
 \r
             // When the window closes, we want to abort the monitor thread.\r
             this.Disposed += new EventHandler(forceQuit);\r
@@ -57,7 +57,7 @@ namespace Handbrake
         {\r
             // Add a header to the log file indicating that it's from the Windows GUI and display the windows version\r
             rtf_actLog.AppendText(String.Format("### Windows GUI {1} {0} \n", Properties.Settings.Default.hb_build, Properties.Settings.Default.hb_version));\r
-            rtf_actLog.AppendText(String.Format("### Running: {0} \n###\n", Environment.OSVersion.ToString()));\r
+            rtf_actLog.AppendText(String.Format("### Running: {0} \n###\n", Environment.OSVersion));\r
             rtf_actLog.AppendText(String.Format("### CPU: {0} \n", getCpuCount()));\r
             rtf_actLog.AppendText(String.Format("### Ram: {0} MB \n", TotalPhysicalMemory()));\r
             rtf_actLog.AppendText(String.Format("### Screen: {0}x{1} \n", screenBounds().Bounds.Width, screenBounds().Bounds.Height));\r
@@ -154,7 +154,7 @@ namespace Handbrake
                 updateTextFromThread();\r
                 while (true)\r
                 {\r
-                    if (encodeHandler.isEncoding == true)\r
+                    if (encodeHandler.isEncoding)\r
                         updateTextFromThread();\r
                     else\r
                     {\r
@@ -186,14 +186,14 @@ namespace Handbrake
         {\r
             try\r
             {\r
-                string text = "";\r
+                string text;\r
                 List<string> data = readFile();\r
                 int count = data.Count;\r
 \r
                 while (position < count)\r
                 {\r
-                    text = data[position].ToString();\r
-                    if (data[position].ToString().Contains("has exited"))\r
+                    text = data[position];\r
+                    if (data[position].Contains("has exited"))\r
                         text = "\n ############ End of Log ############## \n";\r
                     position++;\r
 \r
@@ -217,15 +217,15 @@ namespace Handbrake
                 // InvokeRequired required compares the thread ID of the\r
                 // calling thread to the thread ID of the creating thread.\r
                 // If these threads are different, it returns true.\r
-                if (this.IsHandleCreated) // Make sure the windows has a handle before doing anything\r
+                if (IsHandleCreated) // Make sure the windows has a handle before doing anything\r
                 {\r
-                    if (this.rtf_actLog.InvokeRequired)\r
+                    if (rtf_actLog.InvokeRequired)\r
                     {\r
                         SetTextCallback d = new SetTextCallback(SetText);\r
-                        this.Invoke(d, new object[] { text });\r
+                        Invoke(d, new object[] { text });\r
                     }\r
                     else\r
-                        this.rtf_actLog.AppendText(text);\r
+                        rtf_actLog.AppendText(text);\r
                 }\r
             }\r
             catch (Exception exc)\r
@@ -264,7 +264,7 @@ namespace Handbrake
                 while (line != null)\r
                 {\r
                     if (line.Trim() != "")\r
-                        logData.Add(line + System.Environment.NewLine);\r
+                        logData.Add(line + Environment.NewLine);\r
 \r
                     line = sr.ReadLine();\r
                 }\r
@@ -275,7 +275,7 @@ namespace Handbrake
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("Error in readFile() \n Unable to read the log file.\n You may have to restart HandBrake.\n  Error Information: \n\n" + exc.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+                MessageBox.Show("Error in readFile() \n Unable to read the log file.\n You may have to restart HandBrake.\n  Error Information: \n\n" + exc, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
             }\r
             return null;\r
         }\r
@@ -312,14 +312,7 @@ namespace Handbrake
         #region System Information\r
         private struct MEMORYSTATUS\r
         {\r
-            public UInt32 dwLength;\r
-            public UInt32 dwMemoryLoad;\r
             public UInt32 dwTotalPhys; // Used\r
-            public UInt32 dwAvailPhys;\r
-            public UInt32 dwTotalPageFile;\r
-            public UInt32 dwAvailPageFile;\r
-            public UInt32 dwTotalVirtual;\r
-            public UInt32 dwAvailVirtual;\r
         }\r
 \r
         [DllImport("kernel32.dll")]\r
@@ -358,9 +351,9 @@ namespace Handbrake
         /// Get the System screen size information.\r
         /// </summary>\r
         /// <returns>System.Windows.Forms.Scree</returns>\r
-        public System.Windows.Forms.Screen screenBounds()\r
+        public Screen screenBounds()\r
         {\r
-            return System.Windows.Forms.Screen.PrimaryScreen;\r
+            return Screen.PrimaryScreen;\r
         }\r
 \r
         #endregion\r
index a4def19..00b288c 100644 (file)
@@ -29,7 +29,7 @@ namespace Handbrake
             if (check_pictureSettings.Checked)\r
                 pictureSettings = true;\r
 \r
-            if (presetCode.addPreset(txt_preset_name.Text.Trim(), query, pictureSettings) == true)\r
+            if (presetCode.addPreset(txt_preset_name.Text.Trim(), query, pictureSettings))\r
             {\r
                 frmMainWindow.loadPresetPanel();\r
                 this.Close();\r
index e055140..8b23df9 100644 (file)
@@ -15,7 +15,7 @@ namespace Handbrake
 {\r
     public partial class frmDownload : Form\r
     {\r
-        private Thread downloadThread;\r
+        private readonly Thread downloadThread;\r
         private Stream responceStream;\r
         private Stream loacalStream;\r
         private HttpWebRequest webRequest;\r
@@ -55,7 +55,7 @@ namespace Handbrake
                 responceStream = wcDownload.OpenRead(hbUpdate);\r
                 loacalStream = new FileStream(tempPath, FileMode.Create, FileAccess.Write, FileShare.None);\r
 \r
-                int bytesSize = 0;\r
+                int bytesSize;\r
                 byte[] downBuffer = new byte[2048];\r
 \r
                 long flength = 0;\r
@@ -63,16 +63,16 @@ namespace Handbrake
                 {\r
                     loacalStream.Write(downBuffer, 0, bytesSize);\r
                     flength = loacalStream.Length;\r
-                    this.Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { loacalStream.Length, fileSize });\r
+                    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
+                    Invoke(new DownloadFailedCallback(this.downloadFailed));\r
                 else\r
-                    this.Invoke(new DownloadCompleteCallback(this.downloadComplete));\r
+                    Invoke(new DownloadCompleteCallback(this.downloadComplete));\r
             }\r
             catch (Exception)\r
             {\r
@@ -91,7 +91,7 @@ namespace Handbrake
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("Integer Conversion Error On Download \n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                MessageBox.Show("Integer Conversion Error On Download \n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
         }\r
 \r
@@ -101,8 +101,7 @@ namespace Handbrake
             btn_cancel.Text = "Close";\r
 \r
             string tempPath = Path.Combine(Path.GetTempPath(), "handbrake-setup.exe");\r
-\r
-            Process startInstall = Process.Start(tempPath);\r
+            Process.Start(tempPath);\r
             this.Close();\r
             Application.Exit();\r
         }\r
index a7768a1..29a6213 100644 (file)
@@ -24,10 +24,8 @@ namespace Handbrake
 \r
         private void btn_play_Click(object sender, EventArgs e)\r
         {\r
-            String currently_playing;\r
-\r
             // Get the Destination of the sample video.\r
-            currently_playing = "";\r
+             String currently_playing = "";\r
             if (mainWindow.text_destination.Text != "")\r
                 currently_playing = mainWindow.text_destination.Text.Replace(".m", "_sample.m").Replace(".avi", "_sample.avi").Replace(".ogm", "_sample.ogm");\r
 \r
@@ -74,9 +72,9 @@ namespace Handbrake
         {\r
             try\r
             {\r
-                if (this.InvokeRequired)\r
+                if (InvokeRequired)\r
                 {\r
-                    this.BeginInvoke(new UpdateHandler(encodingMessage));\r
+                    BeginInvoke(new UpdateHandler(encodingMessage));\r
                     return;\r
                 }\r
                 lbl_status.Text = "Encoding, Please wait ...";\r
@@ -92,9 +90,9 @@ namespace Handbrake
         {\r
             try\r
             {\r
-                if (this.InvokeRequired)\r
+                if (InvokeRequired)\r
                 {\r
-                    this.BeginInvoke(new UpdateHandler(updateUIElements));\r
+                    BeginInvoke(new UpdateHandler(updateUIElements));\r
                     return;\r
                 }\r
 \r
index 3c9754c..44c7ac2 100644 (file)
@@ -36,8 +36,8 @@ namespace Handbrake
         private frmGenPreview vlcpreview;\r
         private frmPreview qtpreview;\r
         private string lastAction;\r
-        public int maxWidth = 0;\r
-        public int maxHeight = 0;\r
+        public int maxWidth;\r
+        public int maxHeight;\r
 \r
 \r
         Process hbproc;\r
@@ -144,14 +144,14 @@ namespace Handbrake
         {\r
             try\r
             {\r
-                if (this.InvokeRequired)\r
+                if (InvokeRequired)\r
                 {\r
-                    this.BeginInvoke(new updateStatusChanger(startupUpdateCheck));\r
+                    BeginInvoke(new updateStatusChanger(startupUpdateCheck));\r
                     return;\r
                 }\r
 \r
                 Boolean update = hb_common_func.updateCheck(false);\r
-                if (update == true)\r
+                if (update)\r
                 {\r
                     frmUpdater updateWindow = new frmUpdater();\r
                     updateWindow.Show();\r
@@ -161,7 +161,7 @@ namespace Handbrake
         }\r
         private void queueRecovery()\r
         {\r
-            if (hb_common_func.check_queue_recovery() == true)\r
+            if (hb_common_func.check_queue_recovery())\r
             {\r
                 DialogResult 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
@@ -227,7 +227,7 @@ namespace Handbrake
         }\r
         private void mnu_encodeLog_Click(object sender, EventArgs e)\r
         {\r
-            String file = String.Empty;\r
+            String file;\r
             if (lastAction == "scan")\r
                 file = "dvdinfo.dat";\r
             else\r
@@ -258,7 +258,7 @@ namespace Handbrake
         private void mnu_delete_preset_Click(object sender, EventArgs e)\r
         {\r
             // Empty the preset file\r
-            string presetsFile = Application.StartupPath.ToString() + "\\presets.xml";\r
+            string presetsFile = Application.StartupPath + "\\presets.xml";\r
             if (File.Exists(presetsFile))\r
                 File.Delete(presetsFile);\r
 \r
@@ -270,7 +270,7 @@ namespace Handbrake
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("An error has occured during the preset removal process.\n If you are using Windows Vista, you may need to run under Administrator Mode to complete this task. \n" + exc.ToString());\r
+                MessageBox.Show("An error has occured during the preset removal process.\n If you are using Windows Vista, you may need to run under Administrator Mode to complete this task. \n" + exc);\r
             }\r
 \r
             // Reload the preset panel\r
@@ -487,7 +487,7 @@ namespace Handbrake
                     int i = 0;\r
                     foreach (TreeNode node in treeView_presets.Nodes)\r
                     {\r
-                        if (nodeStatus[i] == true)\r
+                        if (nodeStatus[i])\r
                             node.Expand();\r
 \r
                         i++;\r
@@ -513,12 +513,12 @@ namespace Handbrake
             int i = 0;\r
             foreach (TreeNode node in treeView_presets.Nodes)\r
             {\r
-                if (nodeStatus[i] == true)\r
+                if (nodeStatus[i])\r
                     node.Expand();\r
 \r
                 foreach (TreeNode subNode in node.Nodes)\r
                 {\r
-                    if (nodeStatus[i] == true)\r
+                    if (nodeStatus[i])\r
                         subNode.Expand();\r
                 }\r
 \r
@@ -533,7 +533,7 @@ namespace Handbrake
             {\r
                 foreach (TreeNode node in treenode.Nodes)\r
                 {\r
-                    if (node.Text.ToString().Equals("Normal"))\r
+                    if (node.Text.Equals("Normal"))\r
                         treeView_presets.SelectedNode = treeView_presets.Nodes[treenode.Index].Nodes[0];\r
                 }\r
             }\r
@@ -584,11 +584,7 @@ namespace Handbrake
                     // This is used for tracking which file to load in the activity window\r
                     lastAction = "encode";\r
 \r
-                    String query;\r
-                    if (rtf_query.Text != "")\r
-                        query = rtf_query.Text;\r
-                    else\r
-                        query = queryGen.GenerateTheQuery(this);\r
+                    String query = rtf_query.Text != "" ? rtf_query.Text : queryGen.GenerateTheQuery(this);\r
 \r
                     if (encodeQueue.count() == 0)\r
                     {\r
@@ -672,13 +668,7 @@ namespace Handbrake
         }\r
         private void btn_ActivityWindow_Click(object sender, EventArgs e)\r
         {\r
-\r
-\r
-            String file = String.Empty;\r
-            if (lastAction == "scan")\r
-                file = "dvdinfo.dat";\r
-            else\r
-                file = "hb_encode_log.dat";\r
+            String file = lastAction == "scan" ? "dvdinfo.dat" : "hb_encode_log.dat";\r
 \r
             frmActivityWindow ActivityWindow = new frmActivityWindow(file, encodeHandler);\r
             ActivityWindow.Show();\r
@@ -691,10 +681,7 @@ namespace Handbrake
             if (FormWindowState.Minimized == this.WindowState)\r
             {\r
                 notifyIcon.Visible = true;\r
-                if (lbl_encode.Text != "")\r
-                    notifyIcon.BalloonTipText = lbl_encode.Text;\r
-                else\r
-                    notifyIcon.BalloonTipText = "Not Encoding";\r
+                notifyIcon.BalloonTipText = lbl_encode.Text != "" ? lbl_encode.Text : "Not Encoding";\r
                 notifyIcon.ShowBalloonTip(500);\r
                 this.Hide();\r
             }\r
@@ -729,7 +716,7 @@ namespace Handbrake
             // This is used for tracking which file to load in the activity window\r
             lastAction = "scan";\r
 \r
-            String filename = "";\r
+            String filename;\r
             text_source.Text = "";\r
 \r
             DVD_Open.ShowDialog();\r
@@ -754,7 +741,7 @@ namespace Handbrake
             // This is used for tracking which file to load in the activity window\r
             lastAction = "scan";\r
 \r
-            String filename = "";\r
+            String filename;\r
             text_source.Text = "";\r
 \r
             ISO_Open.ShowDialog();\r
@@ -782,11 +769,10 @@ namespace Handbrake
             // This is used for tracking which file to load in the activity window\r
             lastAction = "scan";\r
 \r
-            String filename = "";\r
             if (mnu_dvd_drive.Text.Contains("VIDEO_TS"))\r
             {\r
                 string[] path = mnu_dvd_drive.Text.Split(' ');\r
-                filename = path[0];\r
+                String filename = path[0];\r
                 setupGUIforScan(filename);\r
                 startScan(filename);\r
             }\r
@@ -872,7 +858,7 @@ namespace Handbrake
         }\r
         private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)\r
         {\r
-            int c_start, c_end = 1;\r
+            int c_start, c_end;\r
 \r
             if (drop_chapterFinish.Text == "Auto" && drop_chapterFinish.Items.Count != 0)\r
                 drop_chapterFinish.SelectedIndex = drop_chapterFinish.Items.Count - 1;\r
@@ -895,7 +881,7 @@ namespace Handbrake
         }\r
         private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)\r
         {\r
-            int c_start, c_end = 1;\r
+            int c_start, c_end;\r
 \r
             if (drop_chapterStart.Text == "Auto" && drop_chapterStart.Items.Count >= 1)\r
                 drop_chapterStart.SelectedIndex = 1;\r
@@ -914,7 +900,7 @@ namespace Handbrake
             // Run the Autonaming function\r
             if (Properties.Settings.Default.autoNaming == "Checked")\r
                 text_destination.Text = hb_common_func.autoName(drp_dvdtitle, drop_chapterStart.Text, drop_chapterFinish.Text, text_source.Text, text_destination.Text, drop_format.SelectedIndex);\r
-        \r
+\r
             // Add more rows to the Chapter menu if needed.\r
             if (Check_ChapterMarkers.Checked)\r
             {\r
@@ -928,8 +914,8 @@ namespace Handbrake
                     int n = data_chpt.Rows.Add();\r
                     data_chpt.Rows[n].Cells[0].Value = (i + 1);\r
                     data_chpt.Rows[n].Cells[1].Value = "Chapter " + (i + 1);\r
-                    data_chpt.Rows[n].Cells[0].ValueType = typeof (int);\r
-                    data_chpt.Rows[n].Cells[1].ValueType = typeof (string);\r
+                    data_chpt.Rows[n].Cells[0].ValueType = typeof(int);\r
+                    data_chpt.Rows[n].Cells[1].ValueType = typeof(string);\r
                     i++;\r
                 }\r
             }\r
@@ -1072,7 +1058,7 @@ namespace Handbrake
         }\r
         private void slider_videoQuality_Scroll(object sender, EventArgs e)\r
         {\r
-            SliderValue.Text = slider_videoQuality.Value.ToString() + "%";\r
+            SliderValue.Text = slider_videoQuality.Value + "%";\r
             text_bitrate.Text = "";\r
             text_filesize.Text = "";\r
             check_2PassEncode.Enabled = false;\r
@@ -1102,13 +1088,9 @@ namespace Handbrake
 \r
             int width;\r
             Boolean parsed = int.TryParse(text_width.Text, out width);\r
-            if (parsed != false)\r
+            if (parsed)\r
             {\r
-                if ((width % 16) != 0)\r
-                    text_width.BackColor = Color.LightCoral;\r
-                else\r
-                    text_width.BackColor = Color.LightGreen;\r
-\r
+                text_width.BackColor = (width % 16) != 0 ? Color.LightCoral : Color.LightGreen;\r
 \r
                 if (lbl_Aspect.Text != "Select a Title" && maxWidth == 0 && maxHeight == 0)\r
                 {\r
@@ -1130,13 +1112,8 @@ namespace Handbrake
 \r
             int height;\r
             Boolean parsed = int.TryParse(text_height.Text, out height);\r
-            if (parsed != false)\r
-            {\r
-                if ((height % 16) != 0)\r
-                    text_height.BackColor = Color.LightCoral;\r
-                else\r
-                    text_height.BackColor = Color.LightGreen;\r
-            }\r
+            if (parsed)\r
+                text_height.BackColor = (height % 16) != 0 ? Color.LightCoral : Color.LightGreen;\r
         }\r
         private void check_customCrop_CheckedChanged(object sender, EventArgs e)\r
         {\r
@@ -1198,10 +1175,7 @@ namespace Handbrake
         }\r
         private void slider_deblock_Scroll(object sender, EventArgs e)\r
         {\r
-            if (slider_deblock.Value == 4)\r
-                lbl_deblockVal.Text = "Off";\r
-            else\r
-                lbl_deblockVal.Text = slider_deblock.Value.ToString();\r
+            lbl_deblockVal.Text = slider_deblock.Value == 4 ? "Off" : slider_deblock.Value.ToString();\r
         }\r
 \r
         //Audio Tab\r
@@ -1393,7 +1367,7 @@ namespace Handbrake
                 drp_audmix_1.Text = lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[2].Text;\r
                 drp_audsr_1.Text = lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[3].Text;\r
                 drp_audbit_1.Text = lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[4].Text;\r
-                double drcValue = 0; int drcCalculated = 0;\r
+                double drcValue; int drcCalculated;\r
                 double.TryParse(lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[5].Text, out drcValue);\r
                 drcValue = (drcValue * 10) - 10;\r
                 int.TryParse(drcValue.ToString(), out drcCalculated);\r
@@ -1567,7 +1541,7 @@ namespace Handbrake
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("frmMain.cs - startScan " + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                MessageBox.Show("frmMain.cs - startScan " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
         }\r
         private void scanProcess(object state)\r
@@ -1608,7 +1582,7 @@ namespace Handbrake
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("frmMain.cs - scanProcess() " + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                MessageBox.Show("frmMain.cs - scanProcess() " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
                 enableGUI();\r
             }\r
         }\r
@@ -1718,9 +1692,9 @@ namespace Handbrake
         {\r
             try\r
             {\r
-                if (this.InvokeRequired)\r
+                if (InvokeRequired)\r
                 {\r
-                    this.BeginInvoke(new ProgressUpdateHandler(getDriveInfoThread));\r
+                    BeginInvoke(new ProgressUpdateHandler(getDriveInfoThread));\r
                     return;\r
                 }\r
 \r
@@ -1732,8 +1706,8 @@ namespace Handbrake
                     {\r
                         if (curDrive.IsReady)\r
                         {\r
-                            if (File.Exists(curDrive.RootDirectory.ToString() + "VIDEO_TS\\VIDEO_TS.IFO"))\r
-                                mnu_dvd_drive.Text = curDrive.RootDirectory.ToString() + "VIDEO_TS (" + curDrive.VolumeLabel + ")";\r
+                            if (File.Exists(curDrive.RootDirectory + "VIDEO_TS\\VIDEO_TS.IFO"))\r
+                                mnu_dvd_drive.Text = curDrive.RootDirectory + "VIDEO_TS (" + curDrive.VolumeLabel + ")";\r
                             else\r
                                 mnu_dvd_drive.Text = "[No DVD Drive Ready]";\r
 \r
@@ -1756,7 +1730,7 @@ namespace Handbrake
         #region Audio Panel Code Helpers\r
         private void setAudioByContainer(String path)\r
         {\r
-            string oldval = "";\r
+            string oldval;\r
 \r
             if ((path.EndsWith(".mp4")) || (path.EndsWith(".m4v")))\r
             {\r
@@ -1798,7 +1772,7 @@ namespace Handbrake
         }\r
         private void setVideoByContainer(String path)\r
         {\r
-            string oldval = "";\r
+            string oldval;\r
 \r
             if ((path.EndsWith(".mp4")) || (path.EndsWith(".m4v")))\r
             {\r
@@ -1917,33 +1891,6 @@ namespace Handbrake
             dropdown.Items.Add("Dolby Surround");\r
             dropdown.Items.Add("Dolby Pro Logic II");\r
         }\r
-        private void audioEncoderChange(ComboBox audenc, ComboBox audMix, ComboBox audbit, ComboBox audsr)\r
-        {\r
-            if (audenc.Text == "AC3")\r
-            {\r
-                audMix.Enabled = false;\r
-                audbit.Enabled = false;\r
-                audsr.Enabled = false;\r
-\r
-                audMix.Text = "Automatic";\r
-                audbit.Text = "160";\r
-                audsr.Text = "Auto";\r
-            }\r
-            else\r
-            {\r
-                // Just make sure not to re-enable the following boxes if the track above is none\r
-                /* if (drp_track2Audio.Text != "None")\r
-                 {\r
-                     audMix.Enabled = true;\r
-                     audbit.Enabled = true;\r
-                     audsr.Enabled = true;\r
-\r
-                     audMix.Text = "Automatic";\r
-                     audbit.Text = "160";\r
-                     audsr.Text = "Auto";\r
-                 }*/\r
-            }\r
-        }\r
         #endregion\r
 \r
         #region Public Methods\r
@@ -1953,14 +1900,13 @@ namespace Handbrake
         /// 1 = Encode Running\r
         /// 0 = Encode Finished.\r
         /// </summary>\r
-        /// <param name="i">Int</param>\r
         public void setEncodeFinished()\r
         {\r
             try\r
             {\r
-                if (this.InvokeRequired)\r
+                if (InvokeRequired)\r
                 {\r
-                    this.BeginInvoke(new UpdateWindowHandler(setEncodeFinished));\r
+                    BeginInvoke(new UpdateWindowHandler(setEncodeFinished));\r
                     return;\r
                 }\r
 \r
@@ -1975,7 +1921,6 @@ namespace Handbrake
                     notifyIcon.BalloonTipText = lbl_encode.Text;\r
                     notifyIcon.ShowBalloonTip(500);\r
                 }\r
-\r
             }\r
             catch (Exception exc)\r
             {\r
@@ -1986,9 +1931,9 @@ namespace Handbrake
         {\r
             try\r
             {\r
-                if (this.InvokeRequired)\r
+                if (InvokeRequired)\r
                 {\r
-                    this.BeginInvoke(new UpdateWindowHandler(setEncodeStarted));\r
+                    BeginInvoke(new UpdateWindowHandler(setEncodeStarted));\r
                     return;\r
                 }\r
 \r
@@ -2033,13 +1978,13 @@ namespace Handbrake
 \r
             treeView_presets.Nodes.Clear();\r
 \r
-            List<Presets.Preset> presetNameList = new List<Presets.Preset>();\r
-            List<string> presetNames = new List<string>();\r
-            TreeNode preset_treeview = new TreeNode();\r
+            List<Presets.Preset> presetNameList;\r
+            List<string> presetNames;\r
+            TreeNode preset_treeview;\r
 \r
             TreeNode rootNode = new TreeNode();\r
             TreeNode rootNodeTwo = new TreeNode();\r
-            TreeNode childNode = new TreeNode();\r
+            TreeNode childNode;\r
             int workingLevel = 0;\r
             string previousCategory = String.Empty;\r
             string currentCategory = String.Empty;\r
index dae22fe..e56dbe7 100644 (file)
@@ -205,7 +205,7 @@ namespace Handbrake
         private void check_saveLogWithVideo_CheckedChanged(object sender, EventArgs e)\r
         {\r
             Properties.Settings.Default.saveLogWithVideo = check_saveLogWithVideo.CheckState.ToString();\r
-            if (check_saveLogWithVideo.Checked == true)\r
+            if (check_saveLogWithVideo.Checked)\r
                 text_logPath.Text = "";\r
         }\r
 \r
index e00bcd9..029ac85 100644 (file)
@@ -28,8 +28,7 @@ namespace Handbrake
 \r
         private void play()\r
         {\r
-            player = new Thread(OpenMovie);\r
-            player.IsBackground = true;\r
+            player = new Thread(OpenMovie) {IsBackground = true};\r
             player.Start();\r
         }\r
 \r
@@ -38,9 +37,9 @@ namespace Handbrake
         {\r
             try\r
             {\r
-                if (this.InvokeRequired)\r
+                if (InvokeRequired)\r
                 {\r
-                    this.BeginInvoke(new UpdateUIHandler(OpenMovie));\r
+                    BeginInvoke(new UpdateUIHandler(OpenMovie));\r
                     return;\r
                 }\r
                 QTControl.URL = currently_playing;\r
@@ -59,11 +58,11 @@ namespace Handbrake
             catch (COMException ex)\r
             {\r
                 QTUtils qtu = new QTUtils();\r
-                MessageBox.Show("Unable to open movie:\n\nError Code: " + ex.ErrorCode.ToString("X") + "\nQT Error code : " + qtu.QTErrorFromErrorCode(ex.ErrorCode).ToString());\r
+                MessageBox.Show("Unable to open movie:\n\nError Code: " + ex.ErrorCode.ToString("X") + "\nQT Error code : " + qtu.QTErrorFromErrorCode(ex.ErrorCode));\r
             }\r
             catch (Exception ex)\r
             {\r
-                MessageBox.Show("Unable to open movie:\n\n" + ex.ToString());\r
+                MessageBox.Show("Unable to open movie:\n\n" + ex);\r
             }\r
         }\r
  \r
@@ -92,9 +91,9 @@ namespace Handbrake
         {\r
             try\r
             {\r
-                if (this.InvokeRequired)\r
+                if (InvokeRequired)\r
                 {\r
-                    this.BeginInvoke(new UpdateUIHandler(encodeCompleted));\r
+                    BeginInvoke(new UpdateUIHandler(encodeCompleted));\r
                     return;\r
                 }\r
                 btn_encode.Enabled = true;\r
@@ -108,7 +107,7 @@ namespace Handbrake
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("frmPreview.cs encodeCompleted " + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                MessageBox.Show("frmPreview.cs encodeCompleted " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
         }\r
         #endregion\r
index 1a9f30c..36e8b06 100644 (file)
@@ -45,7 +45,6 @@ namespace Handbrake
         /// <summary>\r
         /// Initializes the Queue list with the Arraylist from the Queue class\r
         /// </summary>\r
-        /// <param name="qw"></param>\r
         public void setQueue()\r
         {\r
             updateUIElements();\r
@@ -54,7 +53,7 @@ namespace Handbrake
         // Start and Stop Controls\r
         private void btn_encode_Click(object sender, EventArgs e)\r
         {\r
-            if (queue.isPaused == true)\r
+            if (queue.isPaused)\r
             {\r
                 setUIEncodeStarted();\r
                 MessageBox.Show("Encoding restarted", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
@@ -75,9 +74,9 @@ namespace Handbrake
         // Window Display Management\r
         private void setUIEncodeStarted()\r
         {\r
-            if (this.InvokeRequired)\r
+            if (InvokeRequired)\r
             {\r
-                this.BeginInvoke(new UpdateHandler(setUIEncodeStarted));\r
+                BeginInvoke(new UpdateHandler(setUIEncodeStarted));\r
                 return;\r
             }\r
             btn_encode.Enabled = false;\r
@@ -85,9 +84,9 @@ namespace Handbrake
         }\r
         private void setUIEncodeFinished()\r
         {\r
-            if (this.InvokeRequired)\r
+            if (InvokeRequired)\r
             {\r
-                this.BeginInvoke(new UpdateHandler(setUIEncodeFinished));\r
+                BeginInvoke(new UpdateHandler(setUIEncodeFinished));\r
                 return;\r
             }\r
             btn_pause.Visible = false;\r
@@ -95,9 +94,9 @@ namespace Handbrake
         }\r
         private void resetQueue()\r
         {\r
-            if (this.InvokeRequired)\r
+            if (InvokeRequired)\r
             {\r
-                this.BeginInvoke(new UpdateHandler(resetQueue));\r
+                BeginInvoke(new UpdateHandler(resetQueue));\r
                 return;\r
             }\r
             btn_pause.Visible = false;\r
@@ -114,9 +113,9 @@ namespace Handbrake
         }\r
         private void redrawQueue()\r
         {\r
-            if (this.InvokeRequired)\r
+            if (InvokeRequired)\r
             {\r
-                this.BeginInvoke(new UpdateHandler(redrawQueue));\r
+                BeginInvoke(new UpdateHandler(redrawQueue));\r
                 return;\r
             }\r
 \r
@@ -128,14 +127,10 @@ namespace Handbrake
                 Functions.QueryParser parsed = Functions.QueryParser.Parse(q_item);\r
 \r
                 // Get the DVD Title\r
-                string title = "";\r
-                if (parsed.DVDTitle == 0)\r
-                    title = "Auto";\r
-                else\r
-                    title = parsed.DVDTitle.ToString();\r
+                 string title = parsed.DVDTitle == 0 ? "Auto" : parsed.DVDTitle.ToString();\r
 \r
                 // Get the DVD Chapters\r
-                string chapters = "";\r
+                string chapters;\r
                 if (parsed.DVDChapterStart == 0)\r
                     chapters = "Auto";\r
                 else\r
@@ -158,9 +153,9 @@ namespace Handbrake
         }\r
         private void updateUIElements()\r
         {\r
-            if (this.InvokeRequired)\r
+            if (InvokeRequired)\r
             {\r
-                this.BeginInvoke(new UpdateHandler(updateUIElements));\r
+                BeginInvoke(new UpdateHandler(updateUIElements));\r
                 return;\r
             }\r
 \r
@@ -171,9 +166,9 @@ namespace Handbrake
         {\r
             try\r
             {\r
-                if (this.InvokeRequired)\r
+                if (InvokeRequired)\r
                 {\r
-                    this.BeginInvoke(new UpdateHandler(setCurrentEncodeInformation));\r
+                    BeginInvoke(new UpdateHandler(setCurrentEncodeInformation));\r
                 }\r
 \r
                 // found query is a global varible\r
@@ -181,19 +176,13 @@ namespace Handbrake
                 lbl_source.Text = queue.getLastQueryItem().Source;\r
                 lbl_dest.Text = queue.getLastQueryItem().Destination;\r
 \r
-                if (parsed.DVDTitle == 0)\r
-                    lbl_title.Text = "Auto";\r
-                else\r
-                    lbl_title.Text = parsed.DVDTitle.ToString();\r
+                lbl_title.Text = parsed.DVDTitle == 0 ? "Auto" : parsed.DVDTitle.ToString();\r
 \r
-                string chapters = "";\r
-                if (parsed.DVDChapterStart == 0)\r
-                {\r
-                    lbl_chapt.Text = "Auto";\r
-                }\r
+                if (Equals(parsed.DVDChapterStart, 0))\r
+                  lbl_chapt.Text = "Auto";\r
                 else\r
                 {\r
-                    chapters = parsed.DVDChapterStart.ToString();\r
+                    string chapters = parsed.DVDChapterStart.ToString();\r
                     if (parsed.DVDChapterFinish != 0)\r
                         chapters = chapters + " - " + parsed.DVDChapterFinish;\r
                     lbl_chapt.Text = chapters;\r