From 561aa6ec3b4f018a4e76d1a57c7ffd6f0e7ded70 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 17 Jul 2010 22:25:01 +0000 Subject: WinGui: - Some tweaks to the Logging code. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3445 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Functions/Logging.cs | 49 ++++++++++++++++++ .../Functions/System.cs | 58 ++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 win/C#/HandBrake.ApplicationServices/Functions/Logging.cs create mode 100644 win/C#/HandBrake.ApplicationServices/Functions/System.cs (limited to 'win/C#/HandBrake.ApplicationServices/Functions') 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: . + 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; + + /// + /// The System Information. + /// + public class Logging + { + /// + /// Add the CLI Query to the Log File. + /// + /// + /// The Encode Job Object + /// + 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: . + It may be used under the terms of the GNU General Public License. */ + +namespace HandBrake.ApplicationServices.Functions +{ + using System.Windows.Forms; + + using Microsoft.Win32; + + /// + /// The System Information. + /// + public class SystemInfo + { + /// + /// Gets the total physical ram in a system + /// + /// The total memory in the system + 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; + } + } + + /// + /// Gets the number of CPU Cores + /// + /// Object + public static object GetCpuCount + { + get + { + RegistryKey regKey = Registry.LocalMachine; + regKey = regKey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"); + return regKey == null ? 0 : regKey.GetValue("ProcessorNameString"); + } + } + + /// + /// Gets the System screen size information. + /// + /// System.Windows.Forms.Scree + public static Screen ScreenBounds + { + get { return Screen.PrimaryScreen; } + } + } +} \ No newline at end of file -- cgit v1.2.3