From 33fb6c7dd32a586b60376e6854074e6086f15644 Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 11 Mar 2011 22:42:30 +0000 Subject: [PATCH] WinGui: - Advanced options panel for ffmpeg mpeg-4 encoder options. - Bug fixes in the new preset service and handling code. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3840 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Controls/AdvancedEncoderOpts.Designer.cs | 100 ++++++++++++++ win/C#/Controls/AdvancedEncoderOpts.cs | 59 +++++++++ win/C#/Controls/AdvancedEncoderOpts.resx | 123 ++++++++++++++++++ win/C#/Functions/PresetLoader.cs | 2 +- win/C#/Functions/QueryGenerator.cs | 21 ++- .../Model/EncodeTask.cs | 4 +- .../Services/Interfaces/IPresetService.cs | 8 ++ .../Services/PresetService.cs | 17 ++- .../Utilities/PlistUtility.cs | 4 +- .../Utilities/QueryParserUtility.cs | 10 +- win/C#/HandBrake10.sln | 4 +- win/C#/HandBrakeCS.csproj | 10 ++ win/C#/Program.cs | 21 ++- win/C#/frmMain.Designer.cs | 25 +++- win/C#/frmMain.cs | 102 +++++++-------- win/C#/frmQueue.cs | 2 +- 16 files changed, 430 insertions(+), 82 deletions(-) create mode 100644 win/C#/Controls/AdvancedEncoderOpts.Designer.cs create mode 100644 win/C#/Controls/AdvancedEncoderOpts.cs create mode 100644 win/C#/Controls/AdvancedEncoderOpts.resx diff --git a/win/C#/Controls/AdvancedEncoderOpts.Designer.cs b/win/C#/Controls/AdvancedEncoderOpts.Designer.cs new file mode 100644 index 000000000..4ee6d85cf --- /dev/null +++ b/win/C#/Controls/AdvancedEncoderOpts.Designer.cs @@ -0,0 +1,100 @@ +/* x264Panel.Designer.cs $ + + This file is part of the HandBrake source code. + Homepage: . + It may be used under the terms of the GNU General Public License. */ + +namespace Handbrake.Controls +{ + partial class AdvancedEncoderOpts + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.label43 = new System.Windows.Forms.Label(); + this.advancedQuery = new System.Windows.Forms.RichTextBox(); + this.ToolTip = new System.Windows.Forms.ToolTip(this.components); + this.label64 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label43 + // + this.label43.AutoSize = true; + this.label43.BackColor = System.Drawing.Color.Transparent; + this.label43.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label43.Location = new System.Drawing.Point(13, 13); + this.label43.Name = "label43"; + this.label43.Size = new System.Drawing.Size(63, 13); + this.label43.TabIndex = 49; + this.label43.Text = "Advanced"; + // + // advancedQuery + // + this.advancedQuery.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.advancedQuery.Location = new System.Drawing.Point(16, 53); + this.advancedQuery.Name = "advancedQuery"; + this.advancedQuery.Size = new System.Drawing.Size(688, 128); + this.advancedQuery.TabIndex = 80; + this.advancedQuery.Text = ""; + // + // ToolTip + // + this.ToolTip.Active = false; + this.ToolTip.AutomaticDelay = 1000; + this.ToolTip.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info; + // + // label64 + // + this.label64.AutoSize = true; + this.label64.Location = new System.Drawing.Point(13, 35); + this.label64.Name = "label64"; + this.label64.Size = new System.Drawing.Size(163, 13); + this.label64.TabIndex = 81; + this.label64.Text = "Encoder advanced option string:"; + // + // x264Panel + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; + this.BackColor = System.Drawing.Color.Transparent; + this.Controls.Add(this.label64); + this.Controls.Add(this.advancedQuery); + this.Controls.Add(this.label43); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Size = new System.Drawing.Size(720, 305); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + internal System.Windows.Forms.Label label43; + internal System.Windows.Forms.RichTextBox advancedQuery; + private System.Windows.Forms.ToolTip ToolTip; + internal System.Windows.Forms.Label label64; + } +} diff --git a/win/C#/Controls/AdvancedEncoderOpts.cs b/win/C#/Controls/AdvancedEncoderOpts.cs new file mode 100644 index 000000000..8eb2e8ae7 --- /dev/null +++ b/win/C#/Controls/AdvancedEncoderOpts.cs @@ -0,0 +1,59 @@ +/* AdvancedEncoderOpts.cs $ + This file is part of the HandBrake source code. + Homepage: . + It may be used under the terms of the GNU General Public License. */ + +namespace Handbrake.Controls +{ + using System.Windows.Forms; + + /// + /// The x264 Panel + /// + public partial class AdvancedEncoderOpts : UserControl + { + /// + /// Initializes a new instance of the class. + /// + public AdvancedEncoderOpts() + { + InitializeComponent(); + + if (Properties.Settings.Default.tooltipEnable) + ToolTip.Active = true; + } + + /// + /// Gets or sets the X264 query string + /// + public string AdavancedQuery + { + get + { + return advancedQuery.Text; + } + + set + { + advancedQuery.Text = value; + } + } + + public bool IsDisabled + { + set + { + if (value) + { + this.advancedQuery.Enabled = false; + this.advancedQuery.Text = "Advanced encoder option passthrough is not currently supported for the encoder you have chosen."; + } + else + { + this.advancedQuery.Enabled = true; + this.advancedQuery.Text = string.Empty; + } + } + } + } +} \ No newline at end of file diff --git a/win/C#/Controls/AdvancedEncoderOpts.resx b/win/C#/Controls/AdvancedEncoderOpts.resx new file mode 100644 index 000000000..89a8b3473 --- /dev/null +++ b/win/C#/Controls/AdvancedEncoderOpts.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/win/C#/Functions/PresetLoader.cs b/win/C#/Functions/PresetLoader.cs index 84fdb2dfb..00e8aa46b 100644 --- a/win/C#/Functions/PresetLoader.cs +++ b/win/C#/Functions/PresetLoader.cs @@ -267,7 +267,7 @@ namespace Handbrake.Functions #region Other - mainWindow.x264Panel.X264Query = presetQuery.X264Options; + mainWindow.x264Panel.X264Query = presetQuery.AdvancedEncoderOptions; // Set the preset name mainWindow.labelPreset.Text = "Output Settings (Preset: " + name + ")"; diff --git a/win/C#/Functions/QueryGenerator.cs b/win/C#/Functions/QueryGenerator.cs index adb2199bc..97499962b 100644 --- a/win/C#/Functions/QueryGenerator.cs +++ b/win/C#/Functions/QueryGenerator.cs @@ -541,9 +541,26 @@ namespace Handbrake.Functions private static string X264Query(frmMain mainWindow) { - if (string.IsNullOrEmpty(mainWindow.x264Panel.X264Query)) return string.Empty; + string advancedOptions = string.Empty; + switch (mainWindow.drp_videoEncoder.SelectedIndex) + { + case 0: // ffmpeg + advancedOptions = string.IsNullOrEmpty(mainWindow.x264Panel.X264Query) + ? string.Empty + : mainWindow.x264Panel.X264Query; + break; + case 1: // x264 + advancedOptions = string.IsNullOrEmpty(mainWindow.x264Panel.X264Query) + ? string.Empty + : mainWindow.x264Panel.X264Query; + break; + case 2: // VP3 + advancedOptions = string.Empty; + break; + } + - return " -x " + mainWindow.x264Panel.X264Query; + return " -x " + advancedOptions; } private static string ExtraSettings() diff --git a/win/C#/HandBrake.ApplicationServices/Model/EncodeTask.cs b/win/C#/HandBrake.ApplicationServices/Model/EncodeTask.cs index c3a58ac40..d600ba81c 100644 --- a/win/C#/HandBrake.ApplicationServices/Model/EncodeTask.cs +++ b/win/C#/HandBrake.ApplicationServices/Model/EncodeTask.cs @@ -279,9 +279,9 @@ namespace HandBrake.ApplicationServices.Model #region Advanced /// - /// Gets or sets X264Options. + /// Gets or sets AdvancedEncoderOptions. /// - public string X264Options { get; set; } + public string AdvancedEncoderOptions { get; set; } #endregion diff --git a/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IPresetService.cs b/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IPresetService.cs index 07daab3c9..30d6b2f3a 100644 --- a/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IPresetService.cs +++ b/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IPresetService.cs @@ -39,6 +39,14 @@ namespace HandBrake.ApplicationServices.Services.Interfaces /// void Remove(Preset preset); + /// + /// Remove a group of presets by category + /// + /// + /// The Category to remove + /// + void RemoveGroup(string category); + /// /// Get a Preset /// diff --git a/win/C#/HandBrake.ApplicationServices/Services/PresetService.cs b/win/C#/HandBrake.ApplicationServices/Services/PresetService.cs index 9a9f26564..f46a8bad1 100644 --- a/win/C#/HandBrake.ApplicationServices/Services/PresetService.cs +++ b/win/C#/HandBrake.ApplicationServices/Services/PresetService.cs @@ -140,8 +140,23 @@ namespace HandBrake.ApplicationServices.Services public void Remove(Preset preset) { this.presets.Remove(preset); + this.UpdatePresetFiles(); + } + + /// + /// Remove a group of presets by category + /// + /// + /// The Category to remove + /// + public void RemoveGroup(string category) + { + List removeList = this.presets.Where(p => p.Category == category).ToList(); + foreach (Preset preset in removeList) + { + this.presets.Remove(preset); + } - // Update the presets file this.UpdatePresetFiles(); } diff --git a/win/C#/HandBrake.ApplicationServices/Utilities/PlistUtility.cs b/win/C#/HandBrake.ApplicationServices/Utilities/PlistUtility.cs index 660bc905d..ee1ab225a 100644 --- a/win/C#/HandBrake.ApplicationServices/Utilities/PlistUtility.cs +++ b/win/C#/HandBrake.ApplicationServices/Utilities/PlistUtility.cs @@ -254,7 +254,7 @@ namespace HandBrake.ApplicationServices.Utilities // Advanced x264 tab case "x264Option": - parsed.X264Options = value; + parsed.AdvancedEncoderOptions = value; break; // Preset Information @@ -548,7 +548,7 @@ namespace HandBrake.ApplicationServices.Utilities AddEncodeElement(xmlWriter, "VideoTwoPass", "integer", parsed.TwoPass ? "1" : "0"); // x264 string - AddEncodeElement(xmlWriter, "x264Option", "string", parsed.X264Options); + AddEncodeElement(xmlWriter, "x264Option", "string", parsed.AdvancedEncoderOptions); } /// diff --git a/win/C#/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs b/win/C#/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs index 18619170a..ab90cf010 100644 --- a/win/C#/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs +++ b/win/C#/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs @@ -103,8 +103,8 @@ namespace HandBrake.ApplicationServices.Utilities Match chapterMarkers = Regex.Match(input, @" -m"); Match chapterMarkersFileMode = Regex.Match(input, @"--markers"); - // H264 Tab - Match x264 = Regex.Match(input, @"-x ([.,/a-zA-Z0-9=:-]*)"); + // Advanced Tab + Match advanced = Regex.Match(input, @"-x ([.,/a-zA-Z0-9=:-]*)"); #endregion @@ -395,10 +395,10 @@ namespace HandBrake.ApplicationServices.Utilities #endregion - #region H.264 and other + #region Advanced and other - if (x264.Success) - parsed.X264Options = x264.ToString().Replace("-x ", string.Empty); + if (advanced.Success) + parsed.AdvancedEncoderOptions = advanced.ToString().Replace("-x ", string.Empty); #endregion } diff --git a/win/C#/HandBrake10.sln b/win/C#/HandBrake10.sln index b7785d1d9..56c85201d 100644 --- a/win/C#/HandBrake10.sln +++ b/win/C#/HandBrake10.sln @@ -29,8 +29,8 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A2923D42-C38B-4B12-8CBA-B8D93D6B13A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A2923D42-C38B-4B12-8CBA-B8D93D6B13A3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A2923D42-C38B-4B12-8CBA-B8D93D6B13A3}.Debug|Any CPU.ActiveCfg = Debug|x86 + {A2923D42-C38B-4B12-8CBA-B8D93D6B13A3}.Debug|Any CPU.Build.0 = Debug|x86 {A2923D42-C38B-4B12-8CBA-B8D93D6B13A3}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {A2923D42-C38B-4B12-8CBA-B8D93D6B13A3}.Debug|Mixed Platforms.Build.0 = Debug|x86 {A2923D42-C38B-4B12-8CBA-B8D93D6B13A3}.Debug|x64.ActiveCfg = Debug|x86 diff --git a/win/C#/HandBrakeCS.csproj b/win/C#/HandBrakeCS.csproj index 1cd590ce8..4a3d04311 100644 --- a/win/C#/HandBrakeCS.csproj +++ b/win/C#/HandBrakeCS.csproj @@ -183,6 +183,12 @@ AudioPanel.cs + + UserControl + + + AdvancedEncoderOpts.cs + UserControl @@ -281,6 +287,10 @@ AudioPanel.cs Designer + + AdvancedEncoderOpts.cs + Designer + Filters.cs Designer diff --git a/win/C#/Program.cs b/win/C#/Program.cs index 919543c48..bf90c2da7 100644 --- a/win/C#/Program.cs +++ b/win/C#/Program.cs @@ -13,6 +13,7 @@ namespace Handbrake using HandBrake.ApplicationServices; using HandBrake.ApplicationServices.Services; + using HandBrake.Framework.Views; using Handbrake.Properties; @@ -121,11 +122,21 @@ namespace Handbrake /// Unhandled Exception EventArgs private static void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e) { - MessageBox.Show( - "An Unknown Error has occured. \n\n Exception:" + e.ExceptionObject, - "Unhandled Exception", - MessageBoxButtons.OK, - MessageBoxIcon.Error); + try + { + ExceptionWindow window = new ExceptionWindow(); + window.Setup("An Unknown Error has occured.", e.ExceptionObject.ToString()); + window.ShowDialog(); + } + catch (Exception) + { + MessageBox.Show( + "An Unknown Error has occured. \n\n Exception:" + e.ExceptionObject, + "Unhandled Exception", + MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } public static int InstanceId; diff --git a/win/C#/frmMain.Designer.cs b/win/C#/frmMain.Designer.cs index 525da334c..1171afa78 100644 --- a/win/C#/frmMain.Designer.cs +++ b/win/C#/frmMain.Designer.cs @@ -117,6 +117,7 @@ namespace Handbrake this.tab_chapters = new System.Windows.Forms.TabPage(); this.label31 = new System.Windows.Forms.Label(); this.tab_advanced = new System.Windows.Forms.TabPage(); + this.advancedEncoderOpts = new Handbrake.Controls.AdvancedEncoderOpts(); this.x264Panel = new Handbrake.Controls.x264Panel(); this.tab_query = new System.Windows.Forms.TabPage(); this.btn_clear = new System.Windows.Forms.Button(); @@ -285,7 +286,7 @@ namespace Handbrake this.check_turbo.Enabled = false; this.check_turbo.Location = new System.Drawing.Point(495, 134); this.check_turbo.Name = "check_turbo"; - this.check_turbo.Size = new System.Drawing.Size(101, 17); + this.check_turbo.Size = new System.Drawing.Size(99, 17); this.check_turbo.TabIndex = 9; this.check_turbo.Text = "Turbo first Pass"; this.ToolTip.SetToolTip(this.check_turbo, "Makes the first pass of a 2 pass encode faster."); @@ -555,7 +556,7 @@ namespace Handbrake this.radio_cq.BackColor = System.Drawing.Color.Transparent; this.radio_cq.Location = new System.Drawing.Point(366, 37); this.radio_cq.Name = "radio_cq"; - this.radio_cq.Size = new System.Drawing.Size(110, 17); + this.radio_cq.Size = new System.Drawing.Size(105, 17); this.radio_cq.TabIndex = 3; this.radio_cq.Text = "Constant Quality:"; this.ToolTip.SetToolTip(this.radio_cq, resources.GetString("radio_cq.ToolTip")); @@ -569,7 +570,7 @@ namespace Handbrake this.radio_avgBitrate.Checked = true; this.radio_avgBitrate.Location = new System.Drawing.Point(367, 108); this.radio_avgBitrate.Name = "radio_avgBitrate"; - this.radio_avgBitrate.Size = new System.Drawing.Size(116, 17); + this.radio_avgBitrate.Size = new System.Drawing.Size(112, 17); this.radio_avgBitrate.TabIndex = 4; this.radio_avgBitrate.TabStop = true; this.radio_avgBitrate.Text = "Avg Bitrate (kbps):"; @@ -583,7 +584,7 @@ namespace Handbrake this.check_2PassEncode.BackColor = System.Drawing.Color.Transparent; this.check_2PassEncode.Location = new System.Drawing.Point(385, 134); this.check_2PassEncode.Name = "check_2PassEncode"; - this.check_2PassEncode.Size = new System.Drawing.Size(104, 17); + this.check_2PassEncode.Size = new System.Drawing.Size(106, 17); this.check_2PassEncode.TabIndex = 10; this.check_2PassEncode.Text = "2-Pass Encoding"; this.ToolTip.SetToolTip(this.check_2PassEncode, resources.GetString("check_2PassEncode.ToolTip")); @@ -871,7 +872,7 @@ namespace Handbrake this.radio_constantFramerate.Checked = true; this.radio_constantFramerate.Location = new System.Drawing.Point(0, 0); this.radio_constantFramerate.Name = "radio_constantFramerate"; - this.radio_constantFramerate.Size = new System.Drawing.Size(122, 17); + this.radio_constantFramerate.Size = new System.Drawing.Size(117, 17); this.radio_constantFramerate.TabIndex = 17; this.radio_constantFramerate.TabStop = true; this.radio_constantFramerate.Text = "Constant Framerate"; @@ -883,7 +884,7 @@ namespace Handbrake this.radio_peakAndVariable.BackColor = System.Drawing.Color.Transparent; this.radio_peakAndVariable.Location = new System.Drawing.Point(0, 23); this.radio_peakAndVariable.Name = "radio_peakAndVariable"; - this.radio_peakAndVariable.Size = new System.Drawing.Size(116, 17); + this.radio_peakAndVariable.Size = new System.Drawing.Size(113, 17); this.radio_peakAndVariable.TabIndex = 19; this.radio_peakAndVariable.Text = "Variable Framerate"; this.radio_peakAndVariable.UseVisualStyleBackColor = false; @@ -1051,6 +1052,7 @@ namespace Handbrake // tab_advanced // this.tab_advanced.BackColor = System.Drawing.Color.Transparent; + this.tab_advanced.Controls.Add(this.advancedEncoderOpts); this.tab_advanced.Controls.Add(this.x264Panel); this.tab_advanced.Location = new System.Drawing.Point(4, 22); this.tab_advanced.Name = "tab_advanced"; @@ -1060,6 +1062,16 @@ namespace Handbrake this.tab_advanced.Text = "Advanced"; this.tab_advanced.UseVisualStyleBackColor = true; // + // advancedEncoderOpts + // + this.advancedEncoderOpts.AdavancedQuery = ""; + this.advancedEncoderOpts.BackColor = System.Drawing.Color.Transparent; + this.advancedEncoderOpts.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.advancedEncoderOpts.Location = new System.Drawing.Point(0, 0); + this.advancedEncoderOpts.Name = "advancedEncoderOpts"; + this.advancedEncoderOpts.Size = new System.Drawing.Size(720, 209); + this.advancedEncoderOpts.TabIndex = 1; + // // x264Panel // this.x264Panel.BackColor = System.Drawing.Color.Transparent; @@ -1935,5 +1947,6 @@ namespace Handbrake internal RadioButton radio_peakAndVariable; internal RadioButton radio_constantFramerate; private Panel panel1; + internal Controls.AdvancedEncoderOpts advancedEncoderOpts; } } \ No newline at end of file diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index a3cd44187..0a8305dbe 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -607,16 +607,29 @@ namespace Handbrake private void BtnRemovePreset_Click(object sender, EventArgs e) { + throw new Exception(); + if (treeView_presets.SelectedNode == null) + { + return; + } + DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { - if (treeView_presets.SelectedNode != null) + if (treeView_presets.SelectedNode.Nodes.Count > 0) { + // Delete the selected group category + this.presetHandler.RemoveGroup(treeView_presets.SelectedNode.Text.Trim()); + } + else + { + // Delete the selected item. presetHandler.Remove((Preset)treeView_presets.SelectedNode.Tag); - treeView_presets.Nodes.Remove(treeView_presets.SelectedNode); } + treeView_presets.Nodes.Remove(treeView_presets.SelectedNode); } + treeView_presets.Select(); } @@ -625,14 +638,9 @@ namespace Handbrake { if (treeView_presets.SelectedNode != null) { - DialogResult result = MessageBox.Show("Are you sure you wish to set this preset as the default?", - "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (result == DialogResult.Yes) - { - Properties.Settings.Default.defaultPreset = treeView_presets.SelectedNode.Text; - Properties.Settings.Default.Save(); - MessageBox.Show("New default preset set.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information); - } + Settings.Default.defaultPreset = treeView_presets.SelectedNode.Text; + Settings.Default.Save(); + MessageBox.Show("New default preset set.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information); } else MessageBox.Show("Please select a preset first.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); @@ -652,13 +660,6 @@ namespace Handbrake { presetHandler.UpdateBuiltInPresets(string.Empty); LoadPresetPanel(); - if (treeView_presets.Nodes.Count == 0) - 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); - else - MessageBox.Show("Presets have been updated!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information); - treeView_presets.ExpandAll(); } @@ -737,31 +738,7 @@ namespace Handbrake { if (e.KeyCode == Keys.Delete) { - DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset", - MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (result == DialogResult.Yes) - { - if (treeView_presets.SelectedNode != null) - presetHandler.Remove((Preset)treeView_presets.SelectedNode.Tag); - - // Remember each nodes expanded status so we can reload it - List nodeStatus = new List(); - foreach (TreeNode node in treeView_presets.Nodes) - nodeStatus.Add(node.IsExpanded); - - // Now reload the preset panel - LoadPresetPanel(); - - // And finally, re-expand any of the nodes if required - int i = 0; - foreach (TreeNode node in treeView_presets.Nodes) - { - if (nodeStatus[i]) - node.Expand(); - - i++; - } - } + this.BtnRemovePreset_Click(sender, e); } } @@ -1732,7 +1709,7 @@ namespace Handbrake public void SetExtension(string newExtension) { if (newExtension == ".mp4" || newExtension == ".m4v") - if (Check_ChapterMarkers.Checked || AudioSettings.RequiresM4V() || Subtitles.RequiresM4V() || Properties.Settings.Default.useM4v == 2) + if (Check_ChapterMarkers.Checked || AudioSettings.RequiresM4V() || Subtitles.RequiresM4V() || Properties.Settings.Default.useM4v == 2) newExtension = Properties.Settings.Default.useM4v == 1 ? ".mp4" : ".m4v"; else newExtension = ".mp4"; @@ -1752,7 +1729,6 @@ namespace Handbrake if (check_2PassEncode.CheckState == CheckState.Checked) check_turbo.Enabled = true; - tab_advanced.Enabled = true; if ((drop_format.Text.Contains("MP4")) || (drop_format.Text.Contains("M4V"))) check_iPodAtom.Enabled = true; else @@ -1762,13 +1738,12 @@ namespace Handbrake { check_turbo.CheckState = CheckState.Unchecked; check_turbo.Enabled = false; - tab_advanced.Enabled = false; x264Panel.X264Query = string.Empty; check_iPodAtom.Enabled = false; check_iPodAtom.Checked = false; } - // Setup the CQ Slider + // Setup the CQ Slider and Advanced Panel switch (drp_videoEncoder.Text) { case "MPEG-4 (FFmpeg)": @@ -1776,12 +1751,13 @@ namespace Handbrake slider_videoQuality.Value = 20; // Just reset to 70% QP 10 on encode change. slider_videoQuality.Minimum = 1; slider_videoQuality.Maximum = 31; + this.x264Panel.Visible = false; + this.advancedEncoderOpts.Visible = true; + this.advancedEncoderOpts.IsDisabled = false; break; case "H.264 (x264)": slider_videoQuality.Minimum = 0; slider_videoQuality.TickFrequency = 1; - - CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US"); double cqStep = Properties.Settings.Default.x264cqstep; double multiplier = 1.0 / cqStep; double value = slider_videoQuality.Value * multiplier; @@ -1791,12 +1767,19 @@ namespace Handbrake if (value < slider_videoQuality.Maximum) slider_videoQuality.Value = slider_videoQuality.Maximum - (int)value; + this.x264Panel.Visible = true; + this.x264Panel.BringToFront(); + this.advancedEncoderOpts.Visible = false; break; case "VP3 (Theora)": if (slider_videoQuality.Value > 63) slider_videoQuality.Value = 45; // Just reset to 70% QP 45 on encode change. slider_videoQuality.Minimum = 0; slider_videoQuality.Maximum = 63; + + this.x264Panel.Visible = false; + this.advancedEncoderOpts.Visible = true; + this.advancedEncoderOpts.IsDisabled = true; break; } } @@ -1884,7 +1867,7 @@ namespace Handbrake { lbl_SliderValue.Text += " (Warning: lossless)"; } - + break; case "VP3 (Theora)": lbl_SliderValue.Text = "QP:" + slider_videoQuality.Value; @@ -1894,10 +1877,17 @@ namespace Handbrake private void radio_avgBitrate_CheckedChanged(object sender, EventArgs e) { - text_bitrate.Enabled = true; - slider_videoQuality.Enabled = false; + if (radio_avgBitrate.Checked) + { + text_bitrate.Enabled = true; + if (string.IsNullOrEmpty(text_bitrate.Text)) + { + text_bitrate.Text = "1500"; + } + slider_videoQuality.Enabled = false; - check_2PassEncode.Enabled = true; + check_2PassEncode.Enabled = true; + } } private void radio_cq_CheckedChanged(object sender, EventArgs e) @@ -2399,13 +2389,15 @@ namespace Handbrake } if (preset.Category == category && rootNode != null) - rootNode.Nodes.Add(new TreeNode(preset.Name) { ToolTipText = preset.Description, ForeColor = Color.DarkBlue }); + rootNode.Nodes.Add(new TreeNode(preset.Name) { ToolTipText = preset.Description, ForeColor = Color.DarkBlue, Tag = preset }); } rootNode = null; category = null; foreach (Preset preset in this.presetHandler.Presets.Where(p => !p.IsBuildIn)) // User Presets { + // If the category of this preset doesn't match the current category we are processing + // Then we need to create a new root node. if (preset.Category != category && preset.Category != string.Empty) { rootNode = new TreeNode(preset.Category) { ForeColor = Color.Black }; @@ -2414,9 +2406,9 @@ namespace Handbrake } if (preset.Category == category && rootNode != null) - rootNode.Nodes.Add(new TreeNode(preset.Name) { ForeColor = Color.Black, ToolTipText = preset.Description }); + rootNode.Nodes.Add(new TreeNode(preset.Name) { ForeColor = Color.Black, ToolTipText = preset.Description, Tag = preset }); else - treeView_presets.Nodes.Add(new TreeNode(preset.Name) { ForeColor = Color.Black, ToolTipText = preset.Description }); + treeView_presets.Nodes.Add(new TreeNode(preset.Name) { ForeColor = Color.Black, ToolTipText = preset.Description, Tag = preset }); } treeView_presets.Update(); diff --git a/win/C#/frmQueue.cs b/win/C#/frmQueue.cs index d715d8970..cf4ac409c 100644 --- a/win/C#/frmQueue.cs +++ b/win/C#/frmQueue.cs @@ -433,7 +433,7 @@ namespace Handbrake lbl_source.Text = queue.QueueManager.LastProcessedJob.Source + "(Title: " + title + " Chapters: " + chapterlbl + ")"; lbl_dest.Text = queue.QueueManager.LastProcessedJob.Destination; lbl_encodeOptions.Text = "Video: " + parsed.VideoEncoder + " Audio: " + audio + Environment.NewLine + - "x264 Options: " + parsed.X264Options; + "x264 Options: " + parsed.AdvancedEncoderOptions; } catch (Exception) { -- 2.40.0