OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 17 Jul 2010 22:25:01 +0000 (22:25 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 17 Jul 2010 22:25:01 +0000 (22:25 +0000)
- Some tweaks to the Logging code.

git-svn-id: svn://localhost/HandBrake/trunk@3445 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/HandBrake.ApplicationServices/Functions/Logging.cs [new file with mode: 0644]
win/C#/HandBrake.ApplicationServices/Functions/System.cs [moved from win/C#/Functions/System.cs with 93% similarity]
win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
win/C#/HandBrake.ApplicationServices/Init.cs
win/C#/HandBrake.ApplicationServices/Model/Job.cs
win/C#/HandBrake.ApplicationServices/Services/Encode.cs
win/C#/HandBrake.ApplicationServices/Services/Scan.cs
win/C#/HandBrakeCS.csproj
win/C#/Program.cs
win/C#/frmActivityWindow.cs
win/C#/frmOptions.cs

diff --git a/win/C#/HandBrake.ApplicationServices/Functions/Logging.cs b/win/C#/HandBrake.ApplicationServices/Functions/Logging.cs
new file mode 100644 (file)
index 0000000..aba92db
--- /dev/null
@@ -0,0 +1,49 @@
+/*  Logging.cs $\r
+    This file is part of the HandBrake source code.\r
+    Homepage: <http://handbrake.fr>.\r
+    It may be used under the terms of the GNU General Public License. */\r
+\r
+namespace HandBrake.ApplicationServices.Functions\r
+{\r
+    using System;\r
+    using System.IO;\r
+    using System.Text;\r
+    using System.Windows.Forms;\r
+\r
+    using HandBrake.ApplicationServices.Model;\r
+\r
+    /// <summary>\r
+    /// The System Information.\r
+    /// </summary>\r
+    public class Logging\r
+    {\r
+        /// <summary>\r
+        /// Add the CLI Query to the Log File.\r
+        /// </summary>\r
+        /// <param name="encJob">\r
+        /// The Encode Job Object\r
+        /// </param>\r
+        public static string CreateCliLogHeader(Job encJob)\r
+        {\r
+            StringBuilder logHeader = new StringBuilder();\r
+\r
+            logHeader.AppendLine(String.Format("# {0}", Init.HandBrakeGuiVersionString));\r
+            logHeader.AppendLine(String.Format("# Running: {0}", Environment.OSVersion));\r
+            logHeader.AppendLine(String.Format("# CPU: {0}", SystemInfo.GetCpuCount));\r
+            logHeader.AppendLine(String.Format("# Ram: {0} MB", SystemInfo.TotalPhysicalMemory));\r
+            logHeader.AppendLine(String.Format("# Screen: {0}x{1}", SystemInfo.ScreenBounds.Bounds.Width, SystemInfo.ScreenBounds.Bounds.Height));\r
+            logHeader.AppendLine(String.Format("# Temp Dir: {0}", Path.GetTempPath()));\r
+            logHeader.AppendLine(String.Format("# Install Dir: {0}", Application.StartupPath));\r
+            logHeader.AppendLine(String.Format("# Data Dir: {0}\n", Application.UserAppDataPath));\r
+\r
+            if (encJob != null)\r
+            {\r
+                logHeader.AppendLine(String.Format("# CLI Query: {0}", encJob.Query));\r
+                logHeader.AppendLine(String.Format("# User Query: {0}", encJob.CustomQuery));\r
+            }\r
+            logHeader.AppendLine("-------------------------------------------");\r
+\r
+            return logHeader.ToString();\r
+        }\r
+    }\r
+}
\ No newline at end of file
similarity index 93%
rename from win/C#/Functions/System.cs
rename to win/C#/HandBrake.ApplicationServices/Functions/System.cs
index fb830fb..b2ee6ed 100644 (file)
@@ -3,9 +3,10 @@
     Homepage: <http://handbrake.fr>.\r
     It may be used under the terms of the GNU General Public License. */\r
 \r
-namespace Handbrake.Functions\r
+namespace HandBrake.ApplicationServices.Functions\r
 {\r
     using System.Windows.Forms;\r
+\r
     using Microsoft.Win32;\r
 \r
     /// <summary>\r
index 148ba78..bc6c04d 100644 (file)
     <Compile Include="frmExceptionWindow.Designer.cs">\r
       <DependentUpon>frmExceptionWindow.cs</DependentUpon>\r
     </Compile>\r
+    <Compile Include="Functions\Logging.cs" />\r
     <Compile Include="Functions\GrowlCommunicator.cs" />\r
     <Compile Include="Functions\Main.cs" />\r
+    <Compile Include="Functions\System.cs" />\r
     <Compile Include="Functions\Win32.cs" />\r
     <Compile Include="Functions\Win7.cs" />\r
     <Compile Include="Init.cs" />\r
index 7f1e1ed..d279a0b 100644 (file)
@@ -16,6 +16,9 @@ namespace HandBrake.ApplicationServices
         /// <summary>\r
         /// Setup the Settings used by the applicaiton with this library\r
         /// </summary>\r
+        /// <param name="versionString">\r
+        /// The version / name of the application that's using this DLL.\r
+        /// </param>\r
         /// <param name="instanceId">\r
         /// The Instance ID\r
         /// </param>\r
@@ -49,11 +52,12 @@ namespace HandBrake.ApplicationServices
         /// <param name="preventSleep">\r
         /// Prevent the system from sleeping\r
         /// </param>\r
-        public static void SetupSettings(int instanceId, string completionOption, bool disableDvdNav,\r
+        public static void SetupSettings(string versionString, int instanceId, string completionOption, bool disableDvdNav,\r
                                   bool growlEncode, bool growlQueue, string processPriority, string saveLogPath, bool saveLogToSpecifiedPath,\r
                                   bool saveLogWithVideo, bool showCliForInGuiEncodeStatus, bool preventSleep)\r
         {\r
             InstanceId = instanceId;\r
+            HandBrakeGuiVersionString = versionString;\r
             Properties.Settings.Default.CompletionOption = completionOption;\r
             Properties.Settings.Default.disableDvdNav = disableDvdNav;\r
             Properties.Settings.Default.growlEncode = growlEncode;\r
@@ -79,6 +83,14 @@ namespace HandBrake.ApplicationServices
             return Assembly.GetExecutingAssembly().GetName().Version;\r
         }\r
 \r
+        /// <summary>\r
+        /// The instance ID used by the Main Applicaiton\r
+        /// </summary>\r
         public static int InstanceId;\r
+\r
+        /// <summary>\r
+        /// The Applicaiton that uses this DLL can pass in it's version string.\r
+        /// </summary>\r
+        public static string HandBrakeGuiVersionString;\r
     }\r
 }\r
index 9d4b375..5360691 100644 (file)
@@ -8,7 +8,7 @@ namespace HandBrake.ApplicationServices.Model
     /// <summary>\r
     /// The job.\r
     /// </summary>\r
-    public struct Job\r
+    public class Job\r
     {\r
         /// <summary>\r
         /// Gets or sets the job ID.\r
index 9ef1b2c..c21d837 100644 (file)
@@ -261,22 +261,6 @@ namespace HandBrake.ApplicationServices.Services
 \r
         /* Helpers */\r
         /// <summary>\r
-        /// Add the CLI Query to the Log File.\r
-        /// </summary>\r
-        /// <param name="encJob">\r
-        /// The Encode Job Object\r
-        /// </param>\r
-        private static string CreateCliLogHeader(Job encJob)\r
-        {\r
-            StringBuilder logHeader = new StringBuilder();\r
-            logHeader.AppendLine("# CLI Query: " + encJob.Query);\r
-            logHeader.AppendLine("# User Query: " + encJob.CustomQuery);\r
-            logHeader.AppendLine("-------------------------------------------");\r
-\r
-            return logHeader.ToString();\r
-        }\r
-\r
-        /// <summary>\r
         /// Save a copy of the log to the users desired location or a default location\r
         /// if this feature is enabled in options.\r
         /// </summary>\r
@@ -430,8 +414,8 @@ namespace HandBrake.ApplicationServices.Services
 \r
                 fileWriter = new StreamWriter(logFile) { AutoFlush = true };\r
 \r
-                fileWriter.WriteLine(CreateCliLogHeader(encodeJob));\r
-                logBuffer.AppendLine(CreateCliLogHeader(encodeJob));\r
+                fileWriter.WriteLine(Logging.CreateCliLogHeader(encodeJob));\r
+                logBuffer.AppendLine(Logging.CreateCliLogHeader(encodeJob));\r
             }\r
             catch (Exception exc)\r
             {\r
index 039cb3f..04c35e3 100644 (file)
@@ -191,10 +191,11 @@ namespace HandBrake.ApplicationServices.Services
 \r
                 // Write the Buffer out to file.\r
                 StreamWriter scanLog = new StreamWriter(dvdInfoPath);\r
+                scanLog.WriteLine(Logging.CreateCliLogHeader(null));\r
                 scanLog.Write(this.readData.Buffer);\r
                 scanLog.Flush();\r
                 scanLog.Close();\r
-                logBuffer = readData.Buffer;\r
+                logBuffer.AppendLine(this.readData.Buffer.ToString());\r
 \r
                 IsScanning = false;\r
 \r
@@ -268,6 +269,7 @@ namespace HandBrake.ApplicationServices.Services
         {\r
             logFilePosition = 0;\r
             logBuffer = new StringBuilder();\r
+            logBuffer.AppendLine(Logging.CreateCliLogHeader(null));\r
         }\r
 \r
         /// <summary>\r
index 76042e2..0a94759 100644 (file)
     <Compile Include="Functions\PresetLoader.cs" />\r
     <Compile Include="Functions\QueryGenerator.cs" />\r
     <Compile Include="Functions\Main.cs" />\r
-    <Compile Include="Functions\System.cs" />\r
     <Compile Include="Functions\UpdateCheckInformation.cs" />\r
     <Compile Include="Functions\Win32.cs" />\r
     <Compile Include="frmActivityWindow.cs">\r
index f54a775..1c428c8 100644 (file)
@@ -91,7 +91,8 @@ namespace Handbrake
         /// </summary>\r
         private static void InitializeApplicationServices()\r
         {\r
-            Init.SetupSettings(InstanceId, Settings.Default.CompletionOption, Settings.Default.noDvdNav,\r
+            string versionId = String.Format("Windows GUI {1} {0}", Settings.Default.hb_build, Settings.Default.hb_version);\r
+            Init.SetupSettings(versionId, InstanceId, Settings.Default.CompletionOption, Settings.Default.noDvdNav,\r
                                Settings.Default.growlEncode, Settings.Default.growlQueue,\r
                                Settings.Default.processPriority, Settings.Default.saveLogPath, Settings.Default.saveLogToSpecifiedPath,\r
                                Settings.Default.saveLogWithVideo, Settings.Default.showCliForInGuiEncodeStatus, Settings.Default.preventSleep);\r
index d890a78..62799e9 100644 (file)
@@ -12,7 +12,6 @@ namespace Handbrake
     using System.Text;\r
     using System.Threading;\r
     using System.Windows.Forms;\r
-    using Functions;\r
 \r
     using HandBrake.ApplicationServices.Services.Interfaces;\r
 \r
@@ -231,7 +230,6 @@ namespace Handbrake
                     appendText.AppendFormat("Waiting for the log to be generated ...\n");\r
                     position = 0;\r
                     ClearWindowText();\r
-                    PrintLogHeader();\r
                     return appendText;\r
                 }\r
 \r
@@ -247,7 +245,6 @@ namespace Handbrake
                     appendText.AppendFormat("Waiting for the log to be generated ...\n");\r
                     position = 0;\r
                     ClearWindowText();\r
-                    PrintLogHeader();\r
                     return appendText;\r
                 }\r
 \r
@@ -343,48 +340,6 @@ namespace Handbrake
         }\r
 \r
         /// <summary>\r
-        /// Display the log header\r
-        /// </summary>\r
-        private void PrintLogHeader()\r
-        {\r
-            try\r
-            {\r
-                if (IsHandleCreated)\r
-                {\r
-                    if (rtf_actLog.InvokeRequired)\r
-                    {\r
-                        IAsyncResult invoked = BeginInvoke(new SetTextClearCallback(PrintLogHeader));\r
-                        EndInvoke(invoked);\r
-                    }\r
-                    else\r
-                    {\r
-                        lock (rtf_actLog)\r
-                        {\r
-                            // Print the log header. This function will be re-implimented later. Do not delete.\r
-                            StringBuilder header = new StringBuilder();\r
-\r
-                            header.Append(String.Format("### Windows GUI {1} {0} \n", Properties.Settings.Default.hb_build, Properties.Settings.Default.hb_version));\r
-                            header.Append(String.Format("### Running: {0} \n###\n", Environment.OSVersion));\r
-                            header.Append(String.Format("### CPU: {0} \n", SystemInfo.GetCpuCount));\r
-                            header.Append(String.Format("### Ram: {0} MB \n", SystemInfo.TotalPhysicalMemory));\r
-                            header.Append(String.Format("### Screen: {0}x{1} \n", SystemInfo.ScreenBounds.Bounds.Width, SystemInfo.ScreenBounds.Bounds.Height));\r
-                            header.Append(String.Format("### Temp Dir: {0} \n", Path.GetTempPath()));\r
-                            header.Append(String.Format("### Install Dir: {0} \n", Application.StartupPath));\r
-                            header.Append(String.Format("### Data Dir: {0} \n", Application.UserAppDataPath));\r
-                            header.Append("#########################################\n\n");\r
-\r
-                            rtf_actLog.AppendText(header.ToString());\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-            catch (Exception)\r
-            {\r
-                return;\r
-            }\r
-        }\r
-\r
-        /// <summary>\r
         /// Reset Everything\r
         /// </summary>\r
         private void Reset()\r
@@ -393,7 +348,6 @@ namespace Handbrake
                 windowTimer.Dispose();\r
             position = 0;\r
             ClearWindowText();\r
-            PrintLogHeader();\r
             windowTimer = new Timer(new TimerCallback(LogMonitor), null, 1000, 1000);\r
         }\r
 \r
index 7ca71dc..4475d90 100644 (file)
@@ -473,7 +473,8 @@ namespace Handbrake
         /// </summary>\r
         private static void UpdateApplicationServicesSettings()\r
         {\r
-            Init.SetupSettings(Program.InstanceId, Settings.Default.CompletionOption, Settings.Default.noDvdNav,\r
+            string versionId = String.Format("Windows GUI {1} {0}", Settings.Default.hb_build, Settings.Default.hb_version);\r
+            Init.SetupSettings(versionId, Program.InstanceId, Settings.Default.CompletionOption, Settings.Default.noDvdNav,\r
                                Settings.Default.growlEncode, Settings.Default.growlQueue,\r
                                Settings.Default.processPriority, Settings.Default.saveLogPath, Settings.Default.saveLogToSpecifiedPath,\r
                                Settings.Default.saveLogWithVideo, Settings.Default.showCliForInGuiEncodeStatus, Settings.Default.preventSleep);\r