OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 23 May 2010 15:35:57 +0000 (15:35 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 23 May 2010 15:35:57 +0000 (15:35 +0000)
- Added some new events to the Queue for future refactoring.
- Refactor / Cleanup / Remove more stylecop warnings.

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

17 files changed:
win/C#/Controls/Filters.cs
win/C#/Controls/Subtitles.cs
win/C#/Controls/x264Panel.cs
win/C#/Functions/Main.cs
win/C#/Functions/PresetLoader.cs
win/C#/Functions/QueryGenerator.cs
win/C#/Functions/System.cs
win/C#/Functions/Win32.cs
win/C#/Presets/PlistPresetHandler.cs
win/C#/Program.cs
win/C#/Services/Queue.cs
win/C#/frmAbout.cs
win/C#/frmDownload.cs
win/C#/frmMain.cs
win/C#/frmPreview.cs
win/C#/frmQueue.Designer.cs
win/C#/frmQueue.cs

index c8427bb..9f75f69 100644 (file)
@@ -1,5 +1,4 @@
 /*  Filters.cs $\r
-       \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
@@ -30,7 +29,7 @@ namespace Handbrake.Controls
         }\r
 \r
         /// <summary>\r
-        /// Returns the CLI query for the query generator.\r
+        /// Gets the CLI query for the query generator.\r
         /// </summary>\r
         public string GetCliQuery\r
         {\r
@@ -54,7 +53,6 @@ namespace Handbrake.Controls
                         break;\r
                 }\r
 \r
-\r
                 switch (drop_decomb.Text) // Decomb\r
                 {\r
                     case "Off":\r
index 3326ee7..fc93157 100644 (file)
@@ -84,7 +84,6 @@ namespace Handbrake.Controls
                                    ? srtLangVal + " (" + srtFile + ")"\r
                                    : drp_subtitleTracks.SelectedItem.ToString();\r
 \r
-\r
             SubtitleInfo track = new SubtitleInfo\r
                                      {\r
                                          Track = trackName, \r
@@ -433,7 +432,7 @@ namespace Handbrake.Controls
         /// Automatically setup the subtitle tracks.\r
         /// This handles the automatic setup of subitles which the user can control from the program options\r
         /// </summary>\r
-        /// <param name="subs"></param>\r
+        /// <param name="subs">List of Subtitles</param>\r
         public void SetSubtitleTrackAuto(object[] subs)\r
         {\r
             drp_subtitleTracks.Items.Clear();\r
@@ -464,7 +463,7 @@ namespace Handbrake.Controls
         /// <summary>\r
         /// Set the file container which is currently in use.\r
         /// </summary>\r
-        /// <param name="value"></param>\r
+        /// <param name="value">The File Container</param>\r
         public void SetContainer(int value)\r
         {\r
             fileContainer = value;\r
@@ -484,16 +483,16 @@ namespace Handbrake.Controls
         /// <summary>\r
         /// Get the list of subtitles.\r
         /// </summary>\r
-        /// <returns></returns>\r
+        /// <returns>A List of SubtitleInfo Object</returns>\r
         public List<SubtitleInfo> GetSubtitleInfoList()\r
         {\r
             return subList;\r
         }\r
 \r
         /// <summary>\r
-        /// Get the CLI Query for this panel\r
+        /// Gets the CLI Query for this panel\r
         /// </summary>\r
-        /// <returns></returns>\r
+        /// <returns>A CliQuery string</returns>\r
         public string GetCliQuery\r
         {\r
             get\r
index 4b943e3..a3bfd7a 100644 (file)
@@ -353,6 +353,9 @@ namespace Handbrake.Controls
         /// <summary>\r
         /// This function will update the X264 Query when one of the GUI widgets changes.\r
         /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
         private void OnX264WidgetChange(string sender)\r
         {\r
             Animate(sender);\r
@@ -376,8 +379,8 @@ namespace Handbrake.Controls
         /// Called when the current x264 option string contains multiple (or a single) item(s) in it seperated by :\r
         /// it updates the current option that the widget corrosponds to, if it is already in thes string.\r
         /// </summary>\r
-        /// <param name="currentOptString"></param>\r
-        /// <param name="optNameToChange"></param>\r
+        /// <param name="currentOptString">The Current Option String</param>\r
+        /// <param name="optNameToChange">Name of the option to change</param>\r
         private void HasOptions(string currentOptString, string optNameToChange)\r
         {\r
             string thisOpt; // The separated option such as "bframes=3"\r
@@ -440,8 +443,8 @@ namespace Handbrake.Controls
                                 thisOpt = string.Empty;\r
                             else\r
                             {\r
-                                double psyrd = slider_psyrd.Value*0.1;\r
-                                double psytre = slider_psytrellis.Value*0.1;\r
+                                double psyrd = slider_psyrd.Value * 0.1;\r
+                                double psytre = slider_psytrellis.Value * 0.1;\r
 \r
                                 string rd = psyrd.ToString("f1");\r
                                 string rt = psytre.ToString("f1");\r
@@ -592,7 +595,7 @@ namespace Handbrake.Controls
         /// Handles 2 cases.  1 Where rtf_x264Query.Text is empty, and one where there is an option with no value,\r
         /// e.g no-fast-pskip\r
         /// </summary>\r
-        /// <param name="optNameToChange"></param>\r
+        /// <param name="optNameToChange">The Option Name to Change</param>\r
         private void HasNoOptions(IEquatable<string> optNameToChange)\r
         {\r
             string colon = string.Empty;\r
@@ -705,8 +708,8 @@ namespace Handbrake.Controls
                     query += string.Empty;\r
                 else\r
                 {\r
-                    double psyrd = slider_psyrd.Value*0.1;\r
-                    double psytre = slider_psytrellis.Value*0.1;\r
+                    double psyrd = slider_psyrd.Value * 0.1;\r
+                    double psytre = slider_psytrellis.Value * 0.1;\r
 \r
                     string rd = psyrd.ToString("f1");\r
                     string rt = psytre.ToString("f1");\r
@@ -780,17 +783,17 @@ namespace Handbrake.Controls
         /// <summary>\r
         /// Shows and hides controls based on the values of other controls.\r
         /// </summary>\r
-        /// <param name="sender"></param>\r
+        /// <param name="sender">The Sender</param>\r
         private void Animate(string sender)\r
         {\r
             /* Lots of situations to cover.\r
-                  - B-frames (when 0 turn of b-frame specific stuff, when < 2 disable b-pyramid)\r
-                  - CABAC (when 0 turn off trellis)\r
-                  - analysis (if none, turn off 8x8dct)\r
-                  - refs (under 2, disable mixed-refs)\r
-                  - subme (if under 6, turn off psy-rd and psy-trel)\r
-                  - trellis (if 0, turn off psy-trel)\r
-               */\r
+               - B-frames (when 0 turn of b-frame specific stuff, when < 2 disable b-pyramid)\r
+               - CABAC (when 0 turn off trellis)\r
+               - analysis (if none, turn off 8x8dct)\r
+               - refs (under 2, disable mixed-refs)\r
+               - subme (if under 6, turn off psy-rd and psy-trel)\r
+               - trellis (if 0, turn off psy-trel)\r
+             */\r
 \r
             switch (sender)\r
             {\r
@@ -893,7 +896,6 @@ namespace Handbrake.Controls
                         slider_psyrd.Value = 10;\r
                         lbl_psyrd.Visible = false;\r
 \r
-\r
                         slider_psytrellis.Visible = false;\r
                         slider_psytrellis.Value = 0;\r
                         lbl_psytrellis.Visible = false;\r
@@ -931,7 +933,6 @@ namespace Handbrake.Controls
             }\r
         }\r
 \r
-\r
         private void widgetControlChanged(object sender, EventArgs e)\r
         {\r
             Control changedControlName = (Control) sender;\r
index 6d960ef..d7380b2 100644 (file)
@@ -815,5 +815,21 @@ namespace Handbrake.Functions
 \r
             return sb.ToString().Trim();\r
         }\r
+\r
+        /// <summary>\r
+        /// Show the Exception Window\r
+        /// </summary>\r
+        /// <param name="shortError">\r
+        /// The short error.\r
+        /// </param>\r
+        /// <param name="longError">\r
+        /// The long error.\r
+        /// </param>\r
+        public static void ShowExceptiowWindow(string shortError, string longError)\r
+        {\r
+            frmExceptionWindow exceptionWindow = new frmExceptionWindow();\r
+            exceptionWindow.Setup(shortError, longError);\r
+            exceptionWindow.Show();\r
+        }\r
     }\r
 }
\ No newline at end of file
index e2762af..f10bd00 100644 (file)
@@ -232,7 +232,7 @@ namespace Handbrake.Functions
                     break;\r
                 case "H.264 (x264)":\r
                     double cqStep = Properties.Settings.Default.x264cqstep;\r
-                    sliderValue = (int)((51.0 / cqStep) - (value/cqStep));\r
+                    sliderValue = (int)((51.0 / cqStep) - (value / cqStep));\r
                     break;\r
                 case "VP3 (Theora)":\r
                     sliderValue = (int)value;\r
index 2edfc9e..e4557df 100644 (file)
@@ -442,7 +442,6 @@ namespace Handbrake.Functions
             if (Properties.Settings.Default.noDvdNav)\r
                 query += " --no-dvdnav";\r
 \r
-\r
             return query;\r
         }\r
 \r
index 212579e..fb830fb 100644 (file)
@@ -25,7 +25,7 @@ namespace Handbrake.Functions
                 Win32.GlobalMemoryStatus(ref memStatus);\r
 \r
                 uint memoryInfo = memStatus.dwTotalPhys;\r
-                memoryInfo = memoryInfo/1024/1024;\r
+                memoryInfo = memoryInfo / 1024 / 1024;\r
 \r
                 return memoryInfo;\r
             }\r
index e7da9d5..89a0c29 100644 (file)
@@ -3,7 +3,6 @@
     Homepage: <http://handbrake.fr>.\r
     It may be used under the terms of the GNU General Public License. */\r
 \r
-\r
 namespace Handbrake.Functions\r
 {\r
     using System;\r
@@ -63,6 +62,7 @@ namespace Handbrake.Functions
             public UInt32 dwMemoryLoad;\r
 \r
             /// <summary>\r
+            /// Total Physical Memory\r
             /// </summary>\r
             public UInt32 dwTotalPhys; // Used\r
 \r
@@ -104,6 +104,18 @@ namespace Handbrake.Functions
             ref MEMORYSTATUS lpBuffer\r
         );\r
 \r
+        /// <summary>\r
+        /// Generate a Console Ctrl Event\r
+        /// </summary>\r
+        /// <param name="sigevent">\r
+        /// The sigevent.\r
+        /// </param>\r
+        /// <param name="dwProcessGroupId">\r
+        /// The dw process group id.\r
+        /// </param>\r
+        /// <returns>\r
+        /// Bool true is sucess\r
+        /// </returns>\r
         [DllImport("kernel32.dll", SetLastError = true)]\r
         public static extern bool GenerateConsoleCtrlEvent(ConsoleCtrlEvent sigevent, int dwProcessGroupId);\r
 \r
index 601065c..a030cfd 100644 (file)
@@ -31,7 +31,6 @@ namespace Handbrake.Presets
             QueryParser queryParsed = new QueryParser();\r
             string qualityMode = string.Empty;\r
 \r
-\r
             #region Get a List of Audio Track Objects\r
             XmlNode audioListDict = root.ChildNodes[2].ChildNodes[0].FirstChild.ChildNodes[1];\r
             ArrayList audioTracks = new ArrayList();\r
index 3ce379e..fa18674 100644 (file)
@@ -24,21 +24,24 @@ namespace Handbrake
         [STAThread]\r
         public static void Main()\r
         {\r
+            // Handle any unhandled exceptions\r
+            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);\r
+\r
+            // Attempt to upgrade / keep the users settings between versions\r
             if (Settings.Default.UpdateRequired)\r
             {\r
                 Settings.Default.Upgrade();\r
                 Settings.Default.UpdateRequired = false;\r
             }\r
 \r
-            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);\r
-\r
-            const string failedInstall = "HandBrake is not installed properly. Please reinstall HandBrake. \n\n";\r
-            const string nightlyCLIMissing =\r
+            // Make sure we have any pre-requesits before trying to launch\r
+            const string FailedInstall = "HandBrake is not installed properly. Please reinstall HandBrake. \n\n";\r
+            const string NightlyCLIMissing =\r
                 "If you have downloaded the \"HandBrakeGUI\" nightly, " +\r
                 "please make sure you have also downloaded the \"HandBrakeCLI\" nightly and extracted it's contents to the same folder. ";\r
             string missingFiles = string.Empty;\r
 \r
-            // Verify HandBrakeCLI.exe and ilibgcc_s_sjlj-1.dll exists\r
+            // Verify HandBrakeCLI.exe exists\r
             if (!File.Exists(Path.Combine(Application.StartupPath, "HandBrakeCLI.exe")))\r
             {\r
                 missingFiles += "\"HandBrakeCLI.exe\" was not found.";\r
@@ -47,7 +50,7 @@ namespace Handbrake
             if (missingFiles != string.Empty)\r
             {\r
                 MessageBox.Show(\r
-                    failedInstall + missingFiles + "\n\n" + nightlyCLIMissing,\r
+                    FailedInstall + missingFiles + "\n\n" + NightlyCLIMissing,\r
                     "Error",\r
                     MessageBoxButtons.OK,\r
                     MessageBoxIcon.Error);\r
index 695b585..d3d9430 100644 (file)
@@ -9,6 +9,7 @@ namespace Handbrake.Services
     using System.Collections.Generic;\r
     using System.Collections.ObjectModel;\r
     using System.IO;\r
+    using System.Linq;\r
     using System.Threading;\r
     using System.Windows.Forms;\r
     using System.Xml.Serialization;\r
@@ -36,6 +37,17 @@ namespace Handbrake.Services
         private int nextJobId;\r
 \r
         /// <summary>\r
+        /// Fires when the Queue has started\r
+        /// </summary>\r
+        public event EventHandler QueueStarted;\r
+\r
+        /// <summary>\r
+        /// Fires when a job is Added, Removed or Re-Ordered.\r
+        /// Should be used for triggering an update of the Queue Window.\r
+        /// </summary>\r
+        public event EventHandler QueueListChanged;\r
+\r
+        /// <summary>\r
         /// Fires when a pause to the encode queue has been requested.\r
         /// </summary>\r
         public event EventHandler QueuePauseRequested;\r
@@ -45,22 +57,17 @@ namespace Handbrake.Services
         /// </summary>\r
         public event EventHandler QueueCompleted;\r
 \r
-        #region Queue\r
-\r
+        #region Properties\r
         /// <summary>\r
-        /// Gets and removes the next job in the queue.\r
+        /// Gets or sets the last encode that was processed.\r
         /// </summary>\r
-        /// <returns>The job that was removed from the queue.</returns>\r
-        private Job GetNextJob()\r
-        {\r
-            Job job = this.queue[0];\r
-            this.LastEncode = job;\r
-            this.Remove(0); // Remove the item which we are about to pass out.\r
-\r
-            this.WriteQueueStateToFile("hb_queue_recovery.xml");\r
+        /// <returns></returns> \r
+        public Job LastEncode { get; set; }\r
 \r
-            return job;\r
-        }\r
+        /// <summary>\r
+        /// Gets a value indicating whether Request Pause\r
+        /// </summary>\r
+        public bool Paused { get; private set; }\r
 \r
         /// <summary>\r
         /// Gets the current state of the encode queue.\r
@@ -77,6 +84,24 @@ namespace Handbrake.Services
         {\r
             get { return this.queue.Count; }\r
         }\r
+        #endregion\r
+\r
+        #region Queue\r
+\r
+        /// <summary>\r
+        /// Gets and removes the next job in the queue.\r
+        /// </summary>\r
+        /// <returns>The job that was removed from the queue.</returns>\r
+        private Job GetNextJob()\r
+        {\r
+            Job job = this.queue[0];\r
+            this.LastEncode = job;\r
+            this.Remove(0); // Remove the item which we are about to pass out.\r
+\r
+            this.WriteQueueStateToFile("hb_queue_recovery.xml");\r
+\r
+            return job;\r
+        }\r
 \r
         /// <summary>\r
         /// Adds an item to the queue.\r
@@ -102,14 +127,17 @@ namespace Handbrake.Services
                              {\r
                                  Id = this.nextJobId++,\r
                                  Title = title,\r
-                                 Query = query, \r
-                                 Source = source, \r
-                                 Destination = destination, \r
+                                 Query = query,\r
+                                 Source = source,\r
+                                 Destination = destination,\r
                                  CustomQuery = customJob\r
                              };\r
 \r
             this.queue.Add(newJob);\r
             this.WriteQueueStateToFile("hb_queue_recovery.xml");\r
+\r
+            if (this.QueueListChanged != null)\r
+                this.QueueListChanged(this, new EventArgs());\r
         }\r
 \r
         /// <summary>\r
@@ -120,6 +148,9 @@ namespace Handbrake.Services
         {\r
             this.queue.RemoveAt(index);\r
             this.WriteQueueStateToFile("hb_queue_recovery.xml");\r
+\r
+            if (this.QueueListChanged != null)\r
+                this.QueueListChanged(this, new EventArgs());\r
         }\r
 \r
         /// <summary>\r
@@ -150,6 +181,9 @@ namespace Handbrake.Services
             }\r
 \r
             WriteQueueStateToFile("hb_queue_recovery.xml"); // Update the queue recovery file\r
+\r
+            if (this.QueueListChanged != null)\r
+                this.QueueListChanged(this, new EventArgs());\r
         }\r
 \r
         /// <summary>\r
@@ -167,6 +201,9 @@ namespace Handbrake.Services
             }\r
 \r
             this.WriteQueueStateToFile("hb_queue_recovery.xml"); // Update the queue recovery file\r
+\r
+            if (this.QueueListChanged != null)\r
+                this.QueueListChanged(this, new EventArgs());\r
         }\r
 \r
         /// <summary>\r
@@ -175,7 +212,7 @@ namespace Handbrake.Services
         /// <param name="file">The location of the file to write the queue to.</param>\r
         public void WriteQueueStateToFile(string file)\r
         {\r
-            string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), \r
+            string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),\r
                                               @"HandBrake\hb_queue_recovery.xml");\r
             string tempPath = file == "hb_queue_recovery.xml" ? appDataPath : file;\r
 \r
@@ -184,7 +221,7 @@ namespace Handbrake.Services
                 using (FileStream strm = new FileStream(tempPath, FileMode.Create, FileAccess.Write))\r
                 {\r
                     if (serializer == null)\r
-                        serializer = new XmlSerializer(typeof (List<Job>));\r
+                        serializer = new XmlSerializer(typeof(List<Job>));\r
                     serializer.Serialize(strm, queue);\r
                     strm.Close();\r
                     strm.Dispose();\r
@@ -226,14 +263,12 @@ namespace Handbrake.Services
                         line.WriteLine(strCmdLine);\r
                     }\r
 \r
-                    MessageBox.Show("Your batch script has been sucessfully saved.", "Status", MessageBoxButtons.OK, \r
+                    MessageBox.Show("Your batch script has been sucessfully saved.", "Status", MessageBoxButtons.OK,\r
                                     MessageBoxIcon.Asterisk);\r
                 }\r
-                catch (Exception)\r
+                catch (Exception exc)\r
                 {\r
-                    MessageBox.Show(\r
-                        "Unable to write to the file. Please make sure that the location has the correct permissions for file writing.", \r
-                        "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
+                    Main.ShowExceptiowWindow("Unable to write to the file. Please make sure that the location has the correct permissions for file writing.", exc.ToString());\r
                 }\r
             }\r
         }\r
@@ -244,7 +279,7 @@ namespace Handbrake.Services
         /// <param name="file">The location of the file to read the queue from.</param>\r
         public void LoadQueueFromFile(string file)\r
         {\r
-            string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), \r
+            string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),\r
                                               @"HandBrake\hb_queue_recovery.xml");\r
             string tempPath = file == "hb_queue_recovery.xml" ? appDataPath : file;\r
 \r
@@ -255,7 +290,7 @@ namespace Handbrake.Services
                     if (strm.Length != 0)\r
                     {\r
                         if (serializer == null)\r
-                            serializer = new XmlSerializer(typeof (List<Job>));\r
+                            serializer = new XmlSerializer(typeof(List<Job>));\r
 \r
                         List<Job> list = serializer.Deserialize(strm) as List<Job>;\r
 \r
@@ -277,13 +312,7 @@ namespace Handbrake.Services
         /// <returns>Whether or not the supplied destination is already in the queue.</returns>\r
         public bool CheckForDestinationDuplicate(string destination)\r
         {\r
-            foreach (Job checkItem in this.queue)\r
-            {\r
-                if (checkItem.Destination.Contains(destination.Replace("\\\\", "\\")))\r
-                    return true;\r
-            }\r
-\r
-            return false;\r
+            return this.queue.Any(checkItem => checkItem.Destination.Contains(destination.Replace("\\\\", "\\")));\r
         }\r
 \r
         #endregion\r
@@ -291,17 +320,6 @@ namespace Handbrake.Services
         #region Encoding\r
 \r
         /// <summary>\r
-        /// Gets or sets the last encode that was processed.\r
-        /// </summary>\r
-        /// <returns></returns> \r
-        public Job LastEncode { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets a value indicating whether Request Pause\r
-        /// </summary>\r
-        public bool PauseRequested { get; private set; }\r
-\r
-        /// <summary>\r
         /// Starts encoding the first job in the queue and continues encoding until all jobs\r
         /// have been encoded.\r
         /// </summary>\r
@@ -309,19 +327,22 @@ namespace Handbrake.Services
         {\r
             if (this.Count != 0)\r
             {\r
-                if (this.PauseRequested)\r
-                    this.PauseRequested = false;\r
+                if (this.Paused)\r
+                    this.Paused = false;\r
                 else\r
                 {\r
-                    this.PauseRequested = false;\r
+                    this.Paused = false;\r
                     try\r
                     {\r
-                        Thread theQueue = new Thread(this.StartQueue) {IsBackground = true};\r
+                        Thread theQueue = new Thread(this.StartQueue) { IsBackground = true };\r
                         theQueue.Start();\r
+\r
+                        if (this.QueueStarted != null)\r
+                            this.QueueStarted(this, new EventArgs());\r
                     }\r
                     catch (Exception exc)\r
                     {\r
-                        MessageBox.Show(exc.ToString());\r
+                        Main.ShowExceptiowWindow("Unable to Start Queue", exc.ToString());\r
                     }\r
                 }\r
             }\r
@@ -332,7 +353,7 @@ namespace Handbrake.Services
         /// </summary>\r
         public void Pause()\r
         {\r
-            this.PauseRequested = true;\r
+            this.Paused = true;\r
 \r
             if (this.QueuePauseRequested != null)\r
                 this.QueuePauseRequested(this, new EventArgs());\r
@@ -366,10 +387,10 @@ namespace Handbrake.Services
 \r
                 // Growl\r
                 if (Properties.Settings.Default.growlEncode)\r
-                    GrowlCommunicator.Notify("Encode Completed", \r
+                    GrowlCommunicator.Notify("Encode Completed",\r
                                              "Put down that cocktail...\nyour Handbrake encode is done.");\r
 \r
-                while (this.PauseRequested) // Need to find a better way of doing this.\r
+                while (this.Paused) // Need to find a better way of doing this.\r
                 {\r
                     Thread.Sleep(2000);\r
                 }\r
index d557621..6531cf1 100644 (file)
@@ -1,6 +1,5 @@
 /*  frmAbout.cs $\r
-       \r
-    This file is part of the HandBrake source code.\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
@@ -9,8 +8,14 @@ namespace Handbrake
     using System;\r
     using System.Windows.Forms;\r
 \r
+    /// <summary>\r
+    /// The About Window\r
+    /// </summary>\r
     public partial class frmAbout : Form\r
     {\r
+        /// <summary>\r
+        /// Initializes a new instance of the <see cref="frmAbout"/> class.\r
+        /// </summary>\r
         public frmAbout()\r
         {\r
             InitializeComponent();\r
@@ -18,6 +23,15 @@ namespace Handbrake
                                ") - " + Properties.Settings.Default.hb_platform;\r
         }\r
 \r
+        /// <summary>\r
+        /// Button - Close the window\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void btn_close_Click(object sender, EventArgs e)\r
         {\r
             this.Close();\r
index fb2b8ab..a3067e1 100644 (file)
@@ -1,5 +1,4 @@
 /*  frmDownload.cs $\r
-       \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
@@ -29,7 +28,6 @@ namespace Handbrake
 \r
         private delegate void DownloadFailedCallback();\r
 \r
-\r
         public frmDownload(string filename)\r
         {\r
             InitializeComponent();\r
@@ -86,10 +84,10 @@ namespace Handbrake
 \r
         private void UpdateProgress(long bytesRead, long totalBytes)\r
         {\r
-            long p = (bytesRead*100)/totalBytes;\r
+            long p = (bytesRead * 100) / totalBytes;\r
             int.TryParse(p.ToString(), out _progress);\r
             progress_download.Value = _progress;\r
-            lblProgress.Text = (bytesRead/1024) + "k of " + (totalBytes/1024) + "k ";\r
+            lblProgress.Text = (bytesRead / 1024) + "k of " + (totalBytes / 1024) + "k ";\r
         }\r
 \r
         private void DownloadComplete()\r
index 043b67e..958e179 100644 (file)
@@ -28,12 +28,14 @@ namespace Handbrake
         private Queue encodeQueue = new Queue();\r
         private PresetsHandler presetHandler = new PresetsHandler();\r
 \r
-        // Globals: Mainly used for tracking. *********************************\r
-        public Title selectedTitle;\r
+        // Windows ************************************************************\r
         private frmQueue queueWindow;\r
         private frmPreview qtpreview;\r
         private frmActivityWindow ActivityWindow;\r
-        private Form splash;\r
+        private frmSplashScreen splash = new frmSplashScreen();\r
+\r
+        // Globals: Mainly used for tracking. *********************************\r
+        public Title selectedTitle;\r
         public string sourcePath;\r
         private SourceType selectedSourceType;\r
         private string dvdDrivePath;\r
@@ -49,12 +51,34 @@ namespace Handbrake
 \r
         // Applicaiton Startup ************************************************\r
 \r
+        #region Properties\r
+\r
+        /// <summary>\r
+        /// Gets SourceName.\r
+        /// </summary>\r
+        public string SourceName\r
+        {\r
+            get\r
+            {\r
+                if (this.selectedSourceType == SourceType.DvdDrive)\r
+                {\r
+                    return this.dvdDriveLabel;\r
+                }\r
+\r
+                if (Path.GetFileNameWithoutExtension(this.sourcePath) != "VIDEO_TS")\r
+                    return Path.GetFileNameWithoutExtension(this.sourcePath);\r
+\r
+                return Path.GetFileNameWithoutExtension(Path.GetDirectoryName(this.sourcePath));\r
+            }\r
+        }\r
+\r
+        #endregion\r
+\r
         #region Application Startup\r
 \r
         public frmMain()\r
         {\r
             // Load and setup the splash screen in this thread\r
-            splash = new frmSplashScreen();\r
             splash.Show(this);\r
             Label lblStatus = new Label { Size = new Size(150, 20), Location = new Point(182, 102) };\r
             splash.Controls.Add(lblStatus);\r
@@ -62,8 +86,7 @@ namespace Handbrake
             InitializeComponent();\r
 \r
             // Update the users config file with the CLI version data.\r
-            lblStatus.Text = "Checking CLI Version Data ...";\r
-            Application.DoEvents();\r
+            UpdateSplashStatus(lblStatus, "Checking CLI Version Data ...");\r
             Main.SetCliVersionData();\r
             Main.CheckForValidCliVersion();\r
 \r
@@ -86,9 +109,7 @@ namespace Handbrake
                 TimeSpan elapsed = now.Subtract(lastCheck);\r
                 if (elapsed.TotalDays > Properties.Settings.Default.daysBetweenUpdateCheck)\r
                 {\r
-                    lblStatus.Text = "Checking for updates ...";\r
-                    Application.DoEvents();\r
-\r
+                    UpdateSplashStatus(lblStatus, "Checking for updates ...");\r
                     Main.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDone), false);\r
                 }\r
             }\r
@@ -96,15 +117,13 @@ namespace Handbrake
             // Clear the log files in the background\r
             if (Properties.Settings.Default.clearOldLogs)\r
             {\r
-                lblStatus.Text = "Clearing Old Log Files ...";\r
-                Application.DoEvents();\r
+                UpdateSplashStatus(lblStatus, "Clearing Old Log Files ..");\r
                 Thread clearLog = new Thread(Main.ClearOldLogs);\r
                 clearLog.Start();\r
             }\r
 \r
             // Setup the GUI components\r
-            lblStatus.Text = "Setting up the GUI ...";\r
-            Application.DoEvents();\r
+            UpdateSplashStatus(lblStatus, "Setting up the GUI ...");\r
             LoadPresetPanel(); // Load the Preset Panel\r
             treeView_presets.ExpandAll();\r
             lbl_encode.Text = string.Empty;\r
@@ -112,44 +131,33 @@ namespace Handbrake
             queueWindow = new frmQueue(encodeQueue, this); // Prepare the Queue\r
             if (!Properties.Settings.Default.QueryEditorTab)\r
                 tabs_panel.TabPages.RemoveAt(7); // Remove the query editor tab if the user does not want it enabled.\r
+            if (Properties.Settings.Default.tooltipEnable)\r
+                ToolTip.Active = true;\r
 \r
             // Load the user's default settings or Normal Preset\r
-            if (Properties.Settings.Default.defaultPreset != string.Empty)\r
+            if (Properties.Settings.Default.defaultPreset != string.Empty && presetHandler.GetPreset(Properties.Settings.Default.defaultPreset) != null)\r
             {\r
-                if (presetHandler.GetPreset(Properties.Settings.Default.defaultPreset) != null)\r
+                string query = presetHandler.GetPreset(Properties.Settings.Default.defaultPreset).Query;\r
+                if (query != null)\r
                 {\r
-                    string query = presetHandler.GetPreset(Properties.Settings.Default.defaultPreset).Query;\r
-                    bool loadPictureSettings =\r
-                        presetHandler.GetPreset(Properties.Settings.Default.defaultPreset).PictureSettings;\r
-\r
-                    if (query != null)\r
-                    {\r
-                        x264Panel.Reset2Defaults();\r
+                    x264Panel.Reset2Defaults();\r
 \r
-                        QueryParser presetQuery = QueryParser.Parse(query);\r
-                        PresetLoader.LoadPreset(this, presetQuery, Properties.Settings.Default.defaultPreset,\r
-                                                loadPictureSettings);\r
+                    QueryParser presetQuery = QueryParser.Parse(query);\r
+                    PresetLoader.LoadPreset(this, presetQuery, Properties.Settings.Default.defaultPreset,\r
+                                            presetHandler.GetPreset(Properties.Settings.Default.defaultPreset).PictureSettings);\r
 \r
-                        x264Panel.X264_StandardizeOptString();\r
-                        x264Panel.X264_SetCurrentSettingsInPanel();\r
-                    }\r
+                    x264Panel.X264_StandardizeOptString();\r
+                    x264Panel.X264_SetCurrentSettingsInPanel();\r
                 }\r
-                else\r
-                    loadNormalPreset();\r
             }\r
             else\r
                 loadNormalPreset();\r
 \r
-            // Enabled GUI tooltip's if Required\r
-            if (Properties.Settings.Default.tooltipEnable)\r
-                ToolTip.Active = true;\r
-\r
             // Register with Growl (if not using Growl for the encoding completion action, this wont hurt anything)\r
             GrowlCommunicator.Register();\r
 \r
             // Finished Loading\r
-            lblStatus.Text = "Loading Complete!";\r
-            Application.DoEvents();\r
+            UpdateSplashStatus(lblStatus, "Loading Complete.");\r
             splash.Close();\r
             splash.Dispose();\r
             this.Enabled = true;\r
@@ -182,9 +190,7 @@ namespace Handbrake
             catch (Exception ex)\r
             {\r
                 if ((bool)result.AsyncState)\r
-                    MessageBox.Show(\r
-                        "Unable to check for updates, Please try again later.\n\nDetailed Error Information:\n" + ex,\r
-                        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                    Main.ShowExceptiowWindow("Unable to check for updates, Please try again later.", ex.ToString());\r
             }\r
         }\r
 \r
@@ -210,24 +216,10 @@ namespace Handbrake
             }\r
         }\r
 \r
-        #endregion\r
-\r
-        #region Properties\r
-\r
-        public string SourceName\r
+        private void UpdateSplashStatus(Label status, string text)\r
         {\r
-            get\r
-            {\r
-                if (this.selectedSourceType == SourceType.DvdDrive)\r
-                {\r
-                    return this.dvdDriveLabel;\r
-                }\r
-\r
-                if (Path.GetFileNameWithoutExtension(this.sourcePath) != "VIDEO_TS")\r
-                    return Path.GetFileNameWithoutExtension(this.sourcePath);\r
-\r
-                return Path.GetFileNameWithoutExtension(Path.GetDirectoryName(this.sourcePath));\r
-            }\r
+            status.Text = text;\r
+            Application.DoEvents();\r
         }\r
 \r
         #endregion\r
@@ -245,7 +237,6 @@ namespace Handbrake
                 this.Resize += new EventHandler(frmMain_Resize);\r
 \r
             // Handle Encode Start / Finish / Pause\r
-\r
             encodeQueue.QueuePauseRequested += new EventHandler(encodePaused);\r
             encodeQueue.EncodeStarted += new EventHandler(encodeStarted);\r
             encodeQueue.EncodeEnded += new EventHandler(encodeEnded);\r
@@ -265,7 +256,7 @@ namespace Handbrake
             check_optimiseMP4.CheckedChanged += new EventHandler(changePresetLabel);\r
 \r
             // Picture Settings\r
-            // PictureSettings.PictureSettingsChanged += new EventHandler(changePresetLabel);\r
+            PictureSettings.PictureSettingsChanged += new EventHandler(changePresetLabel);\r
 \r
             // Filter Settings\r
             Filters.FilterSettingsChanged += new EventHandler(changePresetLabel);\r
@@ -294,7 +285,7 @@ namespace Handbrake
             check_optimiseMP4.CheckedChanged -= new EventHandler(changePresetLabel);\r
 \r
             // Picture Settings\r
-            // PictureSettings.PictureSettingsChanged -= new EventHandler(changePresetLabel);\r
+            PictureSettings.PictureSettingsChanged -= new EventHandler(changePresetLabel);\r
 \r
             // Filter Settings\r
             Filters.FilterSettingsChanged -= new EventHandler(changePresetLabel);\r
@@ -333,7 +324,7 @@ namespace Handbrake
 \r
             if (fileList != null)\r
             {\r
-                if (fileList[0] != string.Empty)\r
+                if (!string.IsNullOrEmpty(fileList[0]))\r
                 {\r
                     this.selectedSourceType = SourceType.VideoFile;\r
                     StartScan(fileList[0], 0);\r
@@ -373,11 +364,29 @@ namespace Handbrake
 \r
         #region File Menu\r
 \r
+        /// <summary>\r
+        /// Kill The scan menu Item\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void mnu_killCLI_Click(object sender, EventArgs e)\r
         {\r
             KillScan();\r
         }\r
 \r
+        /// <summary>\r
+        /// Exit the Application Menu Item\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void mnu_exit_Click(object sender, EventArgs e)\r
         {\r
             Application.Exit();\r
@@ -387,17 +396,44 @@ namespace Handbrake
 \r
         #region Tools Menu\r
 \r
+        /// <summary>\r
+        /// Menu - Start Button\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void mnu_encode_Click(object sender, EventArgs e)\r
         {\r
             queueWindow.Show();\r
         }\r
 \r
+        /// <summary>\r
+        /// Menu - Display the Log Window\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void mnu_encodeLog_Click(object sender, EventArgs e)\r
         {\r
             frmActivityWindow dvdInfoWindow = new frmActivityWindow(encodeQueue, SourceScan);\r
             dvdInfoWindow.Show();\r
         }\r
 \r
+        /// <summary>\r
+        /// Menu - Display the Options Window\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void mnu_options_Click(object sender, EventArgs e)\r
         {\r
             Form options = new frmOptions(this);\r
@@ -408,6 +444,15 @@ namespace Handbrake
 \r
         #region Presets Menu\r
 \r
+        /// <summary>\r
+        /// Reset the Built in Presets\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void mnu_presetReset_Click(object sender, EventArgs e)\r
         {\r
             presetHandler.UpdateBuiltInPresets();\r
@@ -422,28 +467,72 @@ namespace Handbrake
             treeView_presets.ExpandAll();\r
         }\r
 \r
+        /// <summary>\r
+        /// Delete the selected preset\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void mnu_delete_preset_Click(object sender, EventArgs e)\r
         {\r
             presetHandler.RemoveBuiltInPresets();\r
             LoadPresetPanel(); // Reload the preset panel\r
         }\r
 \r
+        /// <summary>\r
+        /// Select the Normal preset\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void mnu_SelectDefault_Click(object sender, EventArgs e)\r
         {\r
             loadNormalPreset();\r
         }\r
 \r
+        /// <summary>\r
+        /// Import a plist Preset\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void mnu_importMacPreset_Click(object sender, EventArgs e)\r
         {\r
             ImportPreset();\r
         }\r
 \r
+        /// <summary>\r
+        /// Export a Plist Preset\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void mnu_exportMacPreset_Click(object sender, EventArgs e)\r
         {\r
             ExportPreset();\r
         }\r
 \r
-\r
+        /// <summary>\r
+        /// Create a new Preset\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void btn_new_preset_Click(object sender, EventArgs e)\r
         {\r
             Form preset = new frmAddPreset(this, QueryGenerator.GenerateCliQuery(this, drop_mode.SelectedIndex, 0, null),\r
@@ -455,56 +544,44 @@ namespace Handbrake
 \r
         #region Help Menu\r
 \r
+        /// <summary>\r
+        /// Menu - Display the User Guide Web Page\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void mnu_user_guide_Click(object sender, EventArgs e)\r
         {\r
             Process.Start("http://trac.handbrake.fr/wiki/HandBrakeGuide");\r
         }\r
 \r
-        private void mnu_handbrake_home_Click(object sender, EventArgs e)\r
-        {\r
-            Process.Start("http://handbrake.fr");\r
-        }\r
-\r
+        /// <summary>\r
+        /// Menu - Check for Updates\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void mnu_UpdateCheck_Click(object sender, EventArgs e)\r
         {\r
             lbl_updateCheck.Visible = true;\r
             Main.BeginCheckForUpdates(new AsyncCallback(updateCheckDoneMenu), false);\r
         }\r
 \r
-        private void updateCheckDoneMenu(IAsyncResult result)\r
-        {\r
-            // Make sure it's running on the calling thread\r
-            if (InvokeRequired)\r
-            {\r
-                Invoke(new MethodInvoker(() => updateCheckDoneMenu(result)));\r
-                return;\r
-            }\r
-            UpdateCheckInformation info;\r
-            try\r
-            {\r
-                // Get the information about the new build, if any, and close the window\r
-                info = Main.EndCheckForUpdates(result);\r
-\r
-                if (info.NewVersionAvailable && info.BuildInformation != null)\r
-                {\r
-                    frmUpdater updateWindow = new frmUpdater(info.BuildInformation);\r
-                    updateWindow.ShowDialog();\r
-                }\r
-                else\r
-                    MessageBox.Show("There are no new updates at this time.", "Update Check", MessageBoxButtons.OK,\r
-                                    MessageBoxIcon.Information);\r
-                lbl_updateCheck.Visible = false;\r
-                return;\r
-            }\r
-            catch (Exception ex)\r
-            {\r
-                if ((bool)result.AsyncState)\r
-                    MessageBox.Show(\r
-                        "Unable to check for updates, Please try again later.\n\nDetailed Error Information:\n" + ex,\r
-                        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
-            }\r
-        }\r
-\r
+        /// <summary>\r
+        /// Menu - Display the About Window\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void mnu_about_Click(object sender, EventArgs e)\r
         {\r
             using (frmAbout About = new frmAbout())\r
@@ -517,22 +594,57 @@ namespace Handbrake
 \r
         #region Preset Bar\r
 \r
-        // Right Click Menu Code\r
+        /// <summary>\r
+        /// RMenu - Expand All\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void pmnu_expandAll_Click(object sender, EventArgs e)\r
         {\r
             treeView_presets.ExpandAll();\r
         }\r
 \r
+        /// <summary>\r
+        /// RMenu - Collaspe All\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void pmnu_collapse_Click(object sender, EventArgs e)\r
         {\r
             treeView_presets.CollapseAll();\r
         }\r
 \r
+        /// <summary>\r
+        /// Menu - Import Preset\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void pmnu_import_Click(object sender, EventArgs e)\r
         {\r
             ImportPreset();\r
         }\r
 \r
+        /// <summary>\r
+        /// RMenu - Save Changes to Preset\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void pmnu_saveChanges_Click(object sender, EventArgs e)\r
         {\r
             DialogResult result =\r
@@ -548,6 +660,15 @@ namespace Handbrake
                                      QueryGenerator.GenerateTabbedComponentsQuery(this), false);\r
         }\r
 \r
+        /// <summary>\r
+        /// RMenu - Delete Preset\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void pmnu_delete_click(object sender, EventArgs e)\r
         {\r
             if (treeView_presets.SelectedNode != null)\r
@@ -558,6 +679,15 @@ namespace Handbrake
             treeView_presets.Select();\r
         }\r
 \r
+        /// <summary>\r
+        /// Preset Menu Is Opening. Setup the Menu\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void presets_menu_Opening(object sender, CancelEventArgs e)\r
         {\r
             // Make sure that the save menu is always disabled by default\r
@@ -572,12 +702,31 @@ namespace Handbrake
         }\r
 \r
         // Presets Management\r
+\r
+        /// <summary>\r
+        /// Button - Add a preset\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void btn_addPreset_Click(object sender, EventArgs e)\r
         {\r
             Form preset = new frmAddPreset(this, QueryGenerator.GenerateTabbedComponentsQuery(this), presetHandler);\r
             preset.ShowDialog();\r
         }\r
 \r
+        /// <summary>\r
+        /// Button - remove a Preset\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void btn_removePreset_Click(object sender, EventArgs e)\r
         {\r
             DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset",\r
@@ -593,6 +742,15 @@ namespace Handbrake
             treeView_presets.Select();\r
         }\r
 \r
+        /// <summary>\r
+        /// Button - Set the selected preset as the default\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void btn_setDefault_Click(object sender, EventArgs e)\r
         {\r
             if (treeView_presets.SelectedNode != null)\r
@@ -610,6 +768,15 @@ namespace Handbrake
                 MessageBox.Show("Please select a preset first.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
         }\r
 \r
+        /// <summary>\r
+        /// PresetBar Mouse Down event\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void treeview_presets_mouseUp(object sender, MouseEventArgs e)\r
         {\r
             if (e.Button == MouseButtons.Right)\r
@@ -626,11 +793,29 @@ namespace Handbrake
             treeView_presets.Select();\r
         }\r
 \r
+        /// <summary>\r
+        /// Preset Bar after selecting the preset\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void treeView_presets_AfterSelect(object sender, TreeViewEventArgs e)\r
         {\r
             selectPreset();\r
         }\r
 \r
+        /// <summary>\r
+        /// Preset Bar - Handle the Delete Key\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void treeView_presets_deleteKey(object sender, KeyEventArgs e)\r
         {\r
             if (e.KeyCode == Keys.Delete)\r
@@ -663,6 +848,9 @@ namespace Handbrake
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Select the selected preset and setup the GUI\r
+        /// </summary>\r
         private void selectPreset()\r
         {\r
             if (treeView_presets.SelectedNode != null)\r
@@ -698,6 +886,9 @@ namespace Handbrake
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Load the Normal Preset\r
+        /// </summary>\r
         private void loadNormalPreset()\r
         {\r
             foreach (TreeNode treenode in treeView_presets.Nodes)\r
@@ -710,6 +901,9 @@ namespace Handbrake
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Import a plist preset\r
+        /// </summary>\r
         private void ImportPreset()\r
         {\r
             if (openPreset.ShowDialog() == DialogResult.OK)\r
@@ -746,6 +940,9 @@ namespace Handbrake
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Export a plist Preset\r
+        /// </summary>\r
         private void ExportPreset()\r
         {\r
             MessageBox.Show("This feature has not been implimented yet.", "Not Implimented", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
@@ -769,6 +966,15 @@ namespace Handbrake
 \r
         #region ToolStrip\r
 \r
+        /// <summary>\r
+        /// Toolbar - When the Source button is clicked, Clear any DVD drives and add any available DVD drives that can be used as a source.\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void btn_source_Click(object sender, EventArgs e)\r
         {\r
             // Remove old Drive Menu Items.\r
@@ -792,6 +998,15 @@ namespace Handbrake
             driveInfoThread.Start();\r
         }\r
 \r
+        /// <summary>\r
+        /// Toolbar - Start The Encode\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void btn_start_Click(object sender, EventArgs e)\r
         {\r
             if (btn_start.Text == "Stop")\r
@@ -903,6 +1118,15 @@ namespace Handbrake
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Toolbar - Add the current job to the Queue\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void btn_add2Queue_Click(object sender, EventArgs e)\r
         {\r
             if (string.IsNullOrEmpty(sourcePath) || string.IsNullOrEmpty(text_destination.Text))\r
@@ -932,12 +1156,30 @@ namespace Handbrake
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Toolbar - Show the Queue\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void btn_showQueue_Click(object sender, EventArgs e)\r
         {\r
             queueWindow.Show();\r
             queueWindow.Activate();\r
         }\r
 \r
+        /// <summary>\r
+        /// Toolbar - Show the Preview Window\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void tb_preview_Click(object sender, EventArgs e)\r
         {\r
             if (string.IsNullOrEmpty(sourcePath) || string.IsNullOrEmpty(text_destination.Text))\r
@@ -961,6 +1203,15 @@ namespace Handbrake
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Toolbar - Show the Activity log Window\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void btn_ActivityWindow_Click(object sender, EventArgs e)\r
         {\r
             if (ActivityWindow == null || !ActivityWindow.IsHandleCreated)\r
@@ -974,6 +1225,15 @@ namespace Handbrake
 \r
         #region System Tray Icon\r
 \r
+        /// <summary>\r
+        /// Handle Resizing of the main window when deaing with the Notify Icon\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void frmMain_Resize(object sender, EventArgs e)\r
         {\r
             if (FormWindowState.Minimized == this.WindowState)\r
@@ -985,6 +1245,15 @@ namespace Handbrake
                 notifyIcon.Visible = false;\r
         }\r
 \r
+        /// <summary>\r
+        /// Double Click the Tray Icon\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)\r
         {\r
             this.Visible = true;\r
@@ -993,6 +1262,15 @@ namespace Handbrake
             notifyIcon.Visible = false;\r
         }\r
 \r
+        /// <summary>\r
+        /// Tray Icon - Restore Menu Item - Resture the Window\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void btn_restore_Click(object sender, EventArgs e)\r
         {\r
             this.Visible = true;\r
@@ -1003,7 +1281,7 @@ namespace Handbrake
 \r
         #endregion\r
 \r
-        #region Tab Control\r
+        #region Main Window and Tab Control\r
 \r
         // Source\r
         private void btn_dvd_source_Click(object sender, EventArgs e)\r
@@ -1647,8 +1925,15 @@ namespace Handbrake
 \r
         #region Source Scan\r
 \r
-        public bool isScanning { get; set; }\r
-\r
+        /// <summary>\r
+        /// Start the Scan Process\r
+        /// </summary>\r
+        /// <param name="filename">\r
+        /// The filename.\r
+        /// </param>\r
+        /// <param name="title">\r
+        /// The title.\r
+        /// </param>\r
         private void StartScan(string filename, int title)\r
         {\r
             // Setup the GUI components for the scan.\r
@@ -1659,7 +1944,6 @@ namespace Handbrake
             // Start the Scan\r
             try\r
             {\r
-                isScanning = true;\r
                 SourceScan.Scan(sourcePath, title);\r
                 SourceScan.ScanStatusChanged += new EventHandler(SourceScan_ScanStatusChanged);\r
                 SourceScan.ScanCompleted += new EventHandler(SourceScan_ScanCompleted);\r
@@ -1670,16 +1954,37 @@ namespace Handbrake
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Update the Status label for the scan\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void SourceScan_ScanStatusChanged(object sender, EventArgs e)\r
         {\r
             UpdateScanStatusLabel();\r
         }\r
 \r
+        /// <summary>\r
+        /// Update the UI after the scan has completed\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
         private void SourceScan_ScanCompleted(object sender, EventArgs e)\r
         {\r
             UpdateGuiAfterScan();\r
         }\r
 \r
+        /// <summary>\r
+        /// Update the Scan Status Label\r
+        /// </summary>\r
         private void UpdateScanStatusLabel()\r
         {\r
             if (InvokeRequired)\r
@@ -1690,6 +1995,9 @@ namespace Handbrake
             lbl_encode.Text = SourceScan.ScanStatus;\r
         }\r
 \r
+        /// <summary>\r
+        /// Reset the GUI when the scan has completed\r
+        /// </summary>\r
         private void UpdateGuiAfterScan()\r
         {\r
             if (InvokeRequired)\r
@@ -1754,6 +2062,9 @@ namespace Handbrake
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Enable the GUI\r
+        /// </summary>\r
         private void EnableGUI()\r
         {\r
             try\r
@@ -1776,6 +2087,9 @@ namespace Handbrake
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Disable the GUI\r
+        /// </summary>\r
         private void DisableGUI()\r
         {\r
             foreach (Control ctrl in Controls)\r
@@ -1792,6 +2106,9 @@ namespace Handbrake
             mnu_killCLI.Visible = true;\r
         }\r
 \r
+        /// <summary>\r
+        /// Kill the Scan\r
+        /// </summary>\r
         private void KillScan()\r
         {\r
             SourceScan.ScanCompleted -= new EventHandler(SourceScan_ScanCompleted);\r
@@ -1803,6 +2120,9 @@ namespace Handbrake
             lbl_encode.Text = "Scan Cancelled!";\r
         }\r
 \r
+        /// <summary>\r
+        /// Reset the GUI\r
+        /// </summary>\r
         private void ResetGUI()\r
         {\r
             drp_dvdtitle.Items.Clear();\r
@@ -1813,9 +2133,11 @@ namespace Handbrake
             sourcePath = String.Empty;\r
             text_destination.Text = String.Empty;\r
             selectedTitle = null;\r
-            isScanning = false;\r
         }\r
 \r
+        /// <summary>\r
+        /// Update the Source Label\r
+        /// </summary>\r
         private void UpdateSourceLabel()\r
         {\r
             labelSource.Text = string.IsNullOrEmpty(sourcePath) ? "Select \"Source\" to continue." : this.SourceName;\r
@@ -1826,6 +2148,12 @@ namespace Handbrake
                     labelSource.Text = Path.GetFileName(selectedTitle.SourceName);\r
         }\r
 \r
+        /// <summary>\r
+        /// Take a job from the Queue, rescan it, and reload the GUI for that job.\r
+        /// </summary>\r
+        /// <param name="job">\r
+        /// The job.\r
+        /// </param>\r
         public void RecievingJob(Job job)\r
         {\r
             string query = job.Query;\r
@@ -1933,10 +2261,12 @@ namespace Handbrake
                 List<ToolStripMenuItem> menuItems = new List<ToolStripMenuItem>();\r
                 foreach (DriveInformation drive in drives)\r
                 {\r
-                    ToolStripMenuItem menuItem = new ToolStripMenuItem();\r
-                    menuItem.Name = drive.ToString();\r
-                    menuItem.Text = drive.RootDirectory + " (" + drive.VolumeLabel + ")";\r
-                    menuItem.Image = Resources.disc_small;\r
+                    ToolStripMenuItem menuItem = new ToolStripMenuItem\r
+                        {\r
+                            Name = drive.ToString(),\r
+                            Text = drive.RootDirectory + " (" + drive.VolumeLabel + ")",\r
+                            Image = Resources.disc_small\r
+                        };\r
                     menuItem.Click += new EventHandler(mnu_dvd_drive_Click);\r
                     menuItems.Add(menuItem);\r
                 }\r
@@ -1983,6 +2313,46 @@ namespace Handbrake
             return title;\r
         }\r
 \r
+        /// <summary>\r
+        /// Handle the Update Check Finishing.\r
+        /// </summary>\r
+        /// <param name="result">\r
+        /// The result.\r
+        /// </param>\r
+        private void updateCheckDoneMenu(IAsyncResult result)\r
+        {\r
+            // Make sure it's running on the calling thread\r
+            if (InvokeRequired)\r
+            {\r
+                Invoke(new MethodInvoker(() => updateCheckDoneMenu(result)));\r
+                return;\r
+            }\r
+            UpdateCheckInformation info;\r
+            try\r
+            {\r
+                // Get the information about the new build, if any, and close the window\r
+                info = Main.EndCheckForUpdates(result);\r
+\r
+                if (info.NewVersionAvailable && info.BuildInformation != null)\r
+                {\r
+                    frmUpdater updateWindow = new frmUpdater(info.BuildInformation);\r
+                    updateWindow.ShowDialog();\r
+                }\r
+                else\r
+                    MessageBox.Show("There are no new updates at this time.", "Update Check", MessageBoxButtons.OK,\r
+                                    MessageBoxIcon.Information);\r
+                lbl_updateCheck.Visible = false;\r
+                return;\r
+            }\r
+            catch (Exception ex)\r
+            {\r
+                if ((bool)result.AsyncState)\r
+                    MessageBox.Show(\r
+                        "Unable to check for updates, Please try again later.\n\nDetailed Error Information:\n" + ex,\r
+                        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+            }\r
+        }\r
+\r
         #endregion\r
 \r
         #region Overrides\r
@@ -2043,7 +2413,7 @@ namespace Handbrake
 \r
         #endregion\r
 \r
-        #region In-GUI Encode Status (Experimental)\r
+        #region In-GUI Encode Status\r
 \r
         /// <summary>\r
         /// Starts a new thread to monitor and process the CLI encode status\r
@@ -2068,31 +2438,31 @@ namespace Handbrake
         /// <summary>\r
         /// Displays the Encode status in the GUI\r
         /// </summary>\r
-        /// <param name="Sender"></param>\r
-        /// <param name="CurrentTask"></param>\r
-        /// <param name="TaskCount"></param>\r
-        /// <param name="PercentComplete"></param>\r
-        /// <param name="CurrentFps"></param>\r
-        /// <param name="AverageFps"></param>\r
-        /// <param name="TimeRemaining"></param>\r
-        private void EncodeOnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)\r
+        /// <param name="sender">The sender</param>\r
+        /// <param name="currentTask">The current task</param>\r
+        /// <param name="taskCount">Number of tasks</param>\r
+        /// <param name="percentComplete">Percent complete</param>\r
+        /// <param name="currentFps">Current encode speed in fps</param>\r
+        /// <param name="av">Avg encode speed</param>\r
+        /// <param name="timeRemaining">Time Left</param>\r
+        private void EncodeOnEncodeProgress(object sender, int currentTask, int taskCount, float percentComplete, float currentFps, float av, TimeSpan timeRemaining)\r
         {\r
             if (this.InvokeRequired)\r
             {\r
                 this.BeginInvoke(\r
                     new EncodeProgressEventHandler(EncodeOnEncodeProgress),\r
-                    new[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });\r
+                    new[] { sender, currentTask, taskCount, percentComplete, currentFps, av, timeRemaining });\r
                 return;\r
             }\r
             lbl_encode.Text =\r
                 string.Format(\r
-                "{0:00.00}%,    FPS: {1:000.0},    Avg FPS: {2:000.0},    Time Remaining: {3}", \r
-                PercentComplete, \r
-                CurrentFps, \r
-                AverageFps, \r
-                TimeRemaining);\r
+                "{0:00.00}%,    FPS: {1:000.0},    Avg FPS: {2:000.0},    Time Remaining: {3}",\r
+                percentComplete,\r
+                currentFps,\r
+                av,\r
+                timeRemaining);\r
 \r
-            ProgressBarStatus.Value = (int)Math.Round(PercentComplete);\r
+            ProgressBarStatus.Value = (int)Math.Round(percentComplete);\r
         }\r
 \r
         #endregion\r
index 0be644f..14080bd 100644 (file)
@@ -178,7 +178,6 @@ namespace Handbrake
             ProgressBarStatus.Value = (int)Math.Round(PercentComplete);\r
         }\r
 \r
-\r
         private void EncodeCompleted()\r
         {\r
             try\r
index 12a5bcc..e6f0a2e 100644 (file)
@@ -60,12 +60,12 @@ namespace Handbrake
             this.mnu_readd = new System.Windows.Forms.ToolStripMenuItem();\r
             this.SaveFile = new System.Windows.Forms.SaveFileDialog();\r
             this.list_queue = new System.Windows.Forms.ListView();\r
-            this.Title = new System.Windows.Forms.ColumnHeader();\r
-            this.Chapters = new System.Windows.Forms.ColumnHeader();\r
-            this.Source = new System.Windows.Forms.ColumnHeader();\r
-            this.Destination = new System.Windows.Forms.ColumnHeader();\r
-            this.EncoderVideo = new System.Windows.Forms.ColumnHeader();\r
-            this.Audio = new System.Windows.Forms.ColumnHeader();\r
+            this.Title = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));\r
+            this.Chapters = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));\r
+            this.Source = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));\r
+            this.Destination = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));\r
+            this.EncoderVideo = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));\r
+            this.Audio = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));\r
             this.mnu_queue = new System.Windows.Forms.ContextMenuStrip(this.components);\r
             this.mnu_up = new System.Windows.Forms.ToolStripMenuItem();\r
             this.mnu_Down = new System.Windows.Forms.ToolStripMenuItem();\r
index 049cf40..93587db 100644 (file)
@@ -125,8 +125,6 @@ namespace Handbrake
         {\r
             if (doSetQueue) SetQueue();\r
             base.Show();\r
-\r
-            // Activate();\r
         }\r
 \r
         /// <summary>\r
@@ -136,10 +134,9 @@ namespace Handbrake
         /// <param name="e">the EventArgs</param>\r
         private void BtnEncodeClick(object sender, EventArgs e)\r
         {\r
-            if (queue.PauseRequested)\r
+            if (queue.Paused)\r
             {\r
                 SetUiEncodeStarted();\r
-                MessageBox.Show("Encoding restarted", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
             }\r
 \r
             if (!queue.IsEncoding)\r