OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 3 Aug 2009 15:26:14 +0000 (15:26 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 3 Aug 2009 15:26:14 +0000 (15:26 +0000)
- Mostly just code re-factoring.

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

win/C#/Functions/QueryGenerator.cs
win/C#/frmMain.Designer.cs
win/C#/frmMain.cs
win/C#/frmOptions.Designer.cs
win/C#/frmOptions.resx
win/C#/frmPreview.cs

index 248ee18..42b9625 100644 (file)
@@ -15,13 +15,14 @@ namespace Handbrake.Functions
     class QueryGenerator\r
     {\r
         /// <summary>\r
-        /// Generates a CLI query based on the GUI widgets.\r
+        /// Generates a full CLI query for either encoding or previe encoeds if duration and preview are defined.\r
         /// </summary>\r
         /// <param name="mainWindow"></param>\r
-        /// <returns>The CLI String</returns>\r
-        public string generateTheQuery(frmMain mainWindow)\r
+        /// <param name="duration"></param>\r
+        /// <param name="preview"></param>\r
+        /// <returns></returns>\r
+        public string generateCLIQuery(frmMain mainWindow, int duration, string preview)\r
         {\r
-            // Source tab\r
             string query = "";\r
 \r
             if (!string.IsNullOrEmpty(mainWindow.sourcePath))\r
@@ -38,58 +39,30 @@ namespace Handbrake.Functions
                 if (mainWindow.drop_angle.Items.Count != 0)\r
                     query += " --angle " + mainWindow.drop_angle.SelectedItem;\r
 \r
-            if (mainWindow.drop_chapterFinish.Text == mainWindow.drop_chapterStart.Text && mainWindow.drop_chapterStart.Text != "")\r
-                query += " -c " + mainWindow.drop_chapterStart.Text;\r
-            else if (mainWindow.drop_chapterStart.Text == "Auto" && mainWindow.drop_chapterFinish.Text != "Auto")\r
-                query += " -c " + "0-" + mainWindow.drop_chapterFinish.Text;\r
-            else if (mainWindow.drop_chapterStart.Text != "Auto" && mainWindow.drop_chapterFinish.Text != "Auto" && mainWindow.drop_chapterStart.Text != "")\r
-                query += " -c " + mainWindow.drop_chapterStart.Text + "-" + mainWindow.drop_chapterFinish.Text;\r
-\r
-            // Destination tab\r
-            if (mainWindow.text_destination.Text != "")\r
-                query += " -o " + '"' + mainWindow.text_destination.Text + '"';\r
-\r
-            query += generateTabbedComponentsQuery(mainWindow);\r
-            return query;\r
-        }\r
-\r
-        /// <summary>\r
-        /// Generates a CLI query for the preview function.\r
-        /// This basically forces a shortened version of the encdode.\r
-        /// </summary>\r
-        /// <param name="mainWindow"></param>\r
-        /// <param name="duration">Duration</param>\r
-        /// <param name="preview">Start at preview</param>\r
-        /// <returns>Returns a CLI query String.</returns>\r
-        public string generatePreviewQuery(frmMain mainWindow, string duration, string preview)\r
-        {\r
-            int seconds;\r
-            int.TryParse(duration, out seconds);\r
-\r
-            // Source tab\r
-            string query = "";\r
 \r
-            if (!string.IsNullOrEmpty(mainWindow.sourcePath))\r
-                if (mainWindow.sourcePath.Trim() != "Select \"Source\" to continue")\r
-                    query = " -i " + '"' + mainWindow.sourcePath + '"';\r
+            if (duration != 0 && preview != null) // Preivew Query\r
+            {\r
+                query += " --start-at-preview " + preview;\r
+                query += " --stop-at duration:" + duration + " ";\r
 \r
-            if (mainWindow.drp_dvdtitle.Text != "Automatic")\r
+                if (mainWindow.text_destination.Text != "")\r
+                    query += " -o " + '"' + mainWindow.text_destination.Text.Replace(".m", "_sample.m") + '"';\r
+            }\r
+            else // Non Preview Query\r
             {\r
-                string[] titleInfo = mainWindow.drp_dvdtitle.Text.Split(' ');\r
-                query += " -t " + titleInfo[0];\r
+                if (mainWindow.drop_chapterFinish.Text == mainWindow.drop_chapterStart.Text && mainWindow.drop_chapterStart.Text != "")\r
+                    query += " -c " + mainWindow.drop_chapterStart.Text;\r
+                else if (mainWindow.drop_chapterStart.Text == "Auto" && mainWindow.drop_chapterFinish.Text != "Auto")\r
+                    query += " -c " + "0-" + mainWindow.drop_chapterFinish.Text;\r
+                else if (mainWindow.drop_chapterStart.Text != "Auto" && mainWindow.drop_chapterFinish.Text != "Auto" && mainWindow.drop_chapterStart.Text != "")\r
+                    query += " -c " + mainWindow.drop_chapterStart.Text + "-" + mainWindow.drop_chapterFinish.Text;\r
+\r
+                if (mainWindow.text_destination.Text != "")\r
+                    query += " -o " + '"' + mainWindow.text_destination.Text + '"';\r
             }\r
 \r
-            if (mainWindow.drop_angle.SelectedIndex != 0)\r
-                query += " --angle " + mainWindow.drop_angle.SelectedItem;\r
-\r
-            query += " --start-at-preview " + preview;\r
-            query += " --stop-at duration:" + duration + " ";\r
-\r
-            // Destination tab\r
-            if (mainWindow.text_destination.Text != "")\r
-                query += " -o " + '"' + mainWindow.text_destination.Text.Replace(".m", "_sample.m") + '"';\r
-\r
             query += generateTabbedComponentsQuery(mainWindow);\r
+\r
             return query;\r
         }\r
 \r
@@ -606,7 +579,6 @@ namespace Handbrake.Functions
                 file.Close();\r
                 file.Dispose();\r
                 return true;\r
-\r
             }\r
             catch (Exception exc)\r
             {\r
index 0ecb055..cca4514 100644 (file)
@@ -463,7 +463,7 @@ namespace Handbrake
             this.drop_chapterFinish.Size = new System.Drawing.Size(69, 21);\r
             this.drop_chapterFinish.TabIndex = 10;\r
             this.ToolTip.SetToolTip(this.drop_chapterFinish, "Select the chapter range you would like to enocde. (default: All Chapters)");\r
-            this.drop_chapterFinish.SelectedIndexChanged += new System.EventHandler(this.drop_chapterFinish_SelectedIndexChanged);\r
+            this.drop_chapterFinish.SelectedIndexChanged += new System.EventHandler(this.chapersChanged);\r
             // \r
             // drop_chapterStart\r
             // \r
@@ -474,7 +474,7 @@ namespace Handbrake
             this.drop_chapterStart.Size = new System.Drawing.Size(69, 21);\r
             this.drop_chapterStart.TabIndex = 9;\r
             this.ToolTip.SetToolTip(this.drop_chapterStart, "Select the chapter range you would like to enocde. (default: All Chapters)");\r
-            this.drop_chapterStart.SelectedIndexChanged += new System.EventHandler(this.drop_chapterStart_SelectedIndexChanged);\r
+            this.drop_chapterStart.SelectedIndexChanged += new System.EventHandler(this.chapersChanged);\r
             // \r
             // drop_angle\r
             // \r
index a28597c..b6b156c 100644 (file)
@@ -286,10 +286,7 @@ namespace Handbrake
                 else\r
                 {\r
                     if (fileList[0] != "")\r
-                    {\r
-                        setupGUIforScan(fileList[0]);\r
                         startScan(fileList[0]);\r
-                    }\r
                     else\r
                         UpdateSourceLabel();\r
                 }\r
@@ -380,21 +377,21 @@ namespace Handbrake
                 QueryParser parsed = imp.importMacPreset(openPreset.FileName);\r
                 if (presetHandler.checkIfUserPresetExists(parsed.PresetName + " (Imported)"))\r
                 {\r
-                    DialogResult result = MessageBox.Show("This preset appears to already exist. Would you like to overwrite it?", "Overwrite preset?", \r
+                    DialogResult result = MessageBox.Show("This preset appears to already exist. Would you like to overwrite it?", "Overwrite preset?",\r
                                                            MessageBoxButtons.YesNo, MessageBoxIcon.Warning);\r
                     if (result == DialogResult.Yes)\r
                     {\r
                         PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);\r
-                        presetHandler.updatePreset(parsed.PresetName + " (Imported)", queryGen.generateTheQuery(this),\r
+                        presetHandler.updatePreset(parsed.PresetName + " (Imported)", queryGen.generateCLIQuery(this, 0, null),\r
                                                    parsed.UsesPictureSettings);\r
                     }\r
                 }\r
                 else\r
                 {\r
                     PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);\r
-                    presetHandler.addPreset(parsed.PresetName, queryGen.generateTheQuery(this), parsed.UsesPictureSettings);\r
+                    presetHandler.addPreset(parsed.PresetName, queryGen.generateCLIQuery(this, 0, null), parsed.UsesPictureSettings);\r
 \r
-                    if (presetHandler.addPreset(parsed.PresetName + " (Imported)", queryGen.generateTheQuery(this), parsed.UsesPictureSettings))\r
+                    if (presetHandler.addPreset(parsed.PresetName + " (Imported)", queryGen.generateCLIQuery(this, 0, null), parsed.UsesPictureSettings))\r
                     {\r
                         TreeNode preset_treeview = new TreeNode(parsed.PresetName + " (Imported)") { ForeColor = Color.Black };\r
                         treeView_presets.Nodes.Add(preset_treeview);\r
@@ -404,7 +401,7 @@ namespace Handbrake
         }\r
         private void btn_new_preset_Click(object sender, EventArgs e)\r
         {\r
-            Form preset = new frmAddPreset(this, queryGen.generateTheQuery(this), presetHandler);\r
+            Form preset = new frmAddPreset(this, queryGen.generateCLIQuery(this, 0, null), presetHandler);\r
             preset.ShowDialog();\r
         }\r
         #endregion\r
@@ -440,7 +437,7 @@ namespace Handbrake
             {\r
                 // Get the information about the new build, if any, and close the window\r
                 info = Main.EndCheckForUpdates(result);\r
-                \r
+\r
                 if (info.NewVersionAvailable && info.BuildInformation != null)\r
                 {\r
                     frmUpdater updateWindow = new frmUpdater(info.BuildInformation);\r
@@ -666,8 +663,8 @@ namespace Handbrake
             {\r
                 if (encodeQueue.Count != 0 || (!string.IsNullOrEmpty(sourcePath) && !string.IsNullOrEmpty(text_destination.Text)))\r
                 {\r
-                    string generatedQuery = queryGen.generateTheQuery(this);\r
-                    string specifiedQuery = rtf_query.Text != "" ? rtf_query.Text : queryGen.generateTheQuery(this);\r
+                    string generatedQuery = queryGen.generateCLIQuery(this, 0, null);\r
+                    string specifiedQuery = rtf_query.Text != "" ? rtf_query.Text : queryGen.generateCLIQuery(this, 0, null);\r
                     string query = string.Empty;\r
 \r
                     // Check to make sure the generated query matches the GUI settings\r
@@ -735,7 +732,7 @@ namespace Handbrake
                 MessageBox.Show("No source or destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
             else\r
             {\r
-                String query = queryGen.generateTheQuery(this);\r
+                String query = queryGen.generateCLIQuery(this, 0, null);\r
                 if (rtf_query.Text != "")\r
                     query = rtf_query.Text;\r
 \r
@@ -782,7 +779,7 @@ namespace Handbrake
             String file = lastAction == "scan" ? "last_scan_log.txt" : "last_encode_log.txt";\r
             if (ActivityWindow == null)\r
                 ActivityWindow = new frmActivityWindow(file, encodeQueue, this);\r
-            \r
+\r
             ActivityWindow.Show();\r
         }\r
         #endregion\r
@@ -819,92 +816,57 @@ namespace Handbrake
         //Source\r
         private void btn_dvd_source_Click(object sender, EventArgs e)\r
         {\r
-            // Enable the creation of chapter markers.\r
-            Check_ChapterMarkers.Enabled = true;\r
-\r
-            // Set the last action to scan. \r
-            // This is used for tracking which file to load in the activity window\r
-            lastAction = "scan";\r
-            sourcePath = string.Empty;\r
-\r
             if (DVD_Open.ShowDialog() == DialogResult.OK)\r
-            {\r
-                String filename = DVD_Open.SelectedPath;\r
-\r
-                if (filename.StartsWith("\\"))\r
-                {\r
-                    MessageBox.Show(\r
-                        "Sorry, HandBrake does not support UNC file paths. \nTry mounting the share as a network drive in My Computer",\r
-                        "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
-                    UpdateSourceLabel();\r
-                }\r
-                else\r
-                {\r
-                    if (filename != "")\r
-                    {\r
-                        sourcePath = Path.GetFullPath(filename);\r
-                        setupGUIforScan(filename);\r
-                        startScan(filename);\r
-                    } else\r
-                        UpdateSourceLabel();\r
-                }\r
-            }\r
+                selectSource(DVD_Open.SelectedPath, 1);\r
             else\r
                 UpdateSourceLabel();\r
         }\r
         private void btn_file_source_Click(object sender, EventArgs e)\r
         {\r
-            // Set the last action to scan. \r
-            // This is used for tracking which file to load in the activity window\r
-            lastAction = "scan";\r
-            sourcePath = string.Empty;\r
-\r
             if (ISO_Open.ShowDialog() == DialogResult.OK)\r
-            {\r
-                String filename = ISO_Open.FileName;\r
-                if (filename.StartsWith("\\"))\r
-                    MessageBox.Show(\r
-                        "Sorry, HandBrake does not support UNC file paths. \nTry mounting the share as a network drive in My Computer",\r
-                        "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
-                else\r
-                {\r
-                    if (filename != "")\r
-                    {\r
-                        sourcePath = Path.GetFileName(filename);\r
-                        setupGUIforScan(filename);\r
-                        startScan(filename);\r
-                    } else\r
-                        UpdateSourceLabel();\r
-                }\r
-            }\r
-            UpdateSourceLabel();\r
+                selectSource(ISO_Open.FileName, 2);\r
+            else\r
+                UpdateSourceLabel();\r
         }\r
         private void mnu_dvd_drive_Click(object sender, EventArgs e)\r
         {\r
-            // Enable the creation of chapter markers.\r
+            if (!mnu_dvd_drive.Text.Contains("VIDEO_TS")) return;\r
+            string[] path = mnu_dvd_drive.Text.Split(' ');\r
+            selectSource(path[0], 3);\r
+        }\r
+        private void selectSource(string file, int type)\r
+        {\r
             Check_ChapterMarkers.Enabled = true;\r
-\r
-            // Set the last action to scan. \r
-            // This is used for tracking which file to load in the activity window\r
             lastAction = "scan";\r
             sourcePath = string.Empty;\r
 \r
-            if (mnu_dvd_drive.Text.Contains("VIDEO_TS"))\r
+            if (file == string.Empty) // Must have a file or path\r
             {\r
-                string[] path = mnu_dvd_drive.Text.Split(' ');\r
-                String filename = path[0];\r
-                sourcePath = Path.GetFullPath(filename);\r
-                setupGUIforScan(filename);\r
-                startScan(filename);\r
+                UpdateSourceLabel();\r
+                return;\r
             }\r
 \r
-            // If there are no titles in the dropdown menu then the scan has obviously failed. Display an error message explaining to the user.\r
-            if (drp_dvdtitle.Items.Count == 0)\r
-                MessageBox.Show("No Title(s) found. Please make sure you have selected a valid, non-copy protected source.\nYour Source may be copy protected, badly mastered or a format which HandBrake does not support. \nPlease refer to the Documentation and FAQ (see Help Menu).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
-\r
-            UpdateSourceLabel();\r
+            if (file.StartsWith("\\")) // NO UNC Paths\r
+            {\r
+                MessageBox.Show(\r
+                    "Sorry, HandBrake does not support UNC file paths. \nTry mounting the share as a network drive in My Computer",\r
+                    "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+                UpdateSourceLabel();\r
+                return;\r
+            }\r
 \r
-            lbl_encode.Text = "";\r
+            switch (type) // Start the scan\r
+            {\r
+                case 1: // btn_dvd_source_Click()\r
+                case 3: // mnu_dvd_drive_Click()\r
+                    sourcePath = Path.GetFullPath(file);\r
+                    startScan(file);\r
+                    break;\r
+                case 2: // btn_file_source_Click()\r
+                    sourcePath = Path.GetFileName(file);\r
+                    startScan(file);\r
+                    break;\r
+            }\r
         }\r
         private void drp_dvdtitle_Click(object sender, EventArgs e)\r
         {\r
@@ -914,9 +876,8 @@ namespace Handbrake
         private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)\r
         {\r
             unRegisterPresetEventHandler();\r
-            // Reset some values on the form\r
-            PictureSettings.lbl_Aspect.Text = "Select a Title";\r
-            //lbl_RecomendedCrop.Text = "Select a Title";\r
+\r
+            PictureSettings.lbl_Aspect.Text = "Select a Title"; // Reset some values on the form\r
             drop_chapterStart.Items.Clear();\r
             drop_chapterFinish.Items.Clear();\r
 \r
@@ -996,86 +957,65 @@ namespace Handbrake
 \r
             registerPresetEventHandler();\r
         }\r
-        private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)\r
+        private void chapersChanged(object sender, EventArgs e)\r
         {\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
+            Control ctl = (Control) sender;\r
+            int chapterStart, chapterEnd;\r
+            int.TryParse(drop_chapterStart.Text, out chapterStart);\r
+            int.TryParse(drop_chapterFinish.Text, out chapterEnd);\r
 \r
-            int.TryParse(drop_chapterStart.Text, out c_start);\r
-            int.TryParse(drop_chapterFinish.Text, out c_end);\r
-\r
-            if (c_end != 0)\r
+            switch (ctl.Name)\r
             {\r
-                if (c_start > c_end)\r
-                    drop_chapterFinish.Text = c_start.ToString();\r
-            }\r
-\r
-            lbl_duration.Text = Main.calculateDuration(drop_chapterStart.SelectedIndex, drop_chapterFinish.SelectedIndex, selectedTitle).ToString();\r
+                case "drop_chapterStart":\r
+                    if (drop_chapterFinish.SelectedIndex == -1 && drop_chapterFinish.Items.Count != 0)\r
+                        drop_chapterFinish.SelectedIndex = drop_chapterFinish.Items.Count - 1;\r
 \r
-            // Run the Autonaming function\r
-            if (Properties.Settings.Default.autoNaming)\r
-                text_destination.Text = Main.autoName(drp_dvdtitle, drop_chapterStart.Text, drop_chapterFinish.Text, sourcePath, text_destination.Text, drop_format.SelectedIndex);\r
-\r
-            // Disable chapter markers if only 1 chapter is selected.\r
-            if (c_start == c_end)\r
-            {\r
-                Check_ChapterMarkers.Checked = false;\r
-                Check_ChapterMarkers.Enabled = false;\r
-            }\r
-            else\r
-                Check_ChapterMarkers.Enabled = true;\r
-        }\r
-        private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            int c_start, c_end;\r
+                    if (chapterEnd != 0)\r
+                        if (chapterStart > chapterEnd)\r
+                            drop_chapterFinish.Text = chapterStart.ToString();\r
+                    break;\r
+                case "drop_chapterFinish":\r
+                    if (drop_chapterStart.Items.Count >= 1 && drop_chapterStart.SelectedIndex == -1)\r
+                        drop_chapterStart.SelectedIndex = 0;\r
 \r
-            if (drop_chapterStart.Text == "Auto" && drop_chapterStart.Items.Count >= 1)\r
-                drop_chapterStart.SelectedIndex = 1;\r
+                    if (chapterStart != 0)\r
+                        if (chapterEnd < chapterStart)\r
+                            drop_chapterFinish.Text = chapterStart.ToString();\r
 \r
-            int.TryParse(drop_chapterStart.Text, out c_start);\r
-            int.TryParse(drop_chapterFinish.Text, out c_end);\r
+                    // Add more rows to the Chapter menu if needed.\r
+                    if (Check_ChapterMarkers.Checked)\r
+                    {\r
+                        int i = data_chpt.Rows.Count, finish = 0;\r
+                        int.TryParse(drop_chapterFinish.Text, out finish);\r
 \r
-            if (c_start != 0)\r
-            {\r
-                if (c_end < c_start)\r
-                    drop_chapterFinish.Text = c_start.ToString();\r
+                        while (i < finish)\r
+                        {\r
+                            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
+                            i++;\r
+                        }\r
+                    }\r
+                    break;\r
             }\r
 \r
+            // Update the Duration\r
             lbl_duration.Text = Main.calculateDuration(drop_chapterStart.SelectedIndex, drop_chapterFinish.SelectedIndex, selectedTitle).ToString();\r
 \r
             // Run the Autonaming function\r
             if (Properties.Settings.Default.autoNaming)\r
                 text_destination.Text = Main.autoName(drp_dvdtitle, drop_chapterStart.Text, drop_chapterFinish.Text, sourcePath, text_destination.Text, drop_format.SelectedIndex);\r
 \r
-            // Add more rows to the Chapter menu if needed.\r
-            if (Check_ChapterMarkers.Checked)\r
-            {\r
-                int i = data_chpt.Rows.Count, finish = 0;\r
-\r
-                if (drop_chapterFinish.Text != "Auto")\r
-                    int.TryParse(drop_chapterFinish.Text, out finish);\r
-\r
-                while (i < finish)\r
-                {\r
-                    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
-                    i++;\r
-                }\r
-            }\r
-\r
             // Disable chapter markers if only 1 chapter is selected.\r
-            if (c_start == c_end)\r
+            if (chapterStart == chapterEnd)\r
             {\r
                 Check_ChapterMarkers.Checked = false;\r
                 Check_ChapterMarkers.Enabled = false;\r
             }\r
             else\r
-                Check_ChapterMarkers.Enabled = true;\r
+                Check_ChapterMarkers.Enabled = true;  \r
         }\r
 \r
         //Destination\r
@@ -1369,7 +1309,7 @@ namespace Handbrake
         // Query Editor Tab\r
         private void btn_generate_Query_Click(object sender, EventArgs e)\r
         {\r
-            rtf_query.Text = queryGen.generateTheQuery(this);\r
+            rtf_query.Text = queryGen.generateCLIQuery(this, 0, null);\r
         }\r
         private void btn_clear_Click(object sender, EventArgs e)\r
         {\r
@@ -1382,8 +1322,9 @@ namespace Handbrake
         #region Source Scan\r
         public Boolean isScanning { get; set; }\r
         private static int scanProcessID { get; set; }\r
-        private void setupGUIforScan(String filename)\r
+        private void startScan(String filename)\r
         {\r
+            // Setup the GUI components for the scan.\r
             sourcePath = filename;\r
             foreach (Control ctrl in Controls)\r
             {\r
@@ -1392,24 +1333,20 @@ namespace Handbrake
             }\r
             lbl_encode.Visible = true;\r
             lbl_encode.Text = "Scanning ...";\r
-            //gb_source.Text = "Source: Scanning ...";\r
             btn_source.Enabled = false;\r
             btn_start.Enabled = false;\r
             btn_showQueue.Enabled = false;\r
             btn_add2Queue.Enabled = false;\r
             tb_preview.Enabled = false;\r
             mnu_killCLI.Visible = true;\r
-        }\r
-        private void startScan(String filename)\r
-        {\r
+\r
+            // Start hte Scan Thread\r
             try\r
             {\r
-                lbl_encode.Visible = true;\r
-                lbl_encode.Text = "Scanning...";\r
                 if (ActivityWindow != null)\r
                     ActivityWindow.setLogView(true);\r
                 isScanning = true;\r
-                ThreadPool.QueueUserWorkItem(scanProcess, filename);\r
+                ThreadPool.QueueUserWorkItem(scanProcess);\r
             }\r
             catch (Exception exc)\r
             {\r
@@ -1420,7 +1357,6 @@ namespace Handbrake
         {\r
             try\r
             {\r
-                string inputFile = (string)state;\r
                 string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");\r
                 string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
                 string dvdInfoPath = Path.Combine(logDir, "last_scan_log.txt");\r
@@ -1432,7 +1368,7 @@ namespace Handbrake
                 String dvdnav = string.Empty;\r
                 if (Properties.Settings.Default.dvdnav)\r
                     dvdnav = " --dvdnav";\r
-                string strCmdLine = String.Format(@"cmd /c """"{0}"" -i ""{1}"" -t0 {2} -v >""{3}"" 2>&1""", handbrakeCLIPath, inputFile, dvdnav, dvdInfoPath);\r
+                string strCmdLine = String.Format(@"cmd /c """"{0}"" -i ""{1}"" -t0 {2} -v >""{3}"" 2>&1""", handbrakeCLIPath, sourcePath, dvdnav, dvdInfoPath);\r
 \r
                 ProcessStartInfo hbParseDvd = new ProcessStartInfo("CMD.exe", strCmdLine) { WindowStyle = ProcessWindowStyle.Hidden };\r
 \r
@@ -1449,11 +1385,8 @@ namespace Handbrake
                 if (cleanExit) // If 0 exit code, CLI exited cleanly.\r
                 {\r
                     if (!File.Exists(dvdInfoPath))\r
-                    {\r
-                        throw new Exception(\r
-                            "Unable to retrieve the DVD Info. last_scan_log.txt is missing. \nExpected location of last_scan_log.txt: \n" +\r
-                            dvdInfoPath);\r
-                    }\r
+                        throw new Exception("Unable to retrieve the DVD Info. last_scan_log.txt is missing. \nExpected location of last_scan_log.txt: \n"\r
+                                            + dvdInfoPath);\r
 \r
                     using (StreamReader sr = new StreamReader(dvdInfoPath))\r
                     {\r
@@ -1485,9 +1418,6 @@ namespace Handbrake
                 drp_dvdtitle.Items.Clear();\r
                 if (thisDVD.Titles.Count != 0)\r
                     drp_dvdtitle.Items.AddRange(thisDVD.Titles.ToArray());\r
-                drp_dvdtitle.Text = "Automatic";\r
-                drop_chapterFinish.Text = "Auto";\r
-                drop_chapterStart.Text = "Auto";\r
 \r
                 // Now select the longest title\r
                 if (thisDVD.Titles.Count != 0)\r
@@ -1507,7 +1437,7 @@ namespace Handbrake
                 if (drp_dvdtitle.Items.Count == 0)\r
                 {\r
                     MessageBox.Show(\r
-                        "No Title(s) found. \n\nYour Source may be copy protected, badly mastered or a format which HandBrake does not support. \nPlease refer to the Documentation and FAQ (see Help Menu).",\r
+                        "No Title(s) found. \n\nYour Source may be copy protected, badly mastered or in a format which HandBrake does not support. \nPlease refer to the Documentation and FAQ (see Help Menu).",\r
                         "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
                     sourcePath = string.Empty;\r
                 }\r
@@ -1529,7 +1459,6 @@ namespace Handbrake
                 if (InvokeRequired)\r
                     BeginInvoke(new UpdateWindowHandler(enableGUI));\r
                 lbl_encode.Text = "Scan Completed";\r
-                //gb_source.Text = "Source";\r
                 foreach (Control ctrl in Controls)\r
                     ctrl.Enabled = true;\r
                 btn_start.Enabled = true;\r
@@ -1570,26 +1499,21 @@ namespace Handbrake
         private void resetGUI()\r
         {\r
             drp_dvdtitle.Items.Clear();\r
-            drp_dvdtitle.Text = "Automatic";\r
             drop_chapterStart.Items.Clear();\r
-            drop_chapterStart.Text = "Auto";\r
             drop_chapterFinish.Items.Clear();\r
-            drop_chapterFinish.Text = "Auto";\r
             lbl_duration.Text = "Select a Title";\r
             PictureSettings.lbl_src_res.Text = "Select a Title";\r
             PictureSettings.lbl_Aspect.Text = "Select a Title";\r
-            sourcePath = "Source";\r
-            text_destination.Text = "";\r
+            sourcePath = String.Empty;\r
+            text_destination.Text = String.Empty;\r
             thisDVD = null;\r
             selectedTitle = null;\r
             isScanning = false;\r
         }\r
-\r
         private void UpdateSourceLabel()\r
         {\r
             labelSource.Text = string.IsNullOrEmpty(sourcePath) ? "Select \"Source\" to continue." : Path.GetFileName(sourcePath);\r
         }\r
-\r
         #endregion\r
 \r
         #region GUI\r
@@ -1652,14 +1576,13 @@ namespace Handbrake
         #endregion\r
 \r
         #region DVD Drive Detection\r
-        private delegate void ProgressUpdateHandler();\r
         private void getDriveInfoThread()\r
         {\r
             try\r
             {\r
                 if (InvokeRequired)\r
                 {\r
-                    BeginInvoke(new ProgressUpdateHandler(getDriveInfoThread));\r
+                    BeginInvoke(new UpdateWindowHandler(getDriveInfoThread));\r
                     return;\r
                 }\r
 \r
@@ -1702,7 +1625,7 @@ namespace Handbrake
 \r
             presetHandler.getPresetPanel(ref treeView_presets);\r
             treeView_presets.Update();\r
-        }       \r
+        }\r
         #endregion\r
 \r
         #region Overrides\r
index ff14b8a..231a23d 100644 (file)
@@ -1018,7 +1018,7 @@ namespace Handbrake
             "0.50",\r
             "0.25",\r
             "0.20"});\r
-            this.drop_x264step.Location = new System.Drawing.Point(266, 184);\r
+            this.drop_x264step.Location = new System.Drawing.Point(358, 184);\r
             this.drop_x264step.Name = "drop_x264step";\r
             this.drop_x264step.Size = new System.Drawing.Size(85, 21);\r
             this.drop_x264step.TabIndex = 86;\r
@@ -1033,9 +1033,9 @@ namespace Handbrake
             this.tableLayoutPanel4.SetColumnSpan(this.label30, 2);\r
             this.label30.Location = new System.Drawing.Point(67, 188);\r
             this.label30.Name = "label30";\r
-            this.label30.Size = new System.Drawing.Size(193, 13);\r
+            this.label30.Size = new System.Drawing.Size(285, 13);\r
             this.label30.TabIndex = 87;\r
-            this.label30.Text = "Constant quality fractional granularity:\r\n";\r
+            this.label30.Text = "Constant quality fractional granularity (Requires Restart):\r\n";\r
             // \r
             // btn_drive_detect\r
             // \r
@@ -1088,9 +1088,9 @@ namespace Handbrake
             this.tableLayoutPanel4.SetColumnSpan(this.check_queryEditorTab, 4);\r
             this.check_queryEditorTab.Location = new System.Drawing.Point(67, 72);\r
             this.check_queryEditorTab.Name = "check_queryEditorTab";\r
-            this.check_queryEditorTab.Size = new System.Drawing.Size(149, 17);\r
+            this.check_queryEditorTab.Size = new System.Drawing.Size(241, 17);\r
             this.check_queryEditorTab.TabIndex = 84;\r
-            this.check_queryEditorTab.Text = "Enable \"Query Editor\" tab";\r
+            this.check_queryEditorTab.Text = "Enable \"Query Editor\" tab (Requires Restart)";\r
             this.ToolTip.SetToolTip(this.check_queryEditorTab, "Enables the Query Editor tab on the main window. Requires program restart to take" +\r
                     " effect.");\r
             this.check_queryEditorTab.UseVisualStyleBackColor = false;\r
index 139d824..427cdd9 100644 (file)
   <metadata name="ToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
     <value>132, 18</value>\r
   </metadata>\r
+  <metadata name="ToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>132, 18</value>\r
+  </metadata>\r
   <metadata name="pathFinder.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
     <value>17, 17</value>\r
   </metadata>\r
index 96ef4a8..6d68dda 100644 (file)
@@ -57,7 +57,9 @@ namespace Handbrake
             btn_playQT.Enabled = false;\r
             btn_playVLC.Enabled = false;\r
             lbl_status.Text = "Encoding Sample for (VLC) ...";\r
-            String query = hb_common_func.generatePreviewQuery(mainWindow, cb_duration.Text, cb_preview.Text);\r
+            int duration;\r
+            int.TryParse(cb_duration.Text, out duration);\r
+            String query = hb_common_func.generateCLIQuery(mainWindow, duration, cb_preview.Text);\r
             ThreadPool.QueueUserWorkItem(procMonitor, query);\r
         }\r
         private void btn_playQT_Click(object sender, EventArgs e)\r
@@ -85,7 +87,9 @@ namespace Handbrake
                 btn_playQT.Enabled = false;\r
                 btn_playVLC.Enabled = false;\r
                 lbl_status.Text = "Encoding Sample for (QT) ...";\r
-                String query = hb_common_func.generatePreviewQuery(mainWindow, cb_duration.Text, cb_preview.Text);\r
+                int duration;\r
+                int.TryParse(cb_duration.Text, out duration);\r
+                String query = hb_common_func.generateCLIQuery(mainWindow, duration, cb_preview.Text);\r
 \r
                 ThreadPool.QueueUserWorkItem(procMonitor, query);\r
             }\r