diff --git a/CUERipper/Options.cs b/CUERipper/Options.cs index 5872d8b..1feaaec 100644 --- a/CUERipper/Options.cs +++ b/CUERipper/Options.cs @@ -14,9 +14,9 @@ namespace CUERipper { public partial class Options : Form { - private CUEConfig config; + private object config; - public Options(CUEConfig config) + public Options(object config) { this.config = config; this.InitializeComponent(); @@ -24,7 +24,7 @@ namespace CUERipper private void Options_Load(object sender, EventArgs e) { - this.propertyGrid1.SelectedObject = new CUERipperSettings(this.config); + this.propertyGrid1.SelectedObject = this.config; } } diff --git a/CUERipper/frmCUERipper.Designer.cs b/CUERipper/frmCUERipper.Designer.cs index bdd1853..625643f 100644 --- a/CUERipper/frmCUERipper.Designer.cs +++ b/CUERipper/frmCUERipper.Designer.cs @@ -56,6 +56,7 @@ namespace CUERipper this.numericWriteOffset = new System.Windows.Forms.NumericUpDown(); this.lblWriteOffset = new System.Windows.Forms.Label(); this.groupBoxSettings = new System.Windows.Forms.GroupBox(); + this.buttonEncoderSettings = new System.Windows.Forms.Button(); this.checkBoxTestAndCopy = new System.Windows.Forms.CheckBox(); this.bnComboBoxLosslessOrNot = new CUEControls.ImgComboBox(); this.losslessOrNotBindingSource = new System.Windows.Forms.BindingSource(this.components); @@ -283,6 +284,7 @@ namespace CUERipper // // groupBoxSettings // + this.groupBoxSettings.Controls.Add(this.buttonEncoderSettings); this.groupBoxSettings.Controls.Add(this.checkBoxTestAndCopy); this.groupBoxSettings.Controls.Add(this.bnComboBoxLosslessOrNot); this.groupBoxSettings.Controls.Add(this.bnComboBoxEncoder); @@ -300,6 +302,14 @@ namespace CUERipper this.groupBoxSettings.Name = "groupBoxSettings"; this.groupBoxSettings.TabStop = false; // + // buttonEncoderSettings + // + this.buttonEncoderSettings.BackgroundImage = global::CUERipper.Properties.Resources.cog; + resources.ApplyResources(this.buttonEncoderSettings, "buttonEncoderSettings"); + this.buttonEncoderSettings.Name = "buttonEncoderSettings"; + this.buttonEncoderSettings.UseVisualStyleBackColor = true; + this.buttonEncoderSettings.Click += new System.EventHandler(this.buttonEncoderSettings_Click); + // // checkBoxTestAndCopy // resources.ApplyResources(this.checkBoxTestAndCopy, "checkBoxTestAndCopy"); @@ -887,6 +897,7 @@ namespace CUERipper private System.Windows.Forms.Panel panel5; private System.Windows.Forms.Panel panel6; private System.Windows.Forms.Panel panel7; + private System.Windows.Forms.Button buttonEncoderSettings; } } diff --git a/CUERipper/frmCUERipper.cs b/CUERipper/frmCUERipper.cs index 5bb42bc..7862e7f 100644 --- a/CUERipper/frmCUERipper.cs +++ b/CUERipper/frmCUERipper.cs @@ -994,6 +994,35 @@ namespace CUERipper } } + private void resetEncoderModes(CUEToolsUDC encoder) + { + if (encoder.settings != null) + { + encoder.settings.PCM = AudioPCMConfig.RedBook; + buttonEncoderSettings.Enabled = encoder.settings.HasBrowsableAttributes(); + } + string[] modes = encoder.SupportedModes; + if (modes == null || modes.Length < 2) + { + trackBarEncoderMode.Visible = false; + labelEncoderMode.Visible = false; + labelEncoderMinMode.Visible = false; + labelEncoderMaxMode.Visible = false; + } + else + { + trackBarEncoderMode.Maximum = modes.Length - 1; + trackBarEncoderMode.Value = encoder.DefaultModeIndex == -1 ? modes.Length - 1 : encoder.DefaultModeIndex; + labelEncoderMode.Text = encoder.EncoderMode; + labelEncoderMinMode.Text = modes[0]; + labelEncoderMaxMode.Text = modes[modes.Length - 1]; + trackBarEncoderMode.Visible = true; + labelEncoderMode.Visible = true; + labelEncoderMinMode.Visible = true; + labelEncoderMaxMode.Visible = true; + } + } + private void bnComboBoxEncoder_SelectedValueChanged(object sender, EventArgs e) { if (SelectedOutputAudioFormat == null) @@ -1005,27 +1034,7 @@ namespace CUERipper SelectedOutputAudioFmt.encoderLossless = encoder; else SelectedOutputAudioFmt.encoderLossy = encoder; - if (encoder.settings != null) encoder.settings.PCM = AudioPCMConfig.RedBook; - string[] modes = encoder.SupportedModes; - if (modes == null || modes.Length < 2) - { - trackBarEncoderMode.Visible = false; - labelEncoderMode.Visible = false; - labelEncoderMinMode.Visible = false; - labelEncoderMaxMode.Visible = false; - } - else - { - trackBarEncoderMode.Maximum = modes.Length - 1; - trackBarEncoderMode.Value = encoder.DefaultModeIndex == -1 ? modes.Length - 1 : encoder.DefaultModeIndex; - labelEncoderMode.Text = encoder.EncoderMode; - labelEncoderMinMode.Text = modes[0]; - labelEncoderMaxMode.Text = modes[modes.Length - 1]; - trackBarEncoderMode.Visible = true; - labelEncoderMode.Visible = true; - labelEncoderMinMode.Visible = true; - labelEncoderMaxMode.Visible = true; - } + resetEncoderModes(encoder); } private void trackBarEncoderMode_Scroll(object sender, EventArgs e) @@ -1552,7 +1561,7 @@ namespace CUERipper private void buttonSettings_Click(object sender, EventArgs e) { - var form = new Options(this._config); + var form = new Options(new CUERipperSettings(this._config)); form.ShowDialog(this); } @@ -1574,6 +1583,18 @@ namespace CUERipper cueRipperConfig.DriveOffsets[selectedDriveInfo.drive.ARName] = (int)numericWriteOffset.Value; } } + + private void buttonEncoderSettings_Click(object sender, EventArgs e) + { + CUEToolsUDC encoder = bnComboBoxEncoder.SelectedItem as CUEToolsUDC; + if (encoder == null) + return; + if (encoder.settings == null) + return; + var form = new Options(encoder.settings); + form.ShowDialog(this); + resetEncoderModes(encoder); + } } internal class BackgroundWorkerArtworkArgs diff --git a/CUERipper/frmCUERipper.resx b/CUERipper/frmCUERipper.resx index db2af26..e379100 100644 --- a/CUERipper/frmCUERipper.resx +++ b/CUERipper/frmCUERipper.resx @@ -383,7 +383,7 @@ groupBoxSettings - 12 + 13 True @@ -413,13 +413,40 @@ groupBoxSettings - 11 + 12 + + + Stretch + + + 83, 46 + + + 21, 21 + + + 35 + + + MiddleLeft + + + buttonEncoderSettings + + + System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBoxSettings + + + 0 True - 206, 48 + 212, 48 83, 17 @@ -440,7 +467,7 @@ groupBoxSettings - 0 + 1 17, 95 @@ -455,7 +482,7 @@ 40, 0 - 82, 21 + 70, 21 0 @@ -473,19 +500,19 @@ groupBoxSettings - 1 + 2 1217, 56 - 94, 46 + 105, 46 40, 0 - 101, 21 + 90, 21 3 @@ -503,7 +530,7 @@ groupBoxSettings - 2 + 3 NoControl @@ -530,16 +557,16 @@ groupBoxSettings - 3 + 4 1045, 56 - 94, 19 + 83, 19 - 101, 21 + 112, 21 2 @@ -557,7 +584,7 @@ groupBoxSettings - 4 + 5 True @@ -596,7 +623,7 @@ groupBoxSettings - 5 + 6 526, 56 @@ -608,7 +635,7 @@ 40, 0 - 82, 21 + 70, 21 1 @@ -626,7 +653,7 @@ groupBoxSettings - 6 + 7 False @@ -665,7 +692,7 @@ groupBoxSettings - 7 + 8 Tahoma, 8.25pt @@ -701,7 +728,7 @@ groupBoxSettings - 8 + 9 NoControl @@ -728,7 +755,7 @@ groupBoxSettings - 9 + 10 NoControl @@ -752,7 +779,7 @@ groupBoxSettings - 10 + 11 Left @@ -789,7 +816,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABy - CQAAAk1TRnQBSQFMAgEBBAEAAdwBAQHcAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CQAAAk1TRnQBSQFMAgEBBAEAAQwBAgEMAQIBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA @@ -939,7 +966,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAY - EgAAAk1TRnQBSQFMAgEBCwEAAdwBAQHcAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + EgAAAk1TRnQBSQFMAgEBCwEAAQwBAgEMAQIBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAATADAAEBAQABCAYAAQwYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/CUETools.Codecs/AudioEncoderSettings.cs b/CUETools.Codecs/AudioEncoderSettings.cs index c4b1c90..2dddf5a 100644 --- a/CUETools.Codecs/AudioEncoderSettings.cs +++ b/CUETools.Codecs/AudioEncoderSettings.cs @@ -51,6 +51,22 @@ namespace CUETools.Codecs return this.MemberwiseClone() as AudioEncoderSettings; } + public bool HasBrowsableAttributes() + { + bool hasBrowsable = false; + foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this)) + { + bool isBrowsable = true; + foreach (var attribute in property.Attributes) + { + var browsable = attribute as BrowsableAttribute; + isBrowsable &= browsable == null || browsable.Browsable; + } + hasBrowsable |= isBrowsable; + } + return hasBrowsable; + } + [Browsable(false)] [XmlIgnore] public AudioPCMConfig PCM