diff options
author | sr55 <[email protected]> | 2008-06-27 14:42:17 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2008-06-27 14:42:17 +0000 |
commit | 45ce65f74863a7ee8d3ccf8978608794f2c91f42 (patch) | |
tree | d0ea243d7b678484994c22a66027008d93e12e21 /win/C#/Functions/CLI.cs | |
parent | 345c583574d3db3a664347304b8eb0495369ea69 (diff) |
WinGui:
- Added: Resolution calculation for non anamorphic encodes in the GUI.
- Added: Ability to minimize to the system tray. Includes popup notifications of encoding status.
- Added: Duration calculation based on Title and selected chapters.
- Added: Some more code comments and summaries
- Change: Activity window now only refreshes if there is an active HandBrakeCLI.exe running.
- Change: Browse button/ File mode checkbox for Source Selection Removed. Replaced with a Source Dropdown button in the main toolbar. (works a bit like the magui but still uses the 2 different dialog boxes)
- Change: Removed "Recommended Crop" label and simply let the dropdown set the cropping values. Added DVD resolution Label.
- Fixed: Preset loader now selects longest title and set's chapters to Auto. Before it would load in the last setting used which is bad.
- Fixed bug in the presetLoader() function with the 2nd audio channel track selection.
Final Note: Quite a bit of code has been moved around in this checkin to clear things up a bit.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1541 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Functions/CLI.cs')
-rw-r--r-- | win/C#/Functions/CLI.cs | 65 |
1 files changed, 62 insertions, 3 deletions
diff --git a/win/C#/Functions/CLI.cs b/win/C#/Functions/CLI.cs index c511953f0..b0ad57a70 100644 --- a/win/C#/Functions/CLI.cs +++ b/win/C#/Functions/CLI.cs @@ -11,11 +11,12 @@ using System.Diagnostics; using System.Windows.Forms;
using System.Globalization;
using System.IO;
+using System.Runtime.InteropServices;
namespace Handbrake.Functions
{
- class CLI
- {
+ public class CLI
+ {
/// <summary>
/// CLI output is based on en-US locale,
/// we use this CultureInfo as IFormatProvider to *.Parse() calls
@@ -24,7 +25,17 @@ namespace Handbrake.Functions Process hbProc = new Process();
- public Process runCli(object s, string query, bool stderr, bool stdout, bool useShellExec, bool noWindow)
+ /// <summary>
+ /// Execute a HandBrakeCLI process.
+ /// </summary>
+ /// <param name="s"></param>
+ /// <param name="query">The CLI Query</param>
+ /// <param name="stderr">Rediect standard error</param>
+ /// <param name="stdout">Redirect Standard output</param>
+ /// <param name="useShellExec"> Use Shell Executable</param>
+ /// <param name="noWindow">Display No Window</param>
+ /// <returns>Returns a process</returns>
+ public Process runCli(object s, string query)
{
try
{
@@ -34,6 +45,7 @@ namespace Handbrake.Functions string strCmdLine = String.Format(@"cmd /c """"{0}"" {1} 2>""{2}"" """, handbrakeCLIPath, query, logPath);
ProcessStartInfo cliStart = new ProcessStartInfo("CMD.exe", strCmdLine);
+
hbProc = Process.Start(cliStart);
// Set the process Priority
@@ -65,5 +77,52 @@ namespace Handbrake.Functions }
return hbProc;
}
+
+ [DllImport("user32.dll")]
+ public static extern void LockWorkStation();
+ [DllImport("user32.dll")]
+ public static extern int ExitWindowsEx(int uFlags, int dwReason);
+
+ public void afterEncodeAction()
+ {
+ // Do something whent he encode ends.
+ switch (Properties.Settings.Default.CompletionOption)
+ {
+ case "Shutdown":
+ System.Diagnostics.Process.Start("Shutdown", "-s -t 60");
+ break;
+ case "Log Off":
+ ExitWindowsEx(0, 0);
+ break;
+ case "Suspend":
+ Application.SetSuspendState(PowerState.Suspend, true, true);
+ break;
+ case "Hibernate":
+ Application.SetSuspendState(PowerState.Hibernate, true, true);
+ break;
+ case "Lock System":
+ LockWorkStation();
+ break;
+ case "Quit HandBrake":
+ Application.Exit();
+ break;
+ default:
+ break;
+ }
+ }
+
+ /// <summary>
+ /// Update the presets.dat file with the latest version of HandBrak's presets from the CLI
+ /// </summary>
+ public void grabCLIPresets()
+ {
+ // Gets the presets from the CLI and stores them in presets.dat
+ string appPath = Application.StartupPath.ToString() + "\\";
+ string strCmdLine = "cmd /c " + '"' + '"' + appPath + "HandBrakeCLI.exe" + '"' + " --preset-list >" + '"' + appPath + "presets.dat" + '"' + " 2>&1" + '"';
+ Process hbproc = Process.Start("CMD.exe", strCmdLine);
+ hbproc.WaitForExit();
+ hbproc.Dispose();
+ hbproc.Close();
+ }
}
}
|