OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 25 Jun 2010 19:46:38 +0000 (19:46 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 25 Jun 2010 19:46:38 +0000 (19:46 +0000)
- Allow files to be dropped on the GUI executable. (Including shortcuts). This will automatically try to scan the file. Users can add their own registry entries to add an "open with" if they choose.
- Fixed an exception that occurs when a scanned file returns no titles.
- Fixed an issue where pressing "No" to the on close warning (when encodes are running) would cancel the encode anyway.

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

win/C#/Program.cs
win/C#/frmMain.cs

index d5da8f2..19f5fb2 100644 (file)
@@ -24,7 +24,7 @@ namespace Handbrake
         /// The main entry point for the application.\r
         /// </summary>\r
         [STAThread]\r
-        public static void Main()\r
+        public static void Main(string[] args)\r
         {\r
             // Handle any unhandled exceptions\r
             AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);\r
@@ -79,7 +79,7 @@ namespace Handbrake
 \r
                 Application.EnableVisualStyles();\r
                 Application.SetCompatibleTextRenderingDefault(false);\r
-                Application.Run(new frmMain());\r
+                Application.Run(new frmMain(args));\r
             }\r
         }\r
 \r
index 713ca10..1a7590b 100644 (file)
@@ -79,7 +79,13 @@ namespace Handbrake
 \r
         #region Application Startup\r
 \r
-        public frmMain()\r
+        /// <summary>\r
+        /// Initializes a new instance of the <see cref="frmMain"/> class.\r
+        /// </summary>\r
+        /// <param name="args">\r
+        /// The arguments passed in on application startup.\r
+        /// </param>\r
+        public frmMain(string[] args)\r
         {\r
             // Load and setup the splash screen in this thread\r
             splash.Show(this);\r
@@ -168,6 +174,12 @@ namespace Handbrake
             // Event Handlers and Queue Recovery\r
             events();\r
             queueRecovery();\r
+\r
+            // If have a file passed in via command arguemtents, check it's a file and try scanning it.\r
+            if (args.Length >= 1 && File.Exists(args[0]))\r
+            {\r
+                this.StartScan(args[0], 0);\r
+            }\r
         }\r
 \r
         private void UpdateCheckDone(IAsyncResult result)\r
@@ -2046,17 +2058,19 @@ namespace Handbrake
                     drp_dvdtitle.SelectedIndex = 0;\r
                 }\r
 \r
-                // Enable the creation of chapter markers if the file is an image of a dvd.\r
-                int start, end;\r
-                int.TryParse(drop_chapterStart.Items[0].ToString(), out start);\r
-                int.TryParse(drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString(), out end);\r
-                if (end > start)\r
-                    Check_ChapterMarkers.Enabled = true;\r
-                else\r
+                // Enable the creation of chapter markers if the file is an image of a dvd\r
+                if (drop_chapterStart.Items.Count > 0)\r
                 {\r
-                    Check_ChapterMarkers.Enabled = false;\r
-                    Check_ChapterMarkers.Checked = false;\r
-                    data_chpt.Rows.Clear();\r
+                    int start, end;\r
+                    int.TryParse(drop_chapterStart.Items[0].ToString(), out start);\r
+                    int.TryParse(drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString(), out end);\r
+                    if (end > start) Check_ChapterMarkers.Enabled = true;\r
+                    else\r
+                    {\r
+                        Check_ChapterMarkers.Enabled = false;\r
+                        Check_ChapterMarkers.Checked = false;\r
+                        data_chpt.Rows.Clear();\r
+                    }\r
                 }\r
 \r
                 // If no titles were found, Display an error message\r
@@ -2440,7 +2454,10 @@ namespace Handbrake
                         "Close HandBrake?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
 \r
                 if (result == DialogResult.No)\r
+                {\r
                     e.Cancel = true;\r
+                    return;\r
+                }\r
 \r
                 // Try to safely close out if we can, or kill the cli if using in-gui status\r
                 if (Settings.Default.enocdeStatusInGui)\r