From b532bf3e365ecdd4ce30cb773b25670d4a050a67 Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 19 Nov 2010 18:22:58 +0000 Subject: [PATCH] WinGui: - Some code (currently disabled) to support reading chapter names from source. - Updates to tooltips for the release. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3681 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Controls/Filters.cs | 2 +- win/C#/Functions/Main.cs | 17 ++++++- .../Parsing/Chapter.cs | 7 +++ win/C#/Program.cs | 18 +++++--- win/C#/frmMain.Designer.cs | 46 ++++++++++--------- win/C#/frmMain.cs | 4 +- win/C#/frmMain.resx | 11 ++++- 7 files changed, 72 insertions(+), 33 deletions(-) diff --git a/win/C#/Controls/Filters.cs b/win/C#/Controls/Filters.cs index dda8c9548..e5dbd881b 100644 --- a/win/C#/Controls/Filters.cs +++ b/win/C#/Controls/Filters.cs @@ -274,7 +274,7 @@ namespace Handbrake.Controls private void DropDecombSelectedIndexChanged(object sender, EventArgs e) { text_customDC.Visible = drop_decomb.Text == "Custom"; - if (drop_decomb.SelectedIndex != 0 && drop_deinterlace.SelectedIndex != 0) + if (drop_decomb.SelectedIndex != 0 && drop_deinterlace.SelectedIndex != 0)0000 drop_deinterlace.SelectedIndex = 0; // A Filter has changed so raise a FilterSettingsChanged event. diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs index c26d59502..d061f67d8 100644 --- a/win/C#/Functions/Main.cs +++ b/win/C#/Functions/Main.cs @@ -69,6 +69,10 @@ namespace Handbrake.Functions /// /// Set's up the DataGridView on the Chapters tab (frmMain) /// + /// + /// The currently selected title object. + /// This will be used to get chapter names if they exist. + /// /// /// The DataGridView Control /// @@ -78,7 +82,7 @@ namespace Handbrake.Functions /// /// The chapter naming. /// - public static DataGridView ChapterNaming(DataGridView dataChpt, string chapterEnd) + public static DataGridView ChapterNaming(Title title, DataGridView dataChpt, string chapterEnd) { int i = 0, finish = 0; @@ -87,9 +91,18 @@ namespace Handbrake.Functions while (i < finish) { + string chapterName = string.Empty; + if (title != null) + { + if (title.Chapters.Count <= i && title.Chapters[i] != null) + { + chapterName = title.Chapters[i].ChapterName; + } + } + int n = dataChpt.Rows.Add(); dataChpt.Rows[n].Cells[0].Value = i + 1; - dataChpt.Rows[n].Cells[1].Value = "Chapter " + (i + 1); + dataChpt.Rows[n].Cells[1].Value = string.IsNullOrEmpty(chapterName) ? "Chapter " + (i + 1) : chapterName; dataChpt.Rows[n].Cells[0].ValueType = typeof(int); dataChpt.Rows[n].Cells[1].ValueType = typeof(string); i++; diff --git a/win/C#/HandBrake.ApplicationServices/Parsing/Chapter.cs b/win/C#/HandBrake.ApplicationServices/Parsing/Chapter.cs index 0545dd1d5..949b73f97 100644 --- a/win/C#/HandBrake.ApplicationServices/Parsing/Chapter.cs +++ b/win/C#/HandBrake.ApplicationServices/Parsing/Chapter.cs @@ -20,6 +20,11 @@ namespace HandBrake.ApplicationServices.Parsing /// public int ChapterNumber { get; set; } + /// + /// Gets or sets ChapterName. + /// + public string ChapterName { get; set; } + /// /// Gets or sets The length in time this Chapter spans /// @@ -36,6 +41,7 @@ namespace HandBrake.ApplicationServices.Parsing /// public static Chapter Parse(StringReader output) { + // TODO add support for reading chapter names to the regex. Match m = Regex.Match( output.ReadLine(), @"^ \+ ([0-9]*): cells ([0-9]*)->([0-9]*), ([0-9]*) blocks, duration ([0-9]{2}:[0-9]{2}:[0-9]{2})"); @@ -44,6 +50,7 @@ namespace HandBrake.ApplicationServices.Parsing var thisChapter = new Chapter { ChapterNumber = int.Parse(m.Groups[1].Value.Trim()), + ChapterName = string.Empty, Duration = TimeSpan.Parse(m.Groups[5].Value) }; return thisChapter; diff --git a/win/C#/Program.cs b/win/C#/Program.cs index 24d1507f6..c14754201 100644 --- a/win/C#/Program.cs +++ b/win/C#/Program.cs @@ -7,6 +7,7 @@ namespace Handbrake { using System; using System.Diagnostics; + using System.Drawing; using System.IO; using System.Windows.Forms; @@ -43,10 +44,7 @@ namespace Handbrake } // Make sure we have any pre-requesits before trying to launch - const string FailedInstall = "HandBrake is not installed properly. Please reinstall HandBrake. \n\n"; - const string NightlyCLIMissing = - "If you have downloaded the \"HandBrakeGUI\" nightly, " + - "please make sure you have also downloaded the \"HandBrakeCLI\" nightly and extracted it's contents to the same folder. "; + string failedInstall = "HandBrake is not installed properly. Please reinstall HandBrake. \n\n"; string missingFiles = string.Empty; // Verify HandBrakeCLI.exe exists @@ -58,7 +56,7 @@ namespace Handbrake if (missingFiles != string.Empty) { MessageBox.Show( - FailedInstall + missingFiles + "\n\n" + NightlyCLIMissing, + failedInstall + missingFiles, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -68,7 +66,15 @@ namespace Handbrake // Check were not running on a screen that's going to cause some funnies to happen. Screen scr = Screen.PrimaryScreen; if ((scr.Bounds.Width < 1024) || (scr.Bounds.Height < 620)) - MessageBox.Show("Your system does not meet the minimum requirements for HandBrake. \n" + "Your screen is running at: " + scr.Bounds.Width + "x" + scr.Bounds.Height + " \nScreen resolution is too Low. Must be 1024x620 or greater", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + { + MessageBox.Show( + "Your system does not meet the minimum requirements for HandBrake. \n" + + "Your screen is running at: " + scr.Bounds.Width + "x" + scr.Bounds.Height + + " \nScreen resolution is too Low. Must be 1024x620 or greater.\n\n", + "Error", + MessageBoxButtons.OK, + MessageBoxIcon.Error); + } else { string logDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\logs"); diff --git a/win/C#/frmMain.Designer.cs b/win/C#/frmMain.Designer.cs index 7761f2142..3e2399a78 100644 --- a/win/C#/frmMain.Designer.cs +++ b/win/C#/frmMain.Designer.cs @@ -70,6 +70,7 @@ namespace Handbrake this.btn_importChapters = new System.Windows.Forms.Button(); this.btn_export = new System.Windows.Forms.Button(); this.drop_mode = new System.Windows.Forms.ComboBox(); + this.btn_generate_Query = new System.Windows.Forms.Button(); this.DVD_Open = new System.Windows.Forms.FolderBrowserDialog(); this.File_Open = new System.Windows.Forms.OpenFileDialog(); this.ISO_Open = new System.Windows.Forms.OpenFileDialog(); @@ -128,7 +129,6 @@ namespace Handbrake this.tab_query = new System.Windows.Forms.TabPage(); this.btn_clear = new System.Windows.Forms.Button(); this.label34 = new System.Windows.Forms.Label(); - this.btn_generate_Query = new System.Windows.Forms.Button(); this.label33 = new System.Windows.Forms.Label(); this.rtf_query = new System.Windows.Forms.RichTextBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); @@ -351,8 +351,7 @@ namespace Handbrake this.btn_setDefault.TabIndex = 1; this.btn_setDefault.TabStop = false; this.btn_setDefault.Text = "Set Default"; - this.ToolTip.SetToolTip(this.btn_setDefault, "Set current settings as program defaults.\r\nRequires option to be enabled in Tools" + - " > Options"); + this.ToolTip.SetToolTip(this.btn_setDefault, "Set current settings as program defaults."); this.btn_setDefault.UseVisualStyleBackColor = true; this.btn_setDefault.Click += new System.EventHandler(this.btn_setDefault_Click); // @@ -461,7 +460,7 @@ namespace Handbrake this.btn_addPreset.TabIndex = 3; this.btn_addPreset.TabStop = false; this.btn_addPreset.Text = "Add"; - this.ToolTip.SetToolTip(this.btn_addPreset, "Add a preset to the preset panel"); + this.ToolTip.SetToolTip(this.btn_addPreset, "This option will take the current settings and add it as a new preset."); this.btn_addPreset.UseVisualStyleBackColor = true; this.btn_addPreset.Click += new System.EventHandler(this.btn_addPreset_Click); // @@ -476,7 +475,7 @@ namespace Handbrake this.btn_removePreset.TabIndex = 4; this.btn_removePreset.TabStop = false; this.btn_removePreset.Text = "Remove"; - this.ToolTip.SetToolTip(this.btn_removePreset, "Remove a preset from the panel above."); + this.ToolTip.SetToolTip(this.btn_removePreset, "Remove the selected preset from the panel above."); this.btn_removePreset.UseVisualStyleBackColor = true; this.btn_removePreset.Click += new System.EventHandler(this.btn_removePreset_Click); // @@ -491,7 +490,7 @@ namespace Handbrake this.drop_format.Name = "drop_format"; this.drop_format.Size = new System.Drawing.Size(106, 21); this.drop_format.TabIndex = 28; - this.ToolTip.SetToolTip(this.drop_format, "Select the file container format."); + this.ToolTip.SetToolTip(this.drop_format, "Select the file container format.\r\nHandBrake supports MKV and MP4(M4v)"); this.drop_format.SelectedIndexChanged += new System.EventHandler(this.drop_format_SelectedIndexChanged); // // drop_chapterFinish @@ -536,8 +535,9 @@ namespace Handbrake this.drp_dvdtitle.Name = "drp_dvdtitle"; this.drp_dvdtitle.Size = new System.Drawing.Size(119, 21); this.drp_dvdtitle.TabIndex = 7; - this.ToolTip.SetToolTip(this.drp_dvdtitle, "Select the title you wish to encode.\r\nThe longest title is selected by default af" + - "ter you have scanned a source."); + this.ToolTip.SetToolTip(this.drp_dvdtitle, "Select the title you wish to encode.\r\n\r\nWhen a DVD is in use, HandBrake will try " + + "to determine the \"Main Feature\" title automatically.\r\nPlease note, this is not a" + + "lways accurate and should be checked."); this.drp_dvdtitle.SelectedIndexChanged += new System.EventHandler(this.drp_dvdtitle_SelectedIndexChanged); this.drp_dvdtitle.Click += new System.EventHandler(this.drp_dvdtitle_Click); // @@ -581,8 +581,25 @@ namespace Handbrake this.drop_mode.Name = "drop_mode"; this.drop_mode.Size = new System.Drawing.Size(77, 21); this.drop_mode.TabIndex = 46; + this.ToolTip.SetToolTip(this.drop_mode, resources.GetString("drop_mode.ToolTip")); this.drop_mode.SelectedIndexChanged += new System.EventHandler(this.drop_mode_SelectedIndexChanged); // + // btn_generate_Query + // + this.btn_generate_Query.FlatAppearance.BorderColor = System.Drawing.Color.Black; + this.btn_generate_Query.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btn_generate_Query.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0))))); + this.btn_generate_Query.Location = new System.Drawing.Point(16, 104); + this.btn_generate_Query.Name = "btn_generate_Query"; + this.btn_generate_Query.Size = new System.Drawing.Size(126, 22); + this.btn_generate_Query.TabIndex = 2; + this.btn_generate_Query.Text = "Generate Query"; + this.ToolTip.SetToolTip(this.btn_generate_Query, "This will allow you to override the generated query.\r\nNote, The query in the box " + + "below will always override any automatically generated query, even if you change" + + " title or source."); + this.btn_generate_Query.UseVisualStyleBackColor = true; + this.btn_generate_Query.Click += new System.EventHandler(this.btn_generate_Query_Click); + // // DVD_Open // this.DVD_Open.Description = "Select the \"VIDEO_TS\" folder from your DVD Drive."; @@ -1164,19 +1181,6 @@ namespace Handbrake this.label34.TabIndex = 1; this.label34.Text = resources.GetString("label34.Text"); // - // btn_generate_Query - // - this.btn_generate_Query.FlatAppearance.BorderColor = System.Drawing.Color.Black; - this.btn_generate_Query.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btn_generate_Query.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0))))); - this.btn_generate_Query.Location = new System.Drawing.Point(16, 104); - this.btn_generate_Query.Name = "btn_generate_Query"; - this.btn_generate_Query.Size = new System.Drawing.Size(126, 22); - this.btn_generate_Query.TabIndex = 2; - this.btn_generate_Query.Text = "Generate Query"; - this.btn_generate_Query.UseVisualStyleBackColor = true; - this.btn_generate_Query.Click += new System.EventHandler(this.btn_generate_Query_Click); - // // label33 // this.label33.AutoSize = true; diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index c25a99606..af5895727 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -1529,7 +1529,7 @@ namespace Handbrake data_chpt.Rows.Clear(); if (selectedTitle.Chapters.Count != 1) { - DataGridView chapterGridView = Main.ChapterNaming(data_chpt, drop_chapterFinish.Text); + DataGridView chapterGridView = Main.ChapterNaming(selectedTitle, data_chpt, drop_chapterFinish.Text); if (chapterGridView != null) data_chpt = chapterGridView; } @@ -2031,7 +2031,7 @@ namespace Handbrake private void mnu_resetChapters_Click(object sender, EventArgs e) { data_chpt.Rows.Clear(); - DataGridView chapterGridView = Main.ChapterNaming(data_chpt, drop_chapterFinish.Text); + DataGridView chapterGridView = Main.ChapterNaming(selectedTitle, data_chpt, drop_chapterFinish.Text); if (chapterGridView != null) { data_chpt = chapterGridView; diff --git a/win/C#/frmMain.resx b/win/C#/frmMain.resx index ef0cad28a..c173c6991 100644 --- a/win/C#/frmMain.resx +++ b/win/C#/frmMain.resx @@ -152,7 +152,8 @@ The CSV should be formatted as follows: 2,Chapter 2 Name 3,Chapter 3 Name -Note: Currently, if you wish to use a , in your chapter name, you must escape it with a \ +Note: Currently, if you wish to use a , in your chapter name, you must escape it with a \ +Note2: HandBrake can NOT create chapters, only add a name to any chapters your source currently has. Export to a comma separated file containing the chapter information. @@ -163,6 +164,14 @@ The CSV is formatted as follows: 3,Chapter 3 Name Note: Commas in names are escaped by a \ + + + There are several ranges which can be encoded: +- Encode a range of Chapters. + +The Following options are not 100% accurate: +- Encode video between a start and end time, measured in seconds +- Encode video between a start and end frame. 232, 15 -- 2.40.0