From: sr55 Date: Fri, 9 Jul 2010 19:21:42 +0000 (+0000) Subject: WinGui: X-Git-Tag: 0.9.5~302 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=094b2b9b203610939245502c89afee983219b9f9;p=handbrake WinGui: - 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 --- diff --git a/win/C#/HandBrake.ApplicationServices/Functions/Win32.cs b/win/C#/HandBrake.ApplicationServices/Functions/Win32.cs index 72e4d8db0..a45d7441a 100644 --- a/win/C#/HandBrake.ApplicationServices/Functions/Win32.cs +++ b/win/C#/HandBrake.ApplicationServices/Functions/Win32.cs @@ -154,7 +154,7 @@ namespace HandBrake.ApplicationServices.Functions /// /// Prevent the system from sleeping /// - public void PreventSleep() + public static void PreventSleep() { SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS | EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_AWAYMODE_REQUIRED); } @@ -162,7 +162,7 @@ namespace HandBrake.ApplicationServices.Functions /// /// Allow the system to sleep. /// - public void AllowSleep() + public static void AllowSleep() { SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS); } diff --git a/win/C#/HandBrake.ApplicationServices/Init.cs b/win/C#/HandBrake.ApplicationServices/Init.cs index 280827605..7fb0e902c 100644 --- a/win/C#/HandBrake.ApplicationServices/Init.cs +++ b/win/C#/HandBrake.ApplicationServices/Init.cs @@ -49,9 +49,12 @@ namespace HandBrake.ApplicationServices /// /// The show cli for in gui encode status. /// + /// + /// Prevent the system from sleeping + /// public static void SetupSettings(bool cli_minimized, string completionOption, bool disableDvdNav, bool enocdeStatusInGui, bool growlEncode, bool growlQueue, string processPriority, string saveLogPath, bool saveLogToSpecifiedPath, - bool saveLogWithVideo, bool showCliForInGuiEncodeStatus) + bool saveLogWithVideo, bool showCliForInGuiEncodeStatus, bool preventSleep) { Properties.Settings.Default.cli_minimized = cli_minimized; Properties.Settings.Default.CompletionOption = completionOption; @@ -64,6 +67,7 @@ namespace HandBrake.ApplicationServices Properties.Settings.Default.saveLogToSpecifiedPath = saveLogToSpecifiedPath; Properties.Settings.Default.saveLogWithVideo = saveLogWithVideo; Properties.Settings.Default.showCliForInGuiEncodeStatus = showCliForInGuiEncodeStatus; + Properties.Settings.Default.preventSleep = preventSleep; Properties.Settings.Default.Save(); } diff --git a/win/C#/HandBrake.ApplicationServices/Properties/Settings.Designer.cs b/win/C#/HandBrake.ApplicationServices/Properties/Settings.Designer.cs index bf2781961..d835524af 100644 --- a/win/C#/HandBrake.ApplicationServices/Properties/Settings.Designer.cs +++ b/win/C#/HandBrake.ApplicationServices/Properties/Settings.Designer.cs @@ -154,5 +154,17 @@ namespace HandBrake.ApplicationServices.Properties { this["growlEncode"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool preventSleep { + get { + return ((bool)(this["preventSleep"])); + } + set { + this["preventSleep"] = value; + } + } } } diff --git a/win/C#/HandBrake.ApplicationServices/Properties/Settings.settings b/win/C#/HandBrake.ApplicationServices/Properties/Settings.settings index 20239afcc..96d2de89a 100644 --- a/win/C#/HandBrake.ApplicationServices/Properties/Settings.settings +++ b/win/C#/HandBrake.ApplicationServices/Properties/Settings.settings @@ -35,5 +35,8 @@ False + + False + \ No newline at end of file diff --git a/win/C#/HandBrake.ApplicationServices/Services/Encode.cs b/win/C#/HandBrake.ApplicationServices/Services/Encode.cs index ad5cd8c3d..1731d4851 100644 --- a/win/C#/HandBrake.ApplicationServices/Services/Encode.cs +++ b/win/C#/HandBrake.ApplicationServices/Services/Encode.cs @@ -193,6 +193,11 @@ namespace HandBrake.ApplicationServices.Services this.job = encJob; try { + if (Properties.Settings.Default.preventSleep) + { + Win32.PreventSleep(); + } + ResetLogReader(); IsEncoding = true; @@ -215,8 +220,7 @@ namespace HandBrake.ApplicationServices.Services HbProcess = Process.Start(cliStart); this.processID = Main.GetCliProcess(before); - if (HbProcess != null) - this.processHandle = HbProcess.MainWindowHandle; // Set the process Handle + this.processHandle = HbProcess.MainWindowHandle; // Set the process Handle // Start the Log Monitor windowTimer = new Timer(new TimerCallback(ReadFile), null, 1000, 1000); @@ -286,6 +290,11 @@ namespace HandBrake.ApplicationServices.Services { windowsSeven.SetTaskBarProgressToNoProgress(); } + + if (Properties.Settings.Default.preventSleep) + { + Win32.AllowSleep(); + } } /// @@ -579,7 +588,7 @@ namespace HandBrake.ApplicationServices.Services while (!encode.EndOfStream) encode.ReadEncodeStatus(); - // Main.ShowExceptiowWindow("Encode Monitor Stopped", "Stopped"); + // Main.ShowExceptiowWindow("Encode Monitor Stopped", "Stopped"); } catch (Exception exc) { diff --git a/win/C#/HandBrake.ApplicationServices/app.config b/win/C#/HandBrake.ApplicationServices/app.config index 5b9648fa1..29ee4894d 100644 --- a/win/C#/HandBrake.ApplicationServices/app.config +++ b/win/C#/HandBrake.ApplicationServices/app.config @@ -40,6 +40,9 @@ False + + False + \ No newline at end of file diff --git a/win/C#/Program.cs b/win/C#/Program.cs index 19f5fb2cb..dde4a1a62 100644 --- a/win/C#/Program.cs +++ b/win/C#/Program.cs @@ -91,7 +91,7 @@ namespace Handbrake Init.SetupSettings(Settings.Default.cli_minimized, Settings.Default.CompletionOption, Settings.Default.noDvdNav, Settings.Default.enocdeStatusInGui, Settings.Default.growlEncode, Settings.Default.growlQueue, Settings.Default.processPriority, Settings.Default.saveLogPath, Settings.Default.saveLogToSpecifiedPath, - Settings.Default.saveLogWithVideo, Settings.Default.showCliForInGuiEncodeStatus); + Settings.Default.saveLogWithVideo, Settings.Default.showCliForInGuiEncodeStatus, Settings.Default.preventSleep); } /// diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 4cf0483ec..6937c5923 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -351,20 +351,12 @@ namespace Handbrake private void encodeStarted(object sender, EventArgs e) { - if (Properties.Settings.Default.preventSleep) - { - Win32.PreventSleep(); - } SetEncodeStarted(); encodeQueue.EncodeStatusChanged += EncodeQueue_EncodeStatusChanged; } private void encodeEnded(object sender, EventArgs e) { - if (Properties.Settings.Default.preventSleep) - { - Win32.AllowSleep(); - } encodeQueue.EncodeStatusChanged -= EncodeQueue_EncodeStatusChanged; SetEncodeFinished(); } diff --git a/win/C#/frmOptions.cs b/win/C#/frmOptions.cs index 399cf01b8..3ca0298f7 100644 --- a/win/C#/frmOptions.cs +++ b/win/C#/frmOptions.cs @@ -507,7 +507,7 @@ namespace Handbrake Init.SetupSettings(Settings.Default.cli_minimized, Settings.Default.CompletionOption, Settings.Default.noDvdNav, Settings.Default.enocdeStatusInGui, Settings.Default.growlEncode, Settings.Default.growlQueue, Settings.Default.processPriority, Settings.Default.saveLogPath, Settings.Default.saveLogToSpecifiedPath, - Settings.Default.saveLogWithVideo, Settings.Default.showCliForInGuiEncodeStatus); + Settings.Default.saveLogWithVideo, Settings.Default.showCliForInGuiEncodeStatus, Settings.Default.preventSleep); } } } \ No newline at end of file