OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / Program.cs
index d5da8f2..24d1507 100644 (file)
@@ -6,15 +6,15 @@
 namespace Handbrake\r
 {\r
     using System;\r
+    using System.Diagnostics;\r
     using System.IO;\r
     using System.Windows.Forms;\r
 \r
     using HandBrake.ApplicationServices;\r
 \r
+    using Handbrake.Presets;\r
     using Handbrake.Properties;\r
 \r
-    using Presets;\r
-\r
     /// <summary>\r
     /// HandBrake Starts Here\r
     /// </summary>\r
@@ -23,17 +23,23 @@ namespace Handbrake
         /// <summary>\r
         /// The main entry point for the application.\r
         /// </summary>\r
+        /// <param name="args">\r
+        /// The args.\r
+        /// </param>\r
         [STAThread]\r
-        public static void Main()\r
+        public static void Main(string[] args)\r
         {\r
+            InstanceId = Process.GetProcessesByName("HandBrake").Length;\r
+\r
             // Handle any unhandled exceptions\r
-            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);\r
+            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomainUnhandledException);\r
 \r
             // Attempt to upgrade / keep the users settings between versions\r
             if (Settings.Default.UpdateRequired)\r
             {\r
                 Settings.Default.Upgrade();\r
                 Settings.Default.UpdateRequired = false;\r
+                Functions.Main.SetCliVersionData();\r
             }\r
 \r
             // Make sure we have any pre-requesits before trying to launch\r
@@ -79,7 +85,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
@@ -88,10 +94,11 @@ namespace Handbrake
         /// </summary>\r
         private static void InitializeApplicationServices()\r
         {\r
-            Init.SetupSettings(Settings.Default.cli_minimized, Settings.Default.CompletionOption, Settings.Default.noDvdNav,\r
-                               Settings.Default.enocdeStatusInGui, Settings.Default.growlEncode, Settings.Default.growlQueue,\r
+            string versionId = String.Format("Windows GUI {1} {0}", Settings.Default.hb_build, Settings.Default.hb_version);\r
+            Init.SetupSettings(versionId, InstanceId, Settings.Default.CompletionOption, Settings.Default.noDvdNav,\r
+                               Settings.Default.growlEncode, Settings.Default.growlQueue,\r
                                Settings.Default.processPriority, Settings.Default.saveLogPath, Settings.Default.saveLogToSpecifiedPath,\r
-                               Settings.Default.saveLogWithVideo, Settings.Default.showCliForInGuiEncodeStatus);\r
+                               Settings.Default.saveLogWithVideo, Settings.Default.showCliForInGuiEncodeStatus, Settings.Default.preventSleep);\r
         }\r
 \r
         /// <summary>\r
@@ -99,22 +106,15 @@ namespace Handbrake
         /// </summary>\r
         /// <param name="sender">The sender</param>\r
         /// <param name="e">Unhandled Exception EventArgs </param>\r
-        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)\r
+        private static void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)\r
         {\r
-            try\r
-            {\r
-                frmExceptionWindow exceptionWindow = new frmExceptionWindow();\r
-                exceptionWindow.Setup("An Unknown Error has occured.", e.ExceptionObject.ToString());\r
-                exceptionWindow.ShowDialog();\r
-            }\r
-            catch (Exception)\r
-            {\r
-                MessageBox.Show(\r
-                    "An Unknown Error has occured. \n\n Exception:" + e.ExceptionObject,\r
-                    "Unhandled Exception",\r
-                    MessageBoxButtons.OK,\r
-                    MessageBoxIcon.Error);\r
-            }\r
+            MessageBox.Show(\r
+                "An Unknown Error has occured. \n\n Exception:" + e.ExceptionObject,\r
+                "Unhandled Exception",\r
+                MessageBoxButtons.OK,\r
+                MessageBoxIcon.Error);\r
         }\r
+\r
+        public static int InstanceId;\r
     }\r
 }
\ No newline at end of file