]> granicus.if.org Git - handbrake/commitdiff
WinGui:
authorsr55 <sr55.hb@outlook.com>
Fri, 9 Jul 2010 19:21:42 +0000 (19:21 +0000)
committersr55 <sr55.hb@outlook.com>
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://svn.handbrake.fr/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 72e4d8db0a3828e495b8dc64e89c6bc1c76be11b..a45d7441a0776657dc01a8839d5db95dcc29668f 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 280827605140cf017d4da3d8312cf5db7fd3a734..7fb0e902c3fa066fe0e9445e64e64a819622a329 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 bf278196177d202bcca0c06052eff037fff6a042..d835524af553dad746c1fd6310a4b511b7ba62f7 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 20239afccb25f0644f288b885bca4bad5a080d21..96d2de89a12113373b6e4adb7c77122d9bf0668e 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 ad5cd8c3da5ba717a51a40b0ff6910f33d1b3858..1731d48519af41ca7b495740fdfcb89b39d2cf95 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 5b9648fa15dfa75cc693df49c4f978d23887e046..29ee4894d853b26f45b6367bf461a70308bd051c 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 19f5fb2cb00af3bcec44eee3f73832a4fb88e641..dde4a1a6298af8435ece51b6fa6403da53fc0198 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 4cf0483ec892e036d625bb77f6811694ecfd1ad3..6937c59238fef92105f401ce3496e7a7c337f33d 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 399cf01b80e10e22641fe04e64d8f38cfc99c2ea..3ca0298f757ac2e3d3c21e89269073039569c1a8 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