OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / frmActivityWindow.cs
index 6b1ffee..5f41c79 100644 (file)
@@ -10,7 +10,6 @@ using System.Text;
 using System.Windows.Forms;\r
 using System.IO;\r
 using System.Threading;\r
-using Handbrake.EncodeQueue;\r
 using Handbrake.Functions;\r
 using Microsoft.Win32;\r
 \r
@@ -24,11 +23,13 @@ namespace Handbrake
         private static int _position;\r
         private static string _lastMode;\r
         private static string _currentMode;\r
-        private Thread monitor;\r
-        private Boolean kilLThread;\r
+        private Thread _monitor;\r
+        private Boolean _kilLThread;\r
 \r
         public frmActivityWindow(string mode)\r
         {\r
+            _kilLThread = false;\r
+            _position = 0;\r
             if (mode == "scan")\r
                 SetScanMode();\r
             else\r
@@ -38,17 +39,15 @@ namespace Handbrake
         }\r
         private void NewActivityWindow_Load(object sender, EventArgs e)\r
         {\r
-            monitor = new Thread(LogMonitor);\r
-            _position = 0;\r
-            kilLThread = false;\r
-\r
+            _monitor = new Thread(LogMonitor);\r
+            \r
             try\r
             {\r
-                monitor.Start();\r
+                _monitor.Start();\r
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show(exc.ToString());\r
+                MessageBox.Show("Unable to monitor HandBrakes log files. Please report this error. If the problem presists, try rebooting your computer.\n\n Debug Informaton:\n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
         }\r
 \r
@@ -56,17 +55,13 @@ namespace Handbrake
         {\r
             while (true)\r
             {\r
-                if (!IsHandleCreated || kilLThread) // break out the thread if the window has been disposed.\r
+                if (!IsHandleCreated || _kilLThread) // break out the thread if the window has been disposed.\r
                     break;\r
 \r
                 // Perform a reset if require.\r
                 // If we have switched to a different log file, we want to start from the beginning.\r
                 if (SetLogFile != _lastMode)\r
-                {\r
-                    _position = 0;\r
-                    ClearWindowText();\r
-                    PrintLogHeader();\r
-                }\r
+                    Reset();\r
 \r
                 // Perform the window update\r
                 switch (SetLogFile)\r
@@ -140,7 +135,7 @@ namespace Handbrake
             }\r
             catch (Exception exc)\r
             {\r
-                appendText.AppendFormat("\nERROR: The Log file could not be read. You may need to restart HandBrake! " + exc);\r
+                appendText.AppendFormat("\n The Log file could not be read. You may need to restart HandBrake! " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
                 _position = 0;\r
                 ClearWindowText();\r
             }\r
@@ -166,7 +161,7 @@ namespace Handbrake
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("SetWindowText(): Exception: \n" + exc);\r
+                MessageBox.Show("Unless you are having problems, you can probably ignore this error. It would not hurt to report this error!\n\nSetWindowText(): Exception: \n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
             }\r
         }\r
         private void ClearWindowText()\r
@@ -186,10 +181,10 @@ namespace Handbrake
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("ClearWindowText(): Exception: \n" + exc);\r
+                MessageBox.Show("Unless you are having problems, you can probably ignore this error. It would not hurt to report this error!\n\nClearWindowText(): Exception: \n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
             }\r
         }\r
-        public void PrintLogHeader()\r
+        private void PrintLogHeader()\r
         {\r
             try\r
             {\r
@@ -217,10 +212,16 @@ namespace Handbrake
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("PrintLogHeader(): Exception: \n" + exc);\r
+                MessageBox.Show("Unless you are having problems, you can probably ignore this error. It would not hurt to report this error!\n\nPrintLogHeader(): Exception: \n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
             }\r
 \r
         }\r
+        private void Reset()\r
+        {\r
+            _position = 0;\r
+            ClearWindowText();\r
+            PrintLogHeader();\r
+        }\r
 \r
         #region Public\r
 \r
@@ -231,11 +232,13 @@ namespace Handbrake
         }\r
         public void SetScanMode()\r
         {\r
+            Reset();\r
             SetLogFile = "last_scan_log.txt";\r
             this.Text = "Activity Window (Scan Log)";\r
         }\r
         public void SetEncodeMode()\r
         {\r
+            Reset();\r
             SetLogFile = "last_encode_log.txt";\r
             this.Text = "Activity Window (Enocde Log)";\r
         }\r
@@ -315,9 +318,9 @@ namespace Handbrake
 \r
         protected override void OnClosing(CancelEventArgs e)\r
         {\r
-            kilLThread = true;\r
-            monitor.Interrupt();\r
-            monitor.Join();\r
+            _kilLThread = true;\r
+            _monitor.Interrupt();\r
+            _monitor.Join();\r
             e.Cancel = true;\r
             this.Dispose();\r
             base.OnClosing(e);\r