OSDN Git Service

WinGui;
[handbrake-jp/handbrake-jp-git.git] / win / C# / frmMain.cs
index 8c5ca36..c25a996 100644 (file)
@@ -77,6 +77,11 @@ namespace Handbrake
                     return this.dvdDriveLabel;\r
                 }\r
 \r
+                if (selectedTitle != null && !string.IsNullOrEmpty(selectedTitle.SourceName))\r
+                {\r
+                    return Path.GetFileName(selectedTitle.SourceName);\r
+                }\r
+\r
                 if (Path.GetFileNameWithoutExtension(this.sourcePath) != "VIDEO_TS")\r
                     return Path.GetFileNameWithoutExtension(this.sourcePath);\r
 \r
@@ -924,21 +929,16 @@ namespace Handbrake
         /// </summary>\r
         private void ExportPreset()\r
         {\r
-            MessageBox.Show("This feature has not been implimented yet.", "Not Implimented", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
-            return;\r
-\r
-            /*SaveFileDialog savefiledialog = new SaveFileDialog();\r
-            savefiledialog.Filter = "plist|*.plist";\r
+            SaveFileDialog savefiledialog = new SaveFileDialog { Filter = "plist|*.plist" };\r
 \r
             if (treeView_presets.SelectedNode != null)\r
             {\r
-\r
                 if (savefiledialog.ShowDialog() == DialogResult.OK)\r
                 {\r
                     Preset preset = presetHandler.GetPreset(treeView_presets.SelectedNode.Text);\r
                     PlistPresetHandler.Export(savefiledialog.FileName, preset);\r
                 }\r
-            }*/\r
+            }\r
         }\r
 \r
         #endregion\r
@@ -1104,7 +1104,64 @@ namespace Handbrake
         /// </param>\r
         private void btn_add2Queue_Click(object sender, EventArgs e)\r
         {\r
-            // Get the CLI query or use the query editor if it's not empty.\r
+            // Add the item to the queue.\r
+            AddItemToQueue(true);\r
+            queueWindow.Show();\r
+        }\r
+\r
+        /// <summary>\r
+        /// Add Multiple Items to the Queue at once.\r
+        /// </summary>\r
+        /// <param name="sender">The Sender</param>\r
+        /// <param name="e">The EventArgs</param>\r
+        private void MnuAddMultiToQueueClick(object sender, EventArgs e)\r
+        {\r
+            if (!Settings.Default.autoNaming)\r
+            {\r
+                MessageBox.Show("Destination Auto Naming must be enabled in preferences for this feature to work.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                return;\r
+            }\r
+\r
+            if (this.SourceScan.SouceData == null)\r
+            {\r
+                MessageBox.Show("You must first scan a source or collection of source to use this feature.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                return;\r
+            }\r
+\r
+            BatchAdd batchAdd = new BatchAdd();\r
+            if (batchAdd.ShowDialog() == DialogResult.OK)\r
+            {\r
+                int min = batchAdd.Min;\r
+                int max = batchAdd.Max;\r
+                bool errors = false;\r
+\r
+                foreach (Title title in this.SourceScan.SouceData.Titles)\r
+                {\r
+                    if (title.Duration.TotalMinutes > min && title.Duration.TotalMinutes < max)\r
+                    {\r
+                        // Add to Queue\r
+                        this.drp_dvdtitle.SelectedItem = title;\r
+\r
+                        if (!this.AddItemToQueue(false))\r
+                        {\r
+                            errors = true;\r
+                        }\r
+                    }\r
+                }\r
+\r
+                if (errors)\r
+                {\r
+                    MessageBox.Show(\r
+                        "One or more items could not be added to the queue. You should check your queue and manually add any missing jobs.",\r
+                        "Warning",\r
+                        MessageBoxButtons.OK,\r
+                        MessageBoxIcon.Warning);\r
+                }\r
+            }\r
+        }\r
+\r
+        private bool AddItemToQueue(bool showError)\r
+        {\r
             string query = QueryGenerator.GenerateFullQuery(this);\r
             if (!string.IsNullOrEmpty(rtf_query.Text))\r
                 query = rtf_query.Text;\r
@@ -1116,33 +1173,48 @@ namespace Handbrake
             // Make sure we have a Source and Destination.\r
             if (string.IsNullOrEmpty(jobSourcePath) || string.IsNullOrEmpty(jobDestination))\r
             {\r
-                MessageBox.Show("No source or destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
-                return;\r
+                if (showError)\r
+                    MessageBox.Show("No source or destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+                return false;\r
             }\r
 \r
             // Make sure the destination path exists.\r
             if (!Directory.Exists(Path.GetDirectoryName(jobDestination)))\r
             {\r
-                MessageBox.Show(string.Format("Destination Path does not exist.\nPath: {0}\n\nThis item was not added to the Queue.", Path.GetDirectoryName(jobDestination)), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
-                return;\r
+                if (showError)\r
+                    MessageBox.Show(string.Format("Destination Path does not exist.\nPath: {0}\n\nThis item was not added to the Queue.", Path.GetDirectoryName(jobDestination)), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+                return false;\r
             }\r
 \r
             // Make sure we don't have a duplciate on the queue.\r
             if (encodeQueue.CheckForDestinationDuplicate(jobDestination))\r
             {\r
-                DialogResult result =\r
-                    MessageBox.Show(\r
-                        string.Format("There is already a queue item for this destination path.\nDestination Path: {0} \n\nIf you continue, the encode will be overwritten. Do you wish to continue?", jobDestination),\r
-                        "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);\r
-                if (result == DialogResult.Yes)\r
-                    encodeQueue.Add(query, this.GetTitle(), jobSourcePath, jobDestination, (rtf_query.Text != string.Empty));\r
+                if (showError)\r
+                {\r
+                    DialogResult result;\r
+                    result =\r
+                        MessageBox.Show(\r
+                            string.Format(\r
+                                "There is already a queue item for this destination path.\nDestination Path: {0} \n\nIf you continue, the encode will be overwritten. Do you wish to continue?",\r
+                                jobDestination),\r
+                            "Warning",\r
+                            MessageBoxButtons.YesNo,\r
+                            MessageBoxIcon.Warning);\r
+\r
+                    if (result != DialogResult.Yes) return false;\r
+                } \r
+                else\r
+                {\r
+                    return false;\r
+                }\r
             }\r
-            else\r
-                encodeQueue.Add(query, this.GetTitle(), jobSourcePath, jobDestination, (rtf_query.Text != string.Empty));\r
+            \r
+            // Add the job.\r
+            encodeQueue.Add(query, this.GetTitle(), jobSourcePath, jobDestination, (rtf_query.Text != string.Empty));\r
 \r
             lbl_encode.Text = encodeQueue.Count + " encode(s) pending in the queue";\r
 \r
-            queueWindow.Show();\r
+            return true;\r
         }\r
 \r
         /// <summary>\r
@@ -1440,7 +1512,7 @@ namespace Handbrake
             // Update the source label if we have multiple streams\r
             if (selectedTitle != null)\r
                 if (!string.IsNullOrEmpty(selectedTitle.SourceName))\r
-                    labelSource.Text = labelSource.Text = Path.GetFileName(selectedTitle.SourceName);\r
+                    labelSource.Text = Path.GetFileName(selectedTitle.SourceName);\r
 \r
             // Run the AutoName & ChapterNaming functions\r
             if (Properties.Settings.Default.autoNaming)\r
@@ -2201,11 +2273,6 @@ namespace Handbrake
         private void UpdateSourceLabel()\r
         {\r
             labelSource.Text = string.IsNullOrEmpty(sourcePath) ? "Select \"Source\" to continue." : this.SourceName;\r
-\r
-            if (selectedTitle != null)\r
-                if (!string.IsNullOrEmpty(selectedTitle.SourceName))\r
-                    // If it's one of multiple source files, make sure we don't use the folder name\r
-                    labelSource.Text = Path.GetFileName(selectedTitle.SourceName);\r
         }\r
 \r
         /// <summary>\r