OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 9 Jul 2010 19:21:42 +0000 (19:21 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 9 Jul 2010 19:21:42 +0000 (19:21 +0000)
- Moved code from the prevent sleep into ApplicationServices instead. Makes more sense to have it there.

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

win/C#/HandBrake.ApplicationServices/Functions/Win32.cs
win/C#/HandBrake.ApplicationServices/Init.cs
win/C#/HandBrake.ApplicationServices/Properties/Settings.Designer.cs
win/C#/HandBrake.ApplicationServices/Properties/Settings.settings
win/C#/HandBrake.ApplicationServices/Services/Encode.cs
win/C#/HandBrake.ApplicationServices/app.config
win/C#/Program.cs
win/C#/frmMain.cs
win/C#/frmOptions.cs

index 72e4d8d..a45d744 100644 (file)
@@ -154,7 +154,7 @@ namespace HandBrake.ApplicationServices.Functions
         /// <summary>\r
         /// Prevent the system from sleeping\r
         /// </summary>\r
-        public void PreventSleep()\r
+        public static void PreventSleep()\r
         {\r
             SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS | EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_AWAYMODE_REQUIRED);\r
         }\r
@@ -162,7 +162,7 @@ namespace HandBrake.ApplicationServices.Functions
         /// <summary>\r
         ///  Allow the system to sleep.\r
         /// </summary>\r
-        public void AllowSleep()\r
+        public static void AllowSleep()\r
         {\r
             SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS);\r
         }\r
index 2808276..7fb0e90 100644 (file)
@@ -49,9 +49,12 @@ namespace HandBrake.ApplicationServices
         /// <param name="showCliForInGuiEncodeStatus">\r
         /// The show cli for in gui encode status.\r
         /// </param>\r
+        /// <param name="preventSleep">\r
+        /// Prevent the system from sleeping\r
+        /// </param>\r
         public static void SetupSettings(bool cli_minimized, string completionOption, bool disableDvdNav, bool enocdeStatusInGui,\r
                                   bool growlEncode, bool growlQueue, string processPriority, string saveLogPath, bool saveLogToSpecifiedPath,\r
-                                  bool saveLogWithVideo, bool showCliForInGuiEncodeStatus)\r
+                                  bool saveLogWithVideo, bool showCliForInGuiEncodeStatus, bool preventSleep)\r
         {\r
             Properties.Settings.Default.cli_minimized = cli_minimized;\r
             Properties.Settings.Default.CompletionOption = completionOption;\r
@@ -64,6 +67,7 @@ namespace HandBrake.ApplicationServices
             Properties.Settings.Default.saveLogToSpecifiedPath = saveLogToSpecifiedPath;\r
             Properties.Settings.Default.saveLogWithVideo = saveLogWithVideo;\r
             Properties.Settings.Default.showCliForInGuiEncodeStatus = showCliForInGuiEncodeStatus;\r
+            Properties.Settings.Default.preventSleep = preventSleep;\r
 \r
             Properties.Settings.Default.Save();\r
         }\r
index bf27819..d835524 100644 (file)
@@ -154,5 +154,17 @@ namespace HandBrake.ApplicationServices.Properties {
                 this["growlEncode"] = value;\r
             }\r
         }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
+        public bool preventSleep {\r
+            get {\r
+                return ((bool)(this["preventSleep"]));\r
+            }\r
+            set {\r
+                this["preventSleep"] = value;\r
+            }\r
+        }\r
     }\r
 }\r
index 20239af..96d2de8 100644 (file)
@@ -35,5 +35,8 @@
     <Setting Name="growlEncode" Type="System.Boolean" Scope="User">\r
       <Value Profile="(Default)">False</Value>\r
     </Setting>\r
+    <Setting Name="preventSleep" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">False</Value>\r
+    </Setting>\r
   </Settings>\r
 </SettingsFile>
\ No newline at end of file
index ad5cd8c..1731d48 100644 (file)
@@ -193,6 +193,11 @@ namespace HandBrake.ApplicationServices.Services
             this.job = encJob;\r
             try\r
             {\r
+                if (Properties.Settings.Default.preventSleep)\r
+                {\r
+                    Win32.PreventSleep();\r
+                }\r
+\r
                 ResetLogReader();\r
                 IsEncoding = true;\r
 \r
@@ -215,8 +220,7 @@ namespace HandBrake.ApplicationServices.Services
                 HbProcess = Process.Start(cliStart);\r
                 this.processID = Main.GetCliProcess(before);\r
 \r
-                if (HbProcess != null)\r
-                    this.processHandle = HbProcess.MainWindowHandle; // Set the process Handle\r
+                this.processHandle = HbProcess.MainWindowHandle; // Set the process Handle\r
 \r
                 // Start the Log Monitor\r
                 windowTimer = new Timer(new TimerCallback(ReadFile), null, 1000, 1000);\r
@@ -286,6 +290,11 @@ namespace HandBrake.ApplicationServices.Services
             {\r
                 windowsSeven.SetTaskBarProgressToNoProgress();\r
             }\r
+\r
+            if (Properties.Settings.Default.preventSleep)\r
+            {\r
+                Win32.AllowSleep();\r
+            }\r
         }\r
 \r
         /// <summary>\r
@@ -579,7 +588,7 @@ namespace HandBrake.ApplicationServices.Services
                 while (!encode.EndOfStream)\r
                     encode.ReadEncodeStatus();\r
 \r
-               // Main.ShowExceptiowWindow("Encode Monitor Stopped", "Stopped");\r
+                // Main.ShowExceptiowWindow("Encode Monitor Stopped", "Stopped");\r
             }\r
             catch (Exception exc)\r
             {\r
index 5b9648f..29ee489 100644 (file)
@@ -40,6 +40,9 @@
             <setting name="growlEncode" serializeAs="String">\r
                 <value>False</value>\r
             </setting>\r
+            <setting name="preventSleep" serializeAs="String">\r
+                <value>False</value>\r
+            </setting>\r
         </HandBrake.ApplicationServices.Properties.Settings>\r
     </userSettings>\r
 </configuration>
\ No newline at end of file
index 19f5fb2..dde4a1a 100644 (file)
@@ -91,7 +91,7 @@ namespace Handbrake
             Init.SetupSettings(Settings.Default.cli_minimized, Settings.Default.CompletionOption, Settings.Default.noDvdNav,\r
                                Settings.Default.enocdeStatusInGui, 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
index 4cf0483..6937c59 100644 (file)
@@ -351,20 +351,12 @@ namespace Handbrake
 \r
         private void encodeStarted(object sender, EventArgs e)\r
         {\r
-            if (Properties.Settings.Default.preventSleep)\r
-            {\r
-                Win32.PreventSleep();\r
-            }    \r
             SetEncodeStarted();\r
             encodeQueue.EncodeStatusChanged += EncodeQueue_EncodeStatusChanged;\r
         }\r
 \r
         private void encodeEnded(object sender, EventArgs e)\r
         {\r
-            if (Properties.Settings.Default.preventSleep)\r
-            {\r
-                Win32.AllowSleep();\r
-            }\r
             encodeQueue.EncodeStatusChanged -= EncodeQueue_EncodeStatusChanged;\r
             SetEncodeFinished();\r
         }\r
index 399cf01..3ca0298 100644 (file)
@@ -507,7 +507,7 @@ namespace Handbrake
             Init.SetupSettings(Settings.Default.cli_minimized, Settings.Default.CompletionOption, Settings.Default.noDvdNav,\r
                                Settings.Default.enocdeStatusInGui, 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
 }
\ No newline at end of file