OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Thu, 21 Jan 2010 20:47:15 +0000 (20:47 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Thu, 21 Jan 2010 20:47:15 +0000 (20:47 +0000)
- Some code refactoring.

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

win/C#/EncodeQueue/Encode.cs
win/C#/EncodeQueue/Job.cs
win/C#/EncodeQueue/Queue.cs
win/C#/Functions/AppcastReader.cs
win/C#/Functions/Main.cs
win/C#/frmActivityWindow.cs
win/C#/frmPreview.cs
win/C#/frmUpdater.cs

index 8beca3f..49a836b 100644 (file)
@@ -14,20 +14,38 @@ namespace Handbrake.EncodeQueue
 {\r
     public class Encode\r
     {\r
+        private int ProcessID { get; set; }\r
+\r
+        /// <summary>\r
+        /// The HB Process\r
+        /// </summary>\r
         public Process HbProcess { get; set; }\r
-        public int ProcessID { get; set; }\r
+        \r
+        /// <summary>\r
+        /// The Process Handle\r
+        /// </summary>\r
         public IntPtr ProcessHandle { get; set; }\r
-        public String CurrentQuery { get; set; }\r
-        public Boolean IsEncoding { get; set; }\r
+        \r
+        /// <summary>\r
+        /// Returns true of HandBrakeCLI.exe is running\r
+        /// </summary>\r
+        public Boolean IsEncoding { get; set; }     \r
 \r
+        /// <summary>\r
+        /// Fires when a new CLI Job starts\r
+        /// </summary>\r
         public event EventHandler EncodeStarted;\r
+\r
+        /// <summary>\r
+        /// Fires when a CLI job finishes.\r
+        /// </summary>\r
         public event EventHandler EncodeEnded;\r
 \r
         /// <summary>\r
         /// Create a preview sample video\r
         /// </summary>\r
         /// <param name="query"></param>\r
-        public void CreatePreviewSampe(string query)\r
+        public void CreatePreviewSample(string query)\r
         {\r
             Run(query);\r
         }\r
@@ -63,7 +81,7 @@ namespace Handbrake.EncodeQueue
                 Process[] before = Process.GetProcesses(); // Get a list of running processes before starting.\r
                 HbProcess = Process.Start(cliStart);\r
                 ProcessID = Main.GetCliProcess(before);\r
-                CurrentQuery = query;\r
+\r
                 if (HbProcess != null)\r
                     ProcessHandle = HbProcess.MainWindowHandle; // Set the process Handle\r
 \r
@@ -125,7 +143,6 @@ namespace Handbrake.EncodeQueue
         protected void Finish()\r
         {\r
             IsEncoding = false;\r
-            CurrentQuery = String.Empty;\r
 \r
             //Growl\r
             if (Properties.Settings.Default.growlQueue)\r
index 5771ece..7dfe7e5 100644 (file)
@@ -5,7 +5,6 @@
           It may be used under the terms of the GNU General Public License. */\r
 \r
 using System;\r
-using Handbrake.Parsing;\r
 \r
 namespace Handbrake.EncodeQueue\r
 {\r
index 0372d90..87db876 100644 (file)
@@ -12,7 +12,6 @@ using System.Threading;
 using System.Windows.Forms;\r
 using System.Xml.Serialization;\r
 using Handbrake.Functions;\r
-using Handbrake.Parsing;\r
 \r
 namespace Handbrake.EncodeQueue\r
 {\r
@@ -316,13 +315,9 @@ namespace Handbrake.EncodeQueue
         }\r
 \r
         /// <summary>\r
-        /// Stops the current job.\r
+        /// Run through all the jobs on the queue.\r
         /// </summary>\r
-        public void End()\r
-        {\r
-            Stop();\r
-        }\r
-\r
+        /// <param name="state"></param>\r
         private void StartQueue(object state)\r
         {\r
             // Run through each item on the queue\r
index 7f1e90b..ea9cac1 100644 (file)
@@ -16,7 +16,7 @@ namespace Handbrake.Functions
         /// <summary>\r
         /// Get the build information from the required appcasts. Run before accessing the public vars.\r
         /// </summary>\r
-        public void getInfo(string input)\r
+        public void GetInfo(string input)\r
         {\r
             try\r
             {\r
@@ -28,13 +28,14 @@ namespace Handbrake.Functions
                 Match ver = Regex.Match(result, @"sparkle:version=""([0-9]*)\""");\r
                 Match verShort = Regex.Match(result, @"sparkle:shortVersionString=""(([svn]*)([0-9.\s]*))\""");\r
 \r
-                build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", "");\r
-                version = verShort.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");\r
-                downloadFile = nodeItem["windows"].InnerText;\r
-                descriptionUrl = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText);\r
-            } catch( Exception)\r
+                Build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", "");\r
+                Version = verShort.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");\r
+                DownloadFile = nodeItem["windows"].InnerText;\r
+                DescriptionUrl = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText);\r
+            } \r
+            catch( Exception)\r
             {\r
-                // Ignore Error.\r
+                return;\r
             }\r
         }\r
 \r
@@ -51,24 +52,24 @@ namespace Handbrake.Functions
             XmlDocument rssDoc = new XmlDocument();\r
             rssDoc.Load(rssReader);\r
 \r
-            for (int i = 0; i < rssDoc.ChildNodes.Count; i++)\r
+            foreach (XmlNode t in rssDoc.ChildNodes)\r
             {\r
-                if (rssDoc.ChildNodes[i].Name == "rss")\r
-                    nodeRss = rssDoc.ChildNodes[i];\r
+                if (t.Name == "rss")\r
+                    nodeRss = t;\r
             }\r
 \r
             if (nodeRss != null)\r
-                for (int i = 0; i < nodeRss.ChildNodes.Count; i++)\r
+                foreach (XmlNode t in nodeRss.ChildNodes)\r
                 {\r
-                    if (nodeRss.ChildNodes[i].Name == "channel")\r
-                        nodeChannel = nodeRss.ChildNodes[i];\r
+                    if (t.Name == "channel")\r
+                        nodeChannel = t;\r
                 }\r
 \r
             if (nodeChannel != null)\r
-                for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)\r
+                foreach (XmlNode t in nodeChannel.ChildNodes)\r
                 {\r
-                    if (nodeChannel.ChildNodes[i].Name == "item")\r
-                        nodeItem = nodeChannel.ChildNodes[i];\r
+                    if (t.Name == "item")\r
+                        nodeItem = t;\r
                 }\r
 \r
             return nodeItem;\r
@@ -77,21 +78,21 @@ namespace Handbrake.Functions
         /// <summary>\r
         /// Get Information about an update to HandBrake\r
         /// </summary>\r
-        public Uri descriptionUrl { get; set; }\r
+        public Uri DescriptionUrl { get; set; }\r
 \r
         /// <summary>\r
         /// Get HandBrake's version from the appcast.xml file.\r
         /// </summary>\r
-        public string version { get; set; }\r
+        public string Version { get; set; }\r
 \r
         /// <summary>\r
         /// Get HandBrake's Build from the appcast.xml file.\r
         /// </summary>\r
-        public string build { get; set; }\r
+        public string Build { get; set; }\r
 \r
         /// <summary>\r
         /// Get's the URL for update file.\r
         /// </summary>\r
-        public string downloadFile { get; set; }\r
+        public string DownloadFile { get; set; }\r
     }\r
 }
\ No newline at end of file
index f218767..e9c4442 100644 (file)
@@ -373,7 +373,6 @@ namespace Handbrake.Functions
             }\r
         }\r
 \r
-\r
         /// <summary>\r
         /// Begins checking for an update to HandBrake.\r
         /// </summary>\r
@@ -394,10 +393,10 @@ namespace Handbrake.Functions
                     AppcastReader reader = new AppcastReader();\r
 \r
                     // Get the data, convert it to a string, and parse it into the AppcastReader\r
-                    reader.getInfo(new StreamReader(response.GetResponseStream()).ReadToEnd());\r
+                    reader.GetInfo(new StreamReader(response.GetResponseStream()).ReadToEnd());\r
 \r
                     // Further parse the information\r
-                    string build = reader.build;\r
+                    string build = reader.Build;\r
 \r
                     int latest = int.Parse(build);\r
                     int current = Properties.Settings.Default.hb_build;\r
index a4d5cd2..ca4edcf 100644 (file)
@@ -105,7 +105,7 @@ namespace Handbrake
                     sr.Dispose();\r
 \r
                 }\r
-                catch (Exception exc)\r
+                catch (Exception)\r
                 {\r
                     Reset();\r
                     appendText = new StringBuilder();\r
index 8cd51a6..6118b43 100644 (file)
@@ -110,7 +110,7 @@ namespace Handbrake
                 MessageBox.Show(this, "Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
             else\r
             {\r
-                Process.CreatePreviewSampe((string)state);\r
+                Process.CreatePreviewSample((string)state);\r
                 if (Process.HbProcess != null)\r
                 {\r
                     Process.HbProcess.WaitForExit();\r
index 816e00f..1237606 100644 (file)
@@ -12,31 +12,31 @@ namespace Handbrake
 {\r
     public partial class frmUpdater : Form\r
     {\r
-        readonly AppcastReader _appcast;\r
+        readonly AppcastReader Appcast;\r
         public frmUpdater(AppcastReader reader)\r
         {\r
             InitializeComponent();\r
 \r
-            _appcast = reader;\r
+            Appcast = reader;\r
             GetRss();\r
             SetVersions();\r
         }\r
 \r
         private void GetRss()\r
         {\r
-            wBrowser.Url = _appcast.descriptionUrl;\r
+            wBrowser.Url = Appcast.DescriptionUrl;\r
         }\r
 \r
         private void SetVersions()\r
         {\r
             string old = "(You have: " + Properties.Settings.Default.hb_version.Trim() + " / " + Properties.Settings.Default.hb_build.ToString().Trim() + ")";\r
-            string newBuild = _appcast.version.Trim() + " (" + _appcast.build + ")";\r
+            string newBuild = Appcast.Version.Trim() + " (" + Appcast.Build + ")";\r
             lbl_update_text.Text = "HandBrake " + newBuild + " is now available. " + old;\r
         }\r
 \r
         private void btn_installUpdate_Click(object sender, EventArgs e)\r
         {\r
-            frmDownload download = new frmDownload(_appcast.downloadFile);\r
+            frmDownload download = new frmDownload(Appcast.DownloadFile);\r
             download.ShowDialog();\r
             this.Close();\r
         }\r
@@ -48,7 +48,7 @@ namespace Handbrake
 \r
         private void btn_skip_Click(object sender, EventArgs e)\r
         {\r
-            Properties.Settings.Default.skipversion = int.Parse(_appcast.build);\r
+            Properties.Settings.Default.skipversion = int.Parse(Appcast.Build);\r
             Properties.Settings.Default.Save();\r
 \r
             this.Close();\r