OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Wed, 16 Jan 2008 16:17:37 +0000 (16:17 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Wed, 16 Jan 2008 16:17:37 +0000 (16:17 +0000)
- Tested and fixed a few issues with the appcast updater.
- Fixed a small issue where dropdowns wouldn't have a default value on startup if presets.dat was missing and user defaults was turned off.
- Disabled loose anamorphic for ffmpeg and xvid encodes.
- Added a useful error message to the presets bar when presets.dat is missing.

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

win/C#/Functions/RssReader.cs
win/C#/frmDownload.cs
win/C#/frmMain.Designer.cs
win/C#/frmMain.cs
win/C#/frmMain.resx

index 4a184de..c8aa5a7 100644 (file)
@@ -28,7 +28,7 @@ namespace Handbrake.Functions
 \r
         private string readRss()\r
         {\r
-            rssReader = new XmlTextReader("http://handbrake.m0k.org/appcast.xml");\r
+            rssReader = new XmlTextReader("http://handbrake.fr/appcast.xml");\r
             rssDoc = new XmlDocument();\r
             rssDoc.Load(rssReader);\r
 \r
index 69c079a..73020ff 100644 (file)
@@ -51,9 +51,13 @@ namespace Handbrake
         {\r
             Functions.RssReader rssRead = new Functions.RssReader();\r
 \r
-            string appPath = Application.StartupPath.ToString() + "\\";\r
-            string hbUpdate = rssRead.downloadFile(); \r
-            string downloadPath = appPath + "Handbrake-win.exe";\r
+            string tempPath = Path.Combine(Path.GetTempPath(), "handbrake-setup.exe");\r
+\r
+            if (File.Exists(tempPath))\r
+                File.Delete(tempPath);\r
+\r
+            string hbUpdate = rssRead.downloadFile();\r
+\r
             WebClient wcDownload = new WebClient();\r
                 try\r
                 {\r
@@ -63,7 +67,7 @@ namespace Handbrake
                     Int64 fileSize = webResponse.ContentLength;\r
 \r
                     responceStream = wcDownload.OpenRead(hbUpdate);\r
-                    loacalStream = new FileStream(downloadPath, FileMode.Create, FileAccess.Write, FileShare.None);\r
+                    loacalStream = new FileStream(tempPath, FileMode.Create, FileAccess.Write, FileShare.None);\r
 \r
                     int bytesSize = 0;\r
                     byte[] downBuffer = new byte[2048];\r
@@ -110,14 +114,11 @@ namespace Handbrake
             lblProgress.Text = "Download Complete";\r
             btn_cancel.Text = "Close";\r
 \r
-            string appPath = Application.StartupPath.ToString() + "\\";\r
-            \r
-            Process hbproc = Process.Start(appPath + "Handbrake-win.exe");\r
-            hbproc.WaitForExit();\r
-            hbproc.Dispose();\r
-            hbproc.Close();\r
+            string tempPath = Path.Combine(Path.GetTempPath(), "handbrake-setup.exe");\r
 \r
+            Process startInstall = Process.Start(tempPath);\r
             this.Close();\r
+            Application.Exit();\r
         }\r
 \r
         private void downloadFailed()\r
@@ -128,13 +129,20 @@ namespace Handbrake
 \r
         private void btn_cancel_Click(object sender, EventArgs e)\r
         {\r
-            webResponse.Close();\r
-            responceStream.Close();\r
-            loacalStream.Close();\r
-            downloadThread.Abort();\r
-            progress_download.Value = 0;\r
-            lblProgress.Text = "Download Stopped";\r
-            this.Close();\r
+            try\r
+            {\r
+                webResponse.Close();\r
+                responceStream.Close();\r
+                loacalStream.Close();\r
+                downloadThread.Abort();\r
+                progress_download.Value = 0;\r
+                lblProgress.Text = "Download Stopped";\r
+                this.Close();\r
+            }\r
+            catch (Exception)\r
+            {\r
+                // Do nothing\r
+            }\r
         }\r
     }\r
 }
\ No newline at end of file
index 7367754..814ff1f 100644 (file)
@@ -37,7 +37,7 @@ namespace Handbrake
             this.components = new System.ComponentModel.Container();\r
             System.Windows.Forms.Label Label38;\r
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));\r
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();\r
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();\r
             this.DVD_Save = new System.Windows.Forms.SaveFileDialog();\r
             this.File_Save = new System.Windows.Forms.SaveFileDialog();\r
             this.ToolTip = new System.Windows.Forms.ToolTip(this.components);\r
@@ -133,7 +133,6 @@ namespace Handbrake
             this.label25 = new System.Windows.Forms.Label();\r
             this.lbl_vfr = new System.Windows.Forms.Label();\r
             this.check_iPodAtom = new System.Windows.Forms.CheckBox();\r
-            this.check_grayscale = new System.Windows.Forms.CheckBox();\r
             this.lbl_largeMp4Warning = new System.Windows.Forms.Label();\r
             this.Label22 = new System.Windows.Forms.Label();\r
             this.check_2PassEncode = new System.Windows.Forms.CheckBox();\r
@@ -142,6 +141,7 @@ namespace Handbrake
             this.SliderValue = new System.Windows.Forms.Label();\r
             this.Label46 = new System.Windows.Forms.Label();\r
             this.Label40 = new System.Windows.Forms.Label();\r
+            this.check_grayscale = new System.Windows.Forms.CheckBox();\r
             this.TabPage1 = new System.Windows.Forms.TabPage();\r
             this.text_bottom = new System.Windows.Forms.NumericUpDown();\r
             this.text_top = new System.Windows.Forms.NumericUpDown();\r
@@ -441,7 +441,7 @@ namespace Handbrake
             this.check_largeFile.AutoSize = true;\r
             this.check_largeFile.BackColor = System.Drawing.Color.Transparent;\r
             this.check_largeFile.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_largeFile.Location = new System.Drawing.Point(16, 107);\r
+            this.check_largeFile.Location = new System.Drawing.Point(16, 80);\r
             this.check_largeFile.Name = "check_largeFile";\r
             this.check_largeFile.Size = new System.Drawing.Size(170, 17);\r
             this.check_largeFile.TabIndex = 4;\r
@@ -456,7 +456,7 @@ namespace Handbrake
             this.check_turbo.BackColor = System.Drawing.Color.Transparent;\r
             this.check_turbo.Enabled = false;\r
             this.check_turbo.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_turbo.Location = new System.Drawing.Point(37, 84);\r
+            this.check_turbo.Location = new System.Drawing.Point(37, 57);\r
             this.check_turbo.Name = "check_turbo";\r
             this.check_turbo.Size = new System.Drawing.Size(122, 17);\r
             this.check_turbo.TabIndex = 3;\r
@@ -1260,7 +1260,6 @@ namespace Handbrake
             this.TabPage3.Controls.Add(this.label25);\r
             this.TabPage3.Controls.Add(this.lbl_vfr);\r
             this.TabPage3.Controls.Add(this.check_iPodAtom);\r
-            this.TabPage3.Controls.Add(this.check_grayscale);\r
             this.TabPage3.Controls.Add(this.lbl_largeMp4Warning);\r
             this.TabPage3.Controls.Add(this.check_largeFile);\r
             this.TabPage3.Controls.Add(this.check_turbo);\r
@@ -1289,7 +1288,7 @@ namespace Handbrake
             this.lbl_ipodAtom.BackColor = System.Drawing.Color.Transparent;\r
             this.lbl_ipodAtom.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.lbl_ipodAtom.ForeColor = System.Drawing.Color.Red;\r
-            this.lbl_ipodAtom.Location = new System.Drawing.Point(132, 151);\r
+            this.lbl_ipodAtom.Location = new System.Drawing.Point(132, 124);\r
             this.lbl_ipodAtom.Name = "lbl_ipodAtom";\r
             this.lbl_ipodAtom.Size = new System.Drawing.Size(91, 12);\r
             this.lbl_ipodAtom.TabIndex = 29;\r
@@ -1324,7 +1323,7 @@ namespace Handbrake
             this.check_iPodAtom.AutoSize = true;\r
             this.check_iPodAtom.BackColor = System.Drawing.Color.Transparent;\r
             this.check_iPodAtom.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_iPodAtom.Location = new System.Drawing.Point(16, 146);\r
+            this.check_iPodAtom.Location = new System.Drawing.Point(16, 119);\r
             this.check_iPodAtom.Name = "check_iPodAtom";\r
             this.check_iPodAtom.Size = new System.Drawing.Size(110, 17);\r
             this.check_iPodAtom.TabIndex = 26;\r
@@ -1332,24 +1331,12 @@ namespace Handbrake
             this.check_iPodAtom.UseVisualStyleBackColor = false;\r
             this.check_iPodAtom.CheckedChanged += new System.EventHandler(this.check_iPodAtom_CheckedChanged);\r
             // \r
-            // check_grayscale\r
-            // \r
-            this.check_grayscale.AutoSize = true;\r
-            this.check_grayscale.BackColor = System.Drawing.Color.Transparent;\r
-            this.check_grayscale.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_grayscale.Location = new System.Drawing.Point(16, 38);\r
-            this.check_grayscale.Name = "check_grayscale";\r
-            this.check_grayscale.Size = new System.Drawing.Size(138, 17);\r
-            this.check_grayscale.TabIndex = 1;\r
-            this.check_grayscale.Text = "Grayscale Encoding";\r
-            this.check_grayscale.UseVisualStyleBackColor = false;\r
-            // \r
             // lbl_largeMp4Warning\r
             // \r
             this.lbl_largeMp4Warning.AutoSize = true;\r
             this.lbl_largeMp4Warning.BackColor = System.Drawing.Color.Transparent;\r
             this.lbl_largeMp4Warning.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_largeMp4Warning.Location = new System.Drawing.Point(35, 127);\r
+            this.lbl_largeMp4Warning.Location = new System.Drawing.Point(35, 100);\r
             this.lbl_largeMp4Warning.Name = "lbl_largeMp4Warning";\r
             this.lbl_largeMp4Warning.Size = new System.Drawing.Size(241, 12);\r
             this.lbl_largeMp4Warning.TabIndex = 5;\r
@@ -1371,7 +1358,7 @@ namespace Handbrake
             this.check_2PassEncode.AutoSize = true;\r
             this.check_2PassEncode.BackColor = System.Drawing.Color.Transparent;\r
             this.check_2PassEncode.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_2PassEncode.Location = new System.Drawing.Point(16, 61);\r
+            this.check_2PassEncode.Location = new System.Drawing.Point(16, 34);\r
             this.check_2PassEncode.Name = "check_2PassEncode";\r
             this.check_2PassEncode.Size = new System.Drawing.Size(119, 17);\r
             this.check_2PassEncode.TabIndex = 2;\r
@@ -1434,6 +1421,18 @@ namespace Handbrake
             this.Label40.TabIndex = 13;\r
             this.Label40.Text = "Constant Quality:";\r
             // \r
+            // check_grayscale\r
+            // \r
+            this.check_grayscale.AutoSize = true;\r
+            this.check_grayscale.BackColor = System.Drawing.Color.Transparent;\r
+            this.check_grayscale.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.check_grayscale.Location = new System.Drawing.Point(16, 217);\r
+            this.check_grayscale.Name = "check_grayscale";\r
+            this.check_grayscale.Size = new System.Drawing.Size(138, 17);\r
+            this.check_grayscale.TabIndex = 1;\r
+            this.check_grayscale.Text = "Grayscale Encoding";\r
+            this.check_grayscale.UseVisualStyleBackColor = false;\r
+            // \r
             // TabPage1\r
             // \r
             this.TabPage1.BackColor = System.Drawing.SystemColors.ControlLight;\r
@@ -1441,6 +1440,7 @@ namespace Handbrake
             this.TabPage1.Controls.Add(this.text_top);\r
             this.TabPage1.Controls.Add(this.text_left);\r
             this.TabPage1.Controls.Add(this.text_right);\r
+            this.TabPage1.Controls.Add(this.check_grayscale);\r
             this.TabPage1.Controls.Add(this.label26);\r
             this.TabPage1.Controls.Add(this.Label56);\r
             this.TabPage1.Controls.Add(this.lbl_Aspect);\r
@@ -1883,9 +1883,9 @@ namespace Handbrake
             // \r
             // number\r
             // \r
-            dataGridViewCellStyle2.Format = "N0";\r
-            dataGridViewCellStyle2.NullValue = null;\r
-            this.number.DefaultCellStyle = dataGridViewCellStyle2;\r
+            dataGridViewCellStyle1.Format = "N0";\r
+            dataGridViewCellStyle1.NullValue = null;\r
+            this.number.DefaultCellStyle = dataGridViewCellStyle1;\r
             this.number.HeaderText = "Chapter Number";\r
             this.number.MaxInputLength = 3;\r
             this.number.Name = "number";\r
index 8e69a8f..8d80d03 100644 (file)
@@ -105,9 +105,10 @@ namespace Handbrake
                 Thread.Sleep(100);\r
             }\r
 \r
-            // Make sure a default cropping option is selected. Not sure why this is not defaulting like the other checkdowns,\r
-            // Can fix it later.\r
-            drp_crop.SelectedItem = "Automatic";\r
+            // Set some defaults for the dropdown menus. Just incase the normal or user presets dont load.\r
+            drp_crop.SelectedIndex = 0;\r
+            drp_videoEncoder.SelectedIndex = 2;\r
+            drp_audioCodec.SelectedIndex = 0;\r
 \r
             //Finished Loading\r
             lblStatus.Text = "Loading Complete!";\r
@@ -902,6 +903,8 @@ namespace Handbrake
                 check_iPodAtom.Checked = false;\r
                 lbl_ipodAtom.Visible = false;\r
                 check_optimiseMP4.Enabled = false;\r
+                check_lAnamorphic.Enabled = false;\r
+                check_lAnamorphic.Checked = false;\r
             }\r
             else\r
             {\r
@@ -912,6 +915,7 @@ namespace Handbrake
                 check_iPodAtom.Enabled = true;\r
                 lbl_ipodAtom.Visible = false;\r
                 check_optimiseMP4.Enabled = true;\r
+                check_lAnamorphic.Enabled = true;\r
             }\r
 \r
         }\r
@@ -990,16 +994,21 @@ namespace Handbrake
         // Function to select the default preset.\r
         private void loadNormalPreset()\r
         {\r
-            int normal = 0;\r
-            foreach (TreeNode treenode in treeView_presets.Nodes)\r
+            string appPath = Application.StartupPath.ToString() + "\\presets.dat";\r
+            if (File.Exists(appPath))\r
             {\r
-                if (treenode.ToString().Equals("TreeNode: Normal"))\r
-                    normal = treenode.Index;\r
-            }\r
 \r
-            TreeNode np = treeView_presets.Nodes[normal];\r
+                int normal = 0;\r
+                foreach (TreeNode treenode in treeView_presets.Nodes)\r
+                {\r
+                    if (treenode.ToString().Equals("TreeNode: Normal"))\r
+                        normal = treenode.Index;\r
+                }\r
 \r
-            treeView_presets.SelectedNode = np;\r
+                TreeNode np = treeView_presets.Nodes[normal];\r
+\r
+                treeView_presets.SelectedNode = np;\r
+            }\r
         }\r
 \r
         // Buttons\r
@@ -1020,33 +1029,38 @@ namespace Handbrake
 \r
             try\r
             {\r
-                string appPath = Application.StartupPath.ToString() + "\\";\r
-                StreamReader presetInput = new StreamReader(appPath + "presets.dat");\r
-\r
-                while (!presetInput.EndOfStream)\r
+                string appPath = Application.StartupPath.ToString() + "\\presets.dat";\r
+                if (File.Exists(appPath))\r
                 {\r
-                    if ((char)presetInput.Peek() == '+')\r
+                    StreamReader presetInput = new StreamReader(appPath);\r
+                    while (!presetInput.EndOfStream)\r
                     {\r
-                        string preset = presetInput.ReadLine().Replace("+ ", "");\r
-                        Regex r = new Regex("(:  )"); // Split on hyphens. \r
-                        string[] presetName = r.Split(preset);\r
+                        if ((char)presetInput.Peek() == '+')\r
+                        {\r
+                            string preset = presetInput.ReadLine().Replace("+ ", "");\r
+                            Regex r = new Regex("(:  )"); // Split on hyphens. \r
+                            string[] presetName = r.Split(preset);\r
 \r
 \r
-                        if (selectedPreset == presetName[0])\r
-                        {\r
-                            // Need to disable anamorphic now, otherwise it may overide the width / height values later.\r
-                            CheckPixelRatio.CheckState = CheckState.Unchecked;\r
+                            if (selectedPreset == presetName[0])\r
+                            {\r
+                                // Need to disable anamorphic now, otherwise it may overide the width / height values later.\r
+                                CheckPixelRatio.CheckState = CheckState.Unchecked;\r
 \r
-                            // Send the query from the file to the Query Parser class\r
-                            Functions.QueryParser presetQuery = Functions.QueryParser.Parse(preset);\r
+                                // Send the query from the file to the Query Parser class\r
+                                Functions.QueryParser presetQuery = Functions.QueryParser.Parse(preset);\r
 \r
-                            // Now load the preset\r
-                            hb_common_func.presetLoader(this, presetQuery, selectedPreset);\r
+                                // Now load the preset\r
+                                hb_common_func.presetLoader(this, presetQuery, selectedPreset);\r
+                            }\r
                         }\r
-\r
+                        else\r
+                            presetInput.ReadLine();\r
                     }\r
-                    else\r
-                        presetInput.ReadLine();\r
+                }\r
+                else\r
+                {\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
                 }\r
             }\r
             catch (Exception exc)\r
index 7964e91..3dee6a5 100644 (file)
@@ -189,12 +189,6 @@ Best used in conjunction with forced subtitles.</value>
   <metadata name="name.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
     <value>True</value>\r
   </metadata>\r
-  <metadata name="number.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
-    <value>True</value>\r
-  </metadata>\r
-  <metadata name="name.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
-    <value>True</value>\r
-  </metadata>\r
   <metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
     <value>731, 18</value>\r
   </metadata>\r