OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Thu, 27 Nov 2008 14:39:02 +0000 (14:39 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Thu, 27 Nov 2008 14:39:02 +0000 (14:39 +0000)
- Removed RAM limitation code on startup.
- Gets rid of the SystemInfo Class. It's no longer required. Since the ram limitation code has been remove, only the activity window needs access to the information, so, the code has been moved to frmActivityWindow.cs
- Removed some redundant code from frmMain.cs. Cleaned the startup code block up a bit.
- Re-structured frmMain.cs. Moved the code around into more logical regions.

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

win/C#/Functions/Main.cs
win/C#/Functions/SystemInfo.cs [deleted file]
win/C#/HandBrakeCS.csproj
win/C#/Program.cs
win/C#/frmActivityWindow.Designer.cs
win/C#/frmActivityWindow.cs
win/C#/frmMain.Designer.cs
win/C#/frmMain.cs
win/C#/frmMain/x264Panel.cs

index 0a202b1..4018ea8 100644 (file)
@@ -323,9 +323,10 @@ namespace Handbrake.Functions
         public ArrayList getCliVersionData()\r
         {\r
             ArrayList cliVersionData = new ArrayList();\r
+            String line;\r
+\r
             // 0 = SVN Build / Version\r
             // 1 = Build Date\r
-\r
             Process cliProcess = new Process();\r
             ProcessStartInfo handBrakeCLI = new ProcessStartInfo("HandBrakeCLI.exe", " -u");\r
             handBrakeCLI.UseShellExecute = false;\r
@@ -333,28 +334,37 @@ namespace Handbrake.Functions
             handBrakeCLI.RedirectStandardOutput = true;\r
             handBrakeCLI.CreateNoWindow = true;\r
             cliProcess.StartInfo = handBrakeCLI;\r
-            cliProcess.Start();\r
 \r
-            // Retrieve standard output and report back to parent thread until the process is complete\r
-            String line;\r
-            TextReader stdOutput = cliProcess.StandardError;\r
-\r
-            while (!cliProcess.HasExited)\r
+            try\r
             {\r
-                line = stdOutput.ReadLine();\r
-                if (line == null) line = "";\r
-                Match m = Regex.Match(line, @"HandBrake ([0-9\.]*)*(svn[0-9]*[M]*)* \([0-9]*\)");\r
+                cliProcess.Start();\r
+                // Retrieve standard output and report back to parent thread until the process is complete\r
+                TextReader stdOutput = cliProcess.StandardError;\r
 \r
-                if (m.Success != false)\r
+                while (!cliProcess.HasExited)\r
                 {\r
-                    string data = line.Replace("(", "").Replace(")", "").Replace("HandBrake ", "");\r
-                    string[] arr = data.Split(' ');\r
-                    cliVersionData.Add(arr[0]);\r
-                    cliVersionData.Add(arr[1]);\r
-                    return cliVersionData;\r
+                    line = stdOutput.ReadLine();\r
+                    if (line == null) line = "";\r
+                    Match m = Regex.Match(line, @"HandBrake ([0-9\.]*)*(svn[0-9]*[M]*)* \([0-9]*\)");\r
+\r
+                    if (m.Success != false)\r
+                    {\r
+                        string data = line.Replace("(", "").Replace(")", "").Replace("HandBrake ", "");\r
+                        string[] arr = data.Split(' ');\r
+                        cliVersionData.Add(arr[0]);\r
+                        cliVersionData.Add(arr[1]);\r
+                        return cliVersionData;\r
+                    }\r
                 }\r
             }\r
-            return null;\r
+            catch (Exception e)\r
+            {\r
+                MessageBox.Show("Unable to retrieve version information from the CLI. \nError:\n" + e);\r
+            }\r
+     \r
+            cliVersionData.Add(0);\r
+            cliVersionData.Add("0");\r
+            return cliVersionData;\r
         }\r
 \r
         /// <summary>\r
diff --git a/win/C#/Functions/SystemInfo.cs b/win/C#/Functions/SystemInfo.cs
deleted file mode 100644 (file)
index 535bda6..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-using System;\r
-using System.Runtime.InteropServices;\r
-using Microsoft.Win32;\r
-\r
-namespace Handbrake.Functions\r
-{\r
-    class SystemInfo\r
-    {\r
-        #region CheckRam\r
-        private struct MEMORYSTATUS\r
-        {\r
-            public UInt32 dwLength;\r
-            public UInt32 dwMemoryLoad;\r
-            public UInt32 dwTotalPhys; // Used\r
-            public UInt32 dwAvailPhys;\r
-            public UInt32 dwTotalPageFile;\r
-            public UInt32 dwAvailPageFile;\r
-            public UInt32 dwTotalVirtual;\r
-            public UInt32 dwAvailVirtual;\r
-        }\r
-\r
-        [DllImport("kernel32.dll")]\r
-        private static extern void GlobalMemoryStatus\r
-        (\r
-            ref MEMORYSTATUS lpBuffer\r
-        );\r
-\r
-\r
-        /// <summary>\r
-        /// Returns the total physical ram in a system\r
-        /// </summary>\r
-        /// <returns></returns>\r
-        public uint TotalPhysicalMemory()\r
-        {\r
-            MEMORYSTATUS memStatus = new MEMORYSTATUS();\r
-            GlobalMemoryStatus(ref memStatus);\r
-\r
-            uint MemoryInfo = memStatus.dwTotalPhys;\r
-            MemoryInfo = MemoryInfo / 1024 / 1024; \r
-\r
-            return MemoryInfo;\r
-        }\r
-        #endregion\r
-\r
-        public Object getCpuCount()\r
-        {\r
-            RegistryKey RegKey = Registry.LocalMachine;\r
-            RegKey = RegKey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");\r
-            return RegKey.GetValue("ProcessorNameString");\r
-        }\r
-\r
-        public System.Windows.Forms.Screen screenBounds()\r
-        {\r
-            return System.Windows.Forms.Screen.PrimaryScreen;\r
-        }\r
-    }\r
-}\r
index 64d5d69..c240341 100644 (file)
     </Compile>\r
     <Compile Include="frmMain\PresetLoader.cs" />\r
     <Compile Include="frmMain\QueryGenerator.cs" />\r
-    <Compile Include="Functions\SystemInfo.cs" />\r
     <Compile Include="Functions\Main.cs" />\r
     <Compile Include="Presets\preset.cs" />\r
     <Compile Include="Presets\PresetsHandler.cs" />\r
index ae9edec..6f71b80 100644 (file)
@@ -30,10 +30,6 @@ namespace Handbrake
         [STAThread]\r
         static void Main()\r
         {\r
-            // Development Code Expiry.\r
-            // Remember to comment out on public release!!!\r
-            //if (DateTime.Now > DateTime.Parse("2008/02/25", new CultureInfo("en-US"))) { MessageBox.Show("Sorry, This development build of Handbrake has expired."); return; } \r
-\r
             // Check the system meets the system requirements.\r
             Boolean launch = true;\r
             try\r
@@ -45,16 +41,6 @@ namespace Handbrake
                     MessageBox.Show("Your system does not meet the minimum requirements for HandBrake. \n" + "Your screen is running at: " + scr.Bounds.Width.ToString() + "x" + scr.Bounds.Height.ToString() + " \nScreen resolution is too Low. Must be 1024x720 or greater", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
                     launch = false;\r
                 }\r
-\r
-                // Make sure the system has enough RAM. 384MB or greater\r
-                Functions.SystemInfo info = new Functions.SystemInfo();\r
-                uint memory = info.TotalPhysicalMemory();\r
-                \r
-                if (memory < 256)\r
-                {\r
-                    MessageBox.Show("Your system does not meet the minimum requirements for HandBrake. \n Insufficient RAM. 384MB or greater required. You have: " + memory.ToString() + "MB", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
-                    launch = false;\r
-                }\r
             }\r
             catch (Exception exc)\r
             {\r
@@ -69,9 +55,7 @@ namespace Handbrake
                 Application.Run(new frmMain());\r
             }\r
             else\r
-            {\r
                 Application.Exit();\r
-            }\r
         }\r
     }\r
 \r
index 837bf37..a57603e 100644 (file)
@@ -37,6 +37,8 @@ namespace Handbrake
             this.components = new System.ComponentModel.Container();\r
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmActivityWindow));\r
             this.rtf_actLog = new System.Windows.Forms.RichTextBox();\r
+            this.rightClickMenu = new System.Windows.Forms.ContextMenuStrip(this.components);\r
+            this.mnu_copy_log = new System.Windows.Forms.ToolStripMenuItem();\r
             this.ToolTip = new System.Windows.Forms.ToolTip(this.components);\r
             this.toolStrip1 = new System.Windows.Forms.ToolStrip();\r
             this.toolStripDropDownButton1 = new System.Windows.Forms.ToolStripDropDownButton();\r
@@ -47,11 +49,9 @@ namespace Handbrake
             this.statusStrip1 = new System.Windows.Forms.StatusStrip();\r
             this.lbl_slb = new System.Windows.Forms.ToolStripStatusLabel();\r
             this.txt_log = new System.Windows.Forms.ToolStripStatusLabel();\r
-            this.rightClickMenu = new System.Windows.Forms.ContextMenuStrip(this.components);\r
-            this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\r
+            this.rightClickMenu.SuspendLayout();\r
             this.toolStrip1.SuspendLayout();\r
             this.statusStrip1.SuspendLayout();\r
-            this.rightClickMenu.SuspendLayout();\r
             this.SuspendLayout();\r
             // \r
             // rtf_actLog\r
@@ -67,6 +67,21 @@ namespace Handbrake
             this.rtf_actLog.TabIndex = 29;\r
             this.rtf_actLog.Text = "";\r
             // \r
+            // rightClickMenu\r
+            // \r
+            this.rightClickMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
+            this.mnu_copy_log});\r
+            this.rightClickMenu.Name = "rightClickMenu";\r
+            this.rightClickMenu.Size = new System.Drawing.Size(153, 48);\r
+            // \r
+            // mnu_copy_log\r
+            // \r
+            this.mnu_copy_log.Image = global::Handbrake.Properties.Resources.copy;\r
+            this.mnu_copy_log.Name = "mnu_copy_log";\r
+            this.mnu_copy_log.Size = new System.Drawing.Size(152, 22);\r
+            this.mnu_copy_log.Text = "Copy";\r
+            this.mnu_copy_log.Click += new System.EventHandler(this.mnu_copy_log_Click);\r
+            // \r
             // ToolTip\r
             // \r
             this.ToolTip.Active = false;\r
@@ -156,21 +171,6 @@ namespace Handbrake
             this.txt_log.Size = new System.Drawing.Size(85, 17);\r
             this.txt_log.Text = "{selected log}";\r
             // \r
-            // rightClickMenu\r
-            // \r
-            this.rightClickMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
-            this.copyToolStripMenuItem});\r
-            this.rightClickMenu.Name = "rightClickMenu";\r
-            this.rightClickMenu.Size = new System.Drawing.Size(153, 48);\r
-            // \r
-            // copyToolStripMenuItem\r
-            // \r
-            this.copyToolStripMenuItem.Image = global::Handbrake.Properties.Resources.copy;\r
-            this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";\r
-            this.copyToolStripMenuItem.Size = new System.Drawing.Size(152, 22);\r
-            this.copyToolStripMenuItem.Text = "Copy";\r
-            this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click);\r
-            // \r
             // frmActivityWindow\r
             // \r
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 13F);\r
@@ -189,11 +189,11 @@ namespace Handbrake
             this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;\r
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;\r
             this.Text = "Activity Window";\r
+            this.rightClickMenu.ResumeLayout(false);\r
             this.toolStrip1.ResumeLayout(false);\r
             this.toolStrip1.PerformLayout();\r
             this.statusStrip1.ResumeLayout(false);\r
             this.statusStrip1.PerformLayout();\r
-            this.rightClickMenu.ResumeLayout(false);\r
             this.ResumeLayout(false);\r
             this.PerformLayout();\r
 \r
@@ -213,6 +213,6 @@ namespace Handbrake
         private System.Windows.Forms.ToolStripButton btn_copy;\r
         private System.Windows.Forms.ToolStripStatusLabel lbl_slb;\r
         private System.Windows.Forms.ContextMenuStrip rightClickMenu;\r
-        private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem;\r
+        private System.Windows.Forms.ToolStripMenuItem mnu_copy_log;\r
     }\r
 }
\ No newline at end of file
index 5508d0b..d21eecd 100644 (file)
@@ -16,6 +16,7 @@ using System.IO;
 using System.Threading;\r
 using System.Diagnostics;\r
 using System.Runtime.InteropServices;\r
+using Microsoft.Win32;\r
 \r
 \r
 namespace Handbrake\r
@@ -62,15 +63,12 @@ namespace Handbrake
         /// </summary>\r
         private void displayLogHeader()\r
         {\r
-            // System Information\r
-            Functions.SystemInfo info = new Functions.SystemInfo();\r
-\r
             // Add a header to the log file indicating that it's from the Windows GUI and display the windows version\r
             rtf_actLog.AppendText(String.Format("### Windows GUI {1} {0} \n", Properties.Settings.Default.hb_build, Properties.Settings.Default.hb_version));\r
             rtf_actLog.AppendText(String.Format("### Running: {0} \n###\n", Environment.OSVersion.ToString()));\r
-            rtf_actLog.AppendText(String.Format("### CPU: {0} \n", info.getCpuCount()));\r
-            rtf_actLog.AppendText(String.Format("### Ram: {0} MB \n", info.TotalPhysicalMemory()));\r
-            rtf_actLog.AppendText(String.Format("### Screen: {0}x{1} \n", info.screenBounds().Bounds.Width, info.screenBounds().Bounds.Height));\r
+            rtf_actLog.AppendText(String.Format("### CPU: {0} \n", getCpuCount()));\r
+            rtf_actLog.AppendText(String.Format("### Ram: {0} MB \n", TotalPhysicalMemory()));\r
+            rtf_actLog.AppendText(String.Format("### Screen: {0}x{1} \n", screenBounds().Bounds.Width, screenBounds().Bounds.Height));\r
             rtf_actLog.AppendText(String.Format("### Temp Dir: {0} \n", Path.GetTempPath()));\r
             rtf_actLog.AppendText(String.Format("### Install Dir: {0} \n", Application.StartupPath));\r
             rtf_actLog.AppendText(String.Format("### Data Dir: {0} \n", Application.UserAppDataPath));\r
@@ -306,12 +304,74 @@ namespace Handbrake
             this.Close();\r
         }\r
 \r
-        private void copyToolStripMenuItem_Click(object sender, EventArgs e)\r
+        /// <summary>\r
+        /// Copy Log Menu Item on the right click menu for the log rtf box\r
+        /// </summary>\r
+        /// <param name="sender"></param>\r
+        /// <param name="e"></param>\r
+        private void mnu_copy_log_Click(object sender, EventArgs e)\r
         {\r
             if (rtf_actLog.SelectedText != "")\r
                 Clipboard.SetDataObject(rtf_actLog.SelectedText, true);\r
             else\r
                 Clipboard.SetDataObject(rtf_actLog.Text, true);\r
         }\r
+\r
+        #region System Information\r
+        private struct MEMORYSTATUS\r
+        {\r
+            public UInt32 dwLength;\r
+            public UInt32 dwMemoryLoad;\r
+            public UInt32 dwTotalPhys; // Used\r
+            public UInt32 dwAvailPhys;\r
+            public UInt32 dwTotalPageFile;\r
+            public UInt32 dwAvailPageFile;\r
+            public UInt32 dwTotalVirtual;\r
+            public UInt32 dwAvailVirtual;\r
+        }\r
+\r
+        [DllImport("kernel32.dll")]\r
+        private static extern void GlobalMemoryStatus\r
+        (\r
+            ref MEMORYSTATUS lpBuffer\r
+        );\r
+\r
+        /// <summary>\r
+        /// Returns the total physical ram in a system\r
+        /// </summary>\r
+        /// <returns></returns>\r
+        public uint TotalPhysicalMemory()\r
+        {\r
+            MEMORYSTATUS memStatus = new MEMORYSTATUS();\r
+            GlobalMemoryStatus(ref memStatus);\r
+\r
+            uint MemoryInfo = memStatus.dwTotalPhys;\r
+            MemoryInfo = MemoryInfo / 1024 / 1024;\r
+\r
+            return MemoryInfo;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Get the number of CPU Cores\r
+        /// </summary>\r
+        /// <returns>Object</returns>\r
+        public Object getCpuCount()\r
+        {\r
+            RegistryKey RegKey = Registry.LocalMachine;\r
+            RegKey = RegKey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");\r
+            return RegKey.GetValue("ProcessorNameString");\r
+        }\r
+\r
+        /// <summary>\r
+        /// Get the System screen size information.\r
+        /// </summary>\r
+        /// <returns>System.Windows.Forms.Scree</returns>\r
+        public System.Windows.Forms.Screen screenBounds()\r
+        {\r
+            return System.Windows.Forms.Screen.PrimaryScreen;\r
+        }\r
+\r
+        #endregion\r
+\r
     }\r
 }
\ No newline at end of file
index 28d111e..ebd065b 100644 (file)
@@ -381,6 +381,7 @@ namespace Handbrake
             this.text_source.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.text_source.Location = new System.Drawing.Point(99, 19);\r
             this.text_source.Name = "text_source";\r
+            this.text_source.ReadOnly = true;\r
             this.text_source.Size = new System.Drawing.Size(584, 21);\r
             this.text_source.TabIndex = 1;\r
             this.text_source.Text = "Click \'Source\' to continue";\r
index 59ae27b..fd65e49 100644 (file)
@@ -21,23 +21,22 @@ namespace Handbrake
 {\r
     public partial class frmMain : Form\r
     {\r
-        // Declarations *******************************************************\r
         // Objects which may be used by one or more other objects\r
         Functions.Main hb_common_func = new Functions.Main();\r
         Functions.Encode cliObj = new Functions.Encode();\r
         Queue.Queue encodeQueue = new Queue.Queue();\r
         Presets.PresetsHandler presetHandler = new Presets.PresetsHandler();\r
         Parsing.Title selectedTitle;\r
+        Parsing.DVD thisDVD;\r
 \r
         // Objects belonging to this window only\r
         PresetLoader presetLoader = new PresetLoader();\r
         x264Panel x264PanelFunctions = new x264Panel();\r
         QueryGenerator queryGen = new QueryGenerator();\r
 \r
+        // Globals: Mainly used for tracking.\r
         internal Process hbProc;\r
-        private Parsing.DVD thisDVD;\r
         private frmQueue queueWindow;\r
-        private delegate void updateStatusChanger();\r
         private string lastAction = null;\r
         public int maxWidth = 0;\r
         public int maxHeight = 0;\r
@@ -52,33 +51,19 @@ namespace Handbrake
             Form splash = new frmSplashScreen();\r
             splash.Show();\r
 \r
-            // Initialize the queue window.\r
-            queueWindow = new frmQueue(this);\r
             //Create a label that can be updated from the parent thread.\r
             Label lblStatus = new Label();\r
             lblStatus.Size = new Size(250, 20);\r
             lblStatus.Location = new Point(10, 280);\r
             splash.Controls.Add(lblStatus);\r
-\r
             InitializeComponent();\r
 \r
             // Update the users config file with the CLI version data.\r
             lblStatus.Text = "Setting Version Data ...";\r
             Application.DoEvents();\r
             ArrayList x = hb_common_func.getCliVersionData();\r
-            if (x != null)\r
-            {\r
-                try\r
-                {\r
-                    Properties.Settings.Default.hb_build = int.Parse(x[1].ToString());\r
-                    Properties.Settings.Default.hb_version = x[0].ToString();\r
-                }\r
-                catch (Exception)\r
-                {\r
-                    Properties.Settings.Default.hb_build = 0;\r
-                    Properties.Settings.Default.hb_version = "0";\r
-                }\r
-            }\r
+            Properties.Settings.Default.hb_build = int.Parse(x[1].ToString());\r
+            Properties.Settings.Default.hb_version = x[0].ToString();\r
 \r
             // show the form, but leave disabled until preloading is complete then show the main form\r
             this.Enabled = false;\r
@@ -97,32 +82,33 @@ namespace Handbrake
             // Setup the GUI components\r
             lblStatus.Text = "Setting up the GUI ...";\r
             Application.DoEvents();\r
-            setupH264Panel();               // Initalize the H.264 Panel\r
-            loadPresetPanel();              // Load the Preset Panel\r
+            x264PanelFunctions.reset2Defaults(this); // Initialize all the x264 widgets to their default values\r
+            loadPresetPanel();                       // Load the Preset Panel\r
+            treeView_presets.ExpandAll();\r
+            lbl_encode.Text = "";\r
+            queueWindow = new frmQueue(this);        // Prepare the Queue\r
+\r
             // Load the user's default settings or Normal Preset\r
-            if (Properties.Settings.Default.defaultSettings == "Checked")\r
-                loadUserDefaults();\r
+            if (Properties.Settings.Default.defaultSettings == "Checked" && Properties.Settings.Default.defaultUserSettings != "")\r
+            {\r
+                Functions.QueryParser presetQuery = Functions.QueryParser.Parse(Properties.Settings.Default.defaultUserSettings);\r
+                presetLoader.presetLoader(this, presetQuery, "User Defaults ");\r
+            }\r
             else\r
                 loadNormalPreset();\r
-            // Expand the preset Nodes\r
-            treeView_presets.ExpandAll();\r
+\r
             // Enabled GUI tooltip's if Required\r
             if (Properties.Settings.Default.tooltipEnable == "Checked")\r
                 ToolTip.Active = true;\r
-            lbl_encode.Text = "";\r
 \r
             //Finished Loading\r
             lblStatus.Text = "Loading Complete!";\r
             Application.DoEvents();\r
-\r
-            //Close the splash screen\r
             splash.Close();\r
             splash.Dispose();\r
-\r
-            // Turn the interface back to the user\r
             this.Enabled = true;\r
 \r
-            // Some event Handlers. Used for minimize to taskbar\r
+            // Event Handlers\r
             this.Resize += new EventHandler(frmMain_Resize);\r
 \r
             // Queue Recovery\r
@@ -130,6 +116,7 @@ namespace Handbrake
         }\r
 \r
         // Startup Functions\r
+        private delegate void updateStatusChanger();\r
         private void startupUpdateCheck()\r
         {\r
             try\r
@@ -149,34 +136,6 @@ namespace Handbrake
             }\r
             catch (Exception) { /* Do Nothing*/ }\r
         }\r
-        private void setupH264Panel()\r
-        {\r
-            // Set the default settings of the x264 panel\r
-            drop_bFrames.Text = "Default (0)";\r
-            drop_refFrames.Text = "Default (1)";\r
-            drop_subpixelMotionEstimation.Text = "Default (4)";\r
-            drop_trellis.Text = "Default (0)";\r
-            drop_MotionEstimationMethod.Text = "Default (Hexagon)";\r
-            drop_MotionEstimationRange.Text = "Default (16)";\r
-            drop_directPrediction.Text = "Default (Spatial)";\r
-            drop_deblockAlpha.Text = "Default (0)";\r
-            drop_deblockBeta.Text = "Default (0)";\r
-            drop_analysis.Text = "Default (some)";\r
-            rtf_x264Query.Text = "";\r
-        }\r
-        private void loadUserDefaults()\r
-        {\r
-            // Try to load the users default settings.\r
-            string userDefaults = Properties.Settings.Default.defaultUserSettings;\r
-\r
-            if (userDefaults == "")\r
-                loadNormalPreset();\r
-            else\r
-            {\r
-                Functions.QueryParser presetQuery = Functions.QueryParser.Parse(userDefaults);\r
-                presetLoader.presetLoader(this, presetQuery, "User Defaults ");\r
-            }\r
-        }\r
         private void queueRecovery()\r
         {\r
             if (hb_common_func.check_queue_recovery() == true)\r
@@ -194,10 +153,9 @@ namespace Handbrake
                 }\r
             }\r
         }\r
-\r
         #endregion\r
 \r
-        // The Applications Main Menu and Menus *******************************\r
+        // User Interface Menus / Tool Strips *********************************\r
 \r
         #region File Menu\r
         private void mnu_exit_Click(object sender, EventArgs e)\r
@@ -236,7 +194,7 @@ namespace Handbrake
             presetHandler.updateBuiltInPresets();\r
             loadPresetPanel();\r
             if (treeView_presets.Nodes.Count == 0)\r
-                MessageBox.Show("Unable to load the presets.dat file. Please select \"Update Built-in Presets\" from the Presets Menu \nMake sure you are running the program in Admin mode if running on Vista. See Windows FAQ for details!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                MessageBox.Show("Unable to load the presets.xml file. Please select \"Update Built-in Presets\" from the Presets Menu \nMake sure you are running the program in Admin mode if running on Vista. See Windows FAQ for details!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             else\r
                 MessageBox.Show("Presets have been updated!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
 \r
@@ -245,7 +203,7 @@ namespace Handbrake
         private void mnu_delete_preset_Click(object sender, EventArgs e)\r
         {\r
             // Empty the preset file\r
-            string presetsFile = Application.StartupPath.ToString() + "\\presets.dat";\r
+            string presetsFile = Application.StartupPath.ToString() + "\\presets.xml";\r
             if (File.Exists(presetsFile))\r
                 File.Delete(presetsFile);\r
 \r
@@ -312,7 +270,8 @@ namespace Handbrake
         }\r
         #endregion\r
 \r
-        #region Preset Menu\r
+        #region Preset Bar\r
+        // Right Click Menu Code\r
         private void pmnu_expandAll_Click(object sender, EventArgs e)\r
         {\r
             treeView_presets.ExpandAll();\r
@@ -344,12 +303,146 @@ namespace Handbrake
             }\r
             treeView_presets.Select();\r
         }\r
-        #endregion\r
 \r
-        // MainWindow Components, Actions and Functions ***********************\r
-        #region Actions\r
+        // Presets Management\r
+        private void btn_addPreset_Click(object sender, EventArgs e)\r
+        {\r
+            // Remember each nodes expanded status so we can reload it\r
+            List<Boolean> nodeStatus = saveTreeViewState();\r
+            nodeStatus.Add(true);\r
+\r
+            // Now add the new preset\r
+            Form preset = new frmAddPreset(this, queryGen.GenerateTheQuery(this), presetHandler);\r
+            preset.ShowDialog();\r
+\r
+            // Now reload the TreeView states\r
+            loadTreeViewStates(nodeStatus);\r
+        }\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", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+            if (result == DialogResult.Yes)\r
+            {\r
+                if (treeView_presets.SelectedNode != null)\r
+                    presetHandler.remove(treeView_presets.SelectedNode.Text);\r
+\r
+                // Remember each nodes expanded status so we can reload it\r
+                List<Boolean> nodeStatus = saveTreeViewState();\r
+\r
+                // Now reload the preset panel\r
+                loadPresetPanel();\r
+\r
+                // Now reload the TreeView states\r
+                loadTreeViewStates(nodeStatus);\r
+            }\r
+            treeView_presets.Select();\r
+        }\r
+        private void btn_setDefault_Click(object sender, EventArgs e)\r
+        {\r
+            String query = queryGen.GenerateTheQuery(this);\r
+            Properties.Settings.Default.defaultUserSettings = query;\r
+            // Save the new default Settings\r
+            Properties.Settings.Default.Save();\r
+            MessageBox.Show("New default settings saved.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
+        }\r
+        private void treeView_presets_AfterSelect(object sender, TreeViewEventArgs e)\r
+        {\r
+            // Ok, so, we've selected a preset. Now we want to load it.\r
+            string presetName = treeView_presets.SelectedNode.Text;\r
+            string query = presetHandler.getCliForPreset(presetName);\r
+\r
+            if (query != null)\r
+            {\r
+                //Ok, Reset all the H264 widgets before changing the preset\r
+                x264PanelFunctions.reset2Defaults(this);\r
+\r
+                // Send the query from the file to the Query Parser class\r
+                Functions.QueryParser presetQuery = Functions.QueryParser.Parse(query);\r
+\r
+                // Now load the preset\r
+                presetLoader.presetLoader(this, presetQuery, presetName);\r
+\r
+                // The x264 widgets will need updated, so do this now:\r
+                x264PanelFunctions.X264_StandardizeOptString(this);\r
+                x264PanelFunctions.X264_SetCurrentSettingsInPanel(this);\r
+            }\r
+        }\r
+        private void treeView_presets_deleteKey(object sender, KeyEventArgs e)\r
+        {\r
+            if (e.KeyCode == Keys.Delete)\r
+            {\r
+                DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+                if (result == DialogResult.Yes)\r
+                {\r
+                    if (treeView_presets.SelectedNode != null)\r
+                        presetHandler.remove(treeView_presets.SelectedNode.Text);\r
+\r
+                    // Remember each nodes expanded status so we can reload it\r
+                    List<Boolean> nodeStatus = new List<Boolean>();\r
+                    foreach (TreeNode node in treeView_presets.Nodes)\r
+                        nodeStatus.Add(node.IsExpanded);\r
+\r
+                    // Now reload the preset panel\r
+                    loadPresetPanel();\r
+\r
+                    // And finally, re-expand any of the nodes if required\r
+                    int i = 0;\r
+                    foreach (TreeNode node in treeView_presets.Nodes)\r
+                    {\r
+                        if (nodeStatus[i] == true)\r
+                            node.Expand();\r
+\r
+                        i++;\r
+                    }\r
+                }\r
+            }\r
+        }\r
+        private List<Boolean> saveTreeViewState()\r
+        {\r
+            // Remember each nodes expanded status so we can reload it\r
+            List<Boolean> nodeStatus = new List<Boolean>();\r
+            foreach (TreeNode node in treeView_presets.Nodes)\r
+            {\r
+                nodeStatus.Add(node.IsExpanded);\r
+                foreach (TreeNode subNode in node.Nodes)\r
+                    nodeStatus.Add(node.IsExpanded);\r
+            }\r
+            return nodeStatus;\r
+        }\r
+        private void loadTreeViewStates(List<Boolean> nodeStatus)\r
+        {\r
+            // And finally, re-expand any of the nodes if required\r
+            int i = 0;\r
+            foreach (TreeNode node in treeView_presets.Nodes)\r
+            {\r
+                if (nodeStatus[i] == true)\r
+                    node.Expand();\r
+\r
+                foreach (TreeNode subNode in node.Nodes)\r
+                {\r
+                    if (nodeStatus[i] == true)\r
+                        subNode.Expand();\r
+                }\r
 \r
-        // ToolBar\r
+                i++;\r
+            }\r
+        }\r
+        private void loadNormalPreset()\r
+        {\r
+            treeView_presets.Nodes.Find("Normal", true);\r
+\r
+            foreach (TreeNode treenode in treeView_presets.Nodes)\r
+            {\r
+                foreach (TreeNode node in treenode.Nodes)\r
+                {\r
+                    if (node.Text.ToString().Equals("Normal"))\r
+                        treeView_presets.SelectedNode = treeView_presets.Nodes[treenode.Index].Nodes[0];\r
+                }\r
+            }\r
+        }\r
+        #endregion\r
+\r
+        #region ToolStrip\r
         private void btn_source_Click(object sender, EventArgs e)\r
         {\r
             if (Properties.Settings.Default.drive_detection == "Checked")\r
@@ -420,6 +513,45 @@ namespace Handbrake
             frmActivityWindow ActivityWindow = new frmActivityWindow(file, this, queueWindow);\r
             ActivityWindow.Show();\r
         }\r
+        #endregion\r
+\r
+        #region System Tray Icon\r
+        private void frmMain_Resize(object sender, EventArgs e)\r
+        {\r
+            if (FormWindowState.Minimized == this.WindowState)\r
+            {\r
+                notifyIcon.Visible = true;\r
+                if (lbl_encode.Text != "")\r
+                    notifyIcon.BalloonTipText = lbl_encode.Text;\r
+                else\r
+                    notifyIcon.BalloonTipText = "Not Encoding";\r
+                notifyIcon.ShowBalloonTip(500);\r
+                this.Hide();\r
+            }\r
+            else if (FormWindowState.Normal == this.WindowState)\r
+                notifyIcon.Visible = false;\r
+        }\r
+        private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)\r
+        {\r
+            this.Visible = true;\r
+            this.Activate();\r
+            this.WindowState = FormWindowState.Normal;\r
+            notifyIcon.Visible = false;\r
+        }\r
+        private void btn_minimize_Click(object sender, EventArgs e)\r
+        {\r
+            this.WindowState = FormWindowState.Minimized;\r
+        }\r
+        private void btn_restore_Click(object sender, EventArgs e)\r
+        {\r
+            this.Visible = true;\r
+            this.Activate();\r
+            this.WindowState = FormWindowState.Normal;\r
+            notifyIcon.Visible = false;\r
+        }\r
+        #endregion\r
+\r
+        #region Tab Control\r
 \r
         //Source\r
         private void btn_dvd_source_Click(object sender, EventArgs e)\r
@@ -722,7 +854,14 @@ namespace Handbrake
                 setExtension(".avi");\r
             else if (drop_format.SelectedIndex == 4)\r
                 setExtension(".ogm");\r
-\r
+        }\r
+        private void setExtension(string newExtension)\r
+        {\r
+            text_destination.Text = text_destination.Text.Replace(".mp4", newExtension);\r
+            text_destination.Text = text_destination.Text.Replace(".m4v", newExtension);\r
+            text_destination.Text = text_destination.Text.Replace(".mkv", newExtension);\r
+            text_destination.Text = text_destination.Text.Replace(".avi", newExtension);\r
+            text_destination.Text = text_destination.Text.Replace(".ogm", newExtension);\r
         }\r
 \r
         //Video Tab\r
@@ -1434,168 +1573,57 @@ namespace Handbrake
         {\r
             rtf_query.Clear();\r
         }\r
+        #endregion\r
 \r
-        // Presets\r
-        private void btn_addPreset_Click(object sender, EventArgs e)\r
-        {\r
-            // Remember each nodes expanded status so we can reload it\r
-            List<Boolean> nodeStatus = saveTreeViewState();\r
-            nodeStatus.Add(true);\r
-\r
-            // Now add the new preset\r
-            Form preset = new frmAddPreset(this, queryGen.GenerateTheQuery(this), presetHandler);\r
-            preset.ShowDialog();\r
-\r
-            // Now reload the TreeView states\r
-            loadTreeViewStates(nodeStatus);\r
-        }\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", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
-            if (result == DialogResult.Yes)\r
-            {\r
-                if (treeView_presets.SelectedNode != null)\r
-                    presetHandler.remove(treeView_presets.SelectedNode.Text);\r
+        // MainWindow Components, Actions and Functions ***********************\r
 \r
-                // Remember each nodes expanded status so we can reload it\r
-                List<Boolean> nodeStatus = saveTreeViewState();\r
+        #region Encoding\r
 \r
-                // Now reload the preset panel\r
-                loadPresetPanel();\r
+        // Declarations\r
+        private delegate void UpdateUIHandler();\r
 \r
-                // Now reload the TreeView states\r
-                loadTreeViewStates(nodeStatus);\r
-            }\r
-            treeView_presets.Select();\r
-        }\r
-        private void btn_setDefault_Click(object sender, EventArgs e)\r
-        {\r
-            String query = queryGen.GenerateTheQuery(this);\r
-            Properties.Settings.Default.defaultUserSettings = query;\r
-            // Save the new default Settings\r
-            Properties.Settings.Default.Save();\r
-            MessageBox.Show("New default settings saved.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
-        }\r
-        private void treeView_presets_AfterSelect(object sender, TreeViewEventArgs e)\r
+        // Encoding Functions\r
+        private void procMonitor(object state)\r
         {\r
-            // Ok, so, we've selected a preset. Now we want to load it.\r
-            string presetName = treeView_presets.SelectedNode.Text;\r
-            string query = presetHandler.getCliForPreset(presetName);\r
-\r
-            if (query != null)\r
+            // Make sure we are not already encoding and if we are then display an error.\r
+            if (hbProc != null)\r
+                hbProc.CloseMainWindow();\r
+            else\r
             {\r
-                //Ok, Reset all the H264 widgets before changing the preset\r
-                x264PanelFunctions.reset2Defaults(this);\r
-\r
-                // Send the query from the file to the Query Parser class\r
-                Functions.QueryParser presetQuery = Functions.QueryParser.Parse(query);\r
-\r
-                // Now load the preset\r
-                presetLoader.presetLoader(this, presetQuery, presetName);\r
+                hbProc = cliObj.runCli(this, (string)state);\r
+                hbProc.WaitForExit();\r
+                setEncodeLabelFinished();\r
+                hbProc = null;\r
 \r
-                // The x264 widgets will need updated, so do this now:\r
-                x264PanelFunctions.X264_StandardizeOptString(this);\r
-                x264PanelFunctions.X264_SetCurrentSettingsInPanel(this);\r
-            }\r
-        }\r
-        private void treeView_presets_deleteKey(object sender, KeyEventArgs e)\r
-        {\r
-            if (e.KeyCode == Keys.Delete)\r
-            {\r
-                DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
-                if (result == DialogResult.Yes)\r
+                // If the window is minimized, display the notification in a popup.\r
+                if (FormWindowState.Minimized == this.WindowState)\r
                 {\r
-                    if (treeView_presets.SelectedNode != null)\r
-                        presetHandler.remove(treeView_presets.SelectedNode.Text);\r
-\r
-                    // Remember each nodes expanded status so we can reload it\r
-                    List<Boolean> nodeStatus = new List<Boolean>();\r
-                    foreach (TreeNode node in treeView_presets.Nodes)\r
-                        nodeStatus.Add(node.IsExpanded);\r
-\r
-                    // Now reload the preset panel\r
-                    loadPresetPanel();\r
-\r
-                    // And finally, re-expand any of the nodes if required\r
-                    int i = 0;\r
-                    foreach (TreeNode node in treeView_presets.Nodes)\r
-                    {\r
-                        if (nodeStatus[i] == true)\r
-                            node.Expand();\r
-\r
-                        i++;\r
-                    }\r
+                    notifyIcon.BalloonTipText = lbl_encode.Text;\r
+                    notifyIcon.ShowBalloonTip(500);\r
                 }\r
-            }\r
-        }\r
 \r
-        #endregion\r
-\r
-        #region Preset Expand / Collaspe\r
-        private List<Boolean> saveTreeViewState()\r
-        {\r
-            // Remember each nodes expanded status so we can reload it\r
-            List<Boolean> nodeStatus = new List<Boolean>();\r
-            foreach (TreeNode node in treeView_presets.Nodes)\r
-            {\r
-                nodeStatus.Add(node.IsExpanded);\r
-                foreach (TreeNode subNode in node.Nodes)\r
-                    nodeStatus.Add(node.IsExpanded);\r
+                // After the encode is done, we may want to shutdown, suspend etc.\r
+                cliObj.addCLIQueryToLog((string)state);\r
+                cliObj.copyLog((string)state, text_destination.Text); // Make a copy of the log in the users desired location if necessary\r
+                cliObj.afterEncodeAction();\r
             }\r
-            return nodeStatus;\r
         }\r
-\r
-        private void loadTreeViewStates(List<Boolean> nodeStatus)\r
+        private void setEncodeLabelFinished()\r
         {\r
-            // And finally, re-expand any of the nodes if required\r
-            int i = 0;\r
-            foreach (TreeNode node in treeView_presets.Nodes)\r
+            if (this.InvokeRequired)\r
             {\r
-                if (nodeStatus[i] == true)\r
-                    node.Expand();\r
-\r
-                foreach (TreeNode subNode in node.Nodes)\r
-                {\r
-                    if (nodeStatus[i] == true)\r
-                        subNode.Expand();\r
-                }\r
-\r
-                i++;\r
+                this.BeginInvoke(new UpdateUIHandler(setEncodeLabelFinished));\r
+                return;\r
             }\r
+            lbl_encode.Text = "Encoding Finished";\r
+            btn_start.Text = "Start";\r
+            btn_start.ToolTipText = "Start the encoding process";\r
+            btn_start.Image = Properties.Resources.Play;\r
         }\r
-        #endregion\r
 \r
-        #region Functions\r
-        private void loadNormalPreset()\r
-        {\r
-            treeView_presets.Nodes.Find("Normal", true);\r
-\r
-            foreach (TreeNode treenode in treeView_presets.Nodes)\r
-            {\r
-                foreach (TreeNode node in treenode.Nodes)\r
-                {\r
-                    if (node.Text.ToString().Equals("Normal"))\r
-                        treeView_presets.SelectedNode = treeView_presets.Nodes[treenode.Index].Nodes[0];\r
-                }\r
-            }\r
-        }\r
-        /// <summary>\r
-        /// Take in a File destination and change it's file extension to a new Extension\r
-        /// </summary>\r
-        /// <param name="destination"></param>\r
-        /// <param name="newExtension"></param>\r
-        /// <returns>String of the new file path and extension</returns>\r
-        public void setExtension(string newExtension)\r
-        {\r
-            text_destination.Text = text_destination.Text.Replace(".mp4", newExtension);\r
-            text_destination.Text = text_destination.Text.Replace(".m4v", newExtension);\r
-            text_destination.Text = text_destination.Text.Replace(".mkv", newExtension);\r
-            text_destination.Text = text_destination.Text.Replace(".avi", newExtension);\r
-            text_destination.Text = text_destination.Text.Replace(".ogm", newExtension);\r
-        }\r
         #endregion\r
 \r
-        #region Drive Detection\r
+        #region DVD Drive Detection\r
         // Source Button Drive Detection\r
         private delegate void ProgressUpdateHandler();\r
         private void getDriveInfoThread()\r
@@ -1637,7 +1665,7 @@ namespace Handbrake
         }\r
         #endregion\r
 \r
-        #region Audio Panel Stuff\r
+        #region Audio Panel Code Helpers\r
         public void setAudioByContainer(String path)\r
         {\r
             string oldval = "";\r
@@ -1892,52 +1920,6 @@ namespace Handbrake
         }\r
         #endregion\r
 \r
-        #region Encoding\r
-\r
-        // Declarations\r
-        private delegate void UpdateUIHandler();\r
-\r
-        // Encoding Functions\r
-        private void procMonitor(object state)\r
-        {\r
-            // Make sure we are not already encoding and if we are then display an error.\r
-            if (hbProc != null)\r
-                hbProc.CloseMainWindow();\r
-            else\r
-            {\r
-                hbProc = cliObj.runCli(this, (string)state);\r
-                hbProc.WaitForExit();\r
-                setEncodeLabelFinished();\r
-                hbProc = null;\r
-\r
-                // If the window is minimized, display the notification in a popup.\r
-                if (FormWindowState.Minimized == this.WindowState)\r
-                {\r
-                    notifyIcon.BalloonTipText = lbl_encode.Text;\r
-                    notifyIcon.ShowBalloonTip(500);\r
-                }\r
-\r
-                // After the encode is done, we may want to shutdown, suspend etc.\r
-                cliObj.addCLIQueryToLog((string)state);\r
-                cliObj.copyLog((string)state, text_destination.Text); // Make a copy of the log in the users desired location if necessary\r
-                cliObj.afterEncodeAction();\r
-            }\r
-        }\r
-        private void setEncodeLabelFinished()\r
-        {\r
-            if (this.InvokeRequired)\r
-            {\r
-                this.BeginInvoke(new UpdateUIHandler(setEncodeLabelFinished));\r
-                return;\r
-            }\r
-            lbl_encode.Text = "Encoding Finished";\r
-            btn_start.Text = "Start";\r
-            btn_start.ToolTipText = "Start the encoding process";\r
-            btn_start.Image = Properties.Resources.Play;\r
-        }\r
-\r
-        #endregion\r
-\r
         #region Public Methods\r
 \r
         /// <summary>\r
@@ -2070,42 +2052,6 @@ namespace Handbrake
 \r
         #endregion\r
 \r
-        #region Taskbar Tray Icon\r
-        private void frmMain_Resize(object sender, EventArgs e)\r
-        {\r
-            if (FormWindowState.Minimized == this.WindowState)\r
-            {\r
-                notifyIcon.Visible = true;\r
-                if (lbl_encode.Text != "")\r
-                    notifyIcon.BalloonTipText = lbl_encode.Text;\r
-                else\r
-                    notifyIcon.BalloonTipText = "Not Encoding";\r
-                notifyIcon.ShowBalloonTip(500);\r
-                this.Hide();\r
-            }\r
-            else if (FormWindowState.Normal == this.WindowState)\r
-                notifyIcon.Visible = false;\r
-        }\r
-        private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)\r
-        {\r
-            this.Visible = true;\r
-            this.Activate();\r
-            this.WindowState = FormWindowState.Normal;\r
-            notifyIcon.Visible = false;\r
-        }\r
-        private void btn_minimize_Click(object sender, EventArgs e)\r
-        {\r
-            this.WindowState = FormWindowState.Minimized;\r
-        }\r
-        private void btn_restore_Click(object sender, EventArgs e)\r
-        {\r
-            this.Visible = true;\r
-            this.Activate();\r
-            this.WindowState = FormWindowState.Normal;\r
-            notifyIcon.Visible = false;\r
-        }\r
-        #endregion\r
-\r
         // This is the END of the road ------------------------------------------------------------------------------\r
     }\r
 }
\ No newline at end of file
index 1358066..a4cb7ec 100644 (file)
@@ -7,6 +7,7 @@ namespace Handbrake
 {\r
     class x264Panel\r
     {\r
+\r
         /// <summary>\r
         /// Reset all components to defaults and clears the x264 rtf box\r
         /// </summary>\r