summaryrefslogtreecommitdiffstats
path: root/win/C#/HandBrake.ApplicationServices/Functions
diff options
context:
space:
mode:
authorsr55 <[email protected]>2010-07-17 22:25:01 +0000
committersr55 <[email protected]>2010-07-17 22:25:01 +0000
commit561aa6ec3b4f018a4e76d1a57c7ffd6f0e7ded70 (patch)
treeb320ca795db14f25259c8d01f5f03222b25a8db6 /win/C#/HandBrake.ApplicationServices/Functions
parent4cacc7fd60440725739f4560f14eadf40e335890 (diff)
WinGui:
- Some tweaks to the Logging code. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3445 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/HandBrake.ApplicationServices/Functions')
-rw-r--r--win/C#/HandBrake.ApplicationServices/Functions/Logging.cs49
-rw-r--r--win/C#/HandBrake.ApplicationServices/Functions/System.cs58
2 files changed, 107 insertions, 0 deletions
diff --git a/win/C#/HandBrake.ApplicationServices/Functions/Logging.cs b/win/C#/HandBrake.ApplicationServices/Functions/Logging.cs
new file mode 100644
index 000000000..aba92dbbe
--- /dev/null
+++ b/win/C#/HandBrake.ApplicationServices/Functions/Logging.cs
@@ -0,0 +1,49 @@
+/* Logging.cs $
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr>.
+ It may be used under the terms of the GNU General Public License. */
+
+namespace HandBrake.ApplicationServices.Functions
+{
+ using System;
+ using System.IO;
+ using System.Text;
+ using System.Windows.Forms;
+
+ using HandBrake.ApplicationServices.Model;
+
+ /// <summary>
+ /// The System Information.
+ /// </summary>
+ public class Logging
+ {
+ /// <summary>
+ /// Add the CLI Query to the Log File.
+ /// </summary>
+ /// <param name="encJob">
+ /// The Encode Job Object
+ /// </param>
+ public static string CreateCliLogHeader(Job encJob)
+ {
+ StringBuilder logHeader = new StringBuilder();
+
+ logHeader.AppendLine(String.Format("# {0}", Init.HandBrakeGuiVersionString));
+ logHeader.AppendLine(String.Format("# Running: {0}", Environment.OSVersion));
+ logHeader.AppendLine(String.Format("# CPU: {0}", SystemInfo.GetCpuCount));
+ logHeader.AppendLine(String.Format("# Ram: {0} MB", SystemInfo.TotalPhysicalMemory));
+ logHeader.AppendLine(String.Format("# Screen: {0}x{1}", SystemInfo.ScreenBounds.Bounds.Width, SystemInfo.ScreenBounds.Bounds.Height));
+ logHeader.AppendLine(String.Format("# Temp Dir: {0}", Path.GetTempPath()));
+ logHeader.AppendLine(String.Format("# Install Dir: {0}", Application.StartupPath));
+ logHeader.AppendLine(String.Format("# Data Dir: {0}\n", Application.UserAppDataPath));
+
+ if (encJob != null)
+ {
+ logHeader.AppendLine(String.Format("# CLI Query: {0}", encJob.Query));
+ logHeader.AppendLine(String.Format("# User Query: {0}", encJob.CustomQuery));
+ }
+ logHeader.AppendLine("-------------------------------------------");
+
+ return logHeader.ToString();
+ }
+ }
+} \ No newline at end of file
diff --git a/win/C#/HandBrake.ApplicationServices/Functions/System.cs b/win/C#/HandBrake.ApplicationServices/Functions/System.cs
new file mode 100644
index 000000000..b2ee6edfe
--- /dev/null
+++ b/win/C#/HandBrake.ApplicationServices/Functions/System.cs
@@ -0,0 +1,58 @@
+/* System.cs $
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr>.
+ It may be used under the terms of the GNU General Public License. */
+
+namespace HandBrake.ApplicationServices.Functions
+{
+ using System.Windows.Forms;
+
+ using Microsoft.Win32;
+
+ /// <summary>
+ /// The System Information.
+ /// </summary>
+ public class SystemInfo
+ {
+ /// <summary>
+ /// Gets the total physical ram in a system
+ /// </summary>
+ /// <returns>The total memory in the system</returns>
+ public static uint TotalPhysicalMemory
+ {
+ get
+ {
+ Win32.MEMORYSTATUS memStatus = new Win32.MEMORYSTATUS();
+ Win32.GlobalMemoryStatus(ref memStatus);
+
+ uint memoryInfo = memStatus.dwTotalPhys;
+ memoryInfo = memoryInfo / 1024 / 1024;
+
+ return memoryInfo;
+ }
+ }
+
+ /// <summary>
+ /// Gets the number of CPU Cores
+ /// </summary>
+ /// <returns>Object</returns>
+ public static object GetCpuCount
+ {
+ get
+ {
+ RegistryKey regKey = Registry.LocalMachine;
+ regKey = regKey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
+ return regKey == null ? 0 : regKey.GetValue("ProcessorNameString");
+ }
+ }
+
+ /// <summary>
+ /// Gets the System screen size information.
+ /// </summary>
+ /// <returns>System.Windows.Forms.Scree</returns>
+ public static Screen ScreenBounds
+ {
+ get { return Screen.PrimaryScreen; }
+ }
+ }
+} \ No newline at end of file