diff options
Diffstat (limited to 'win/CS/Controls')
-rw-r--r-- | win/CS/Controls/AudioPanel.Designer.cs | 75 | ||||
-rw-r--r-- | win/CS/Controls/AudioPanel.cs | 144 |
2 files changed, 130 insertions, 89 deletions
diff --git a/win/CS/Controls/AudioPanel.Designer.cs b/win/CS/Controls/AudioPanel.Designer.cs index dbc1e84c9..13a5c48ef 100644 --- a/win/CS/Controls/AudioPanel.Designer.cs +++ b/win/CS/Controls/AudioPanel.Designer.cs @@ -49,8 +49,6 @@ namespace Handbrake.Controls this.drp_audioBitrate = new System.Windows.Forms.ComboBox();
this.drp_audioSample = new System.Windows.Forms.ComboBox();
this.AudioMenuRowHeightHack = new System.Windows.Forms.ImageList(this.components);
- this.label1 = new System.Windows.Forms.Label();
- this.lbl_audioTrack = new System.Windows.Forms.Label();
this.audioList = new System.Windows.Forms.DataGridView();
this.ToolTips = new System.Windows.Forms.ToolTip(this.components);
this.btn_AdvancedAudio = new System.Windows.Forms.Button();
@@ -61,6 +59,8 @@ namespace Handbrake.Controls this.Bitrate = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.DRC = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Gain = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.audioList_MoveToBottom = new System.Windows.Forms.ToolStripMenuItem();
+ this.audioList_MoveToTop = new System.Windows.Forms.ToolStripMenuItem();
this.audioMenu.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.audioList)).BeginInit();
this.SuspendLayout();
@@ -68,24 +68,26 @@ namespace Handbrake.Controls // audioMenu
//
this.audioMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.audioList_MoveToTop,
this.audioList_moveup,
this.audioList_movedown,
+ this.audioList_MoveToBottom,
this.toolStripSeparator2,
this.audioList_remove});
this.audioMenu.Name = "audioMenu";
- this.audioMenu.Size = new System.Drawing.Size(139, 76);
+ this.audioMenu.Size = new System.Drawing.Size(165, 142);
//
// audioList_moveup
//
this.audioList_moveup.Name = "audioList_moveup";
- this.audioList_moveup.Size = new System.Drawing.Size(138, 22);
+ this.audioList_moveup.Size = new System.Drawing.Size(164, 22);
this.audioList_moveup.Text = "Move Up";
this.audioList_moveup.Click += new System.EventHandler(this.AudioList_moveup_Click);
//
// audioList_movedown
//
this.audioList_movedown.Name = "audioList_movedown";
- this.audioList_movedown.Size = new System.Drawing.Size(138, 22);
+ this.audioList_movedown.Size = new System.Drawing.Size(164, 22);
this.audioList_movedown.Text = "Move Down";
this.audioList_movedown.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.audioList_movedown.Click += new System.EventHandler(this.AudioList_movedown_Click);
@@ -93,12 +95,12 @@ namespace Handbrake.Controls // toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
- this.toolStripSeparator2.Size = new System.Drawing.Size(135, 6);
+ this.toolStripSeparator2.Size = new System.Drawing.Size(161, 6);
//
// audioList_remove
//
this.audioList_remove.Name = "audioList_remove";
- this.audioList_remove.Size = new System.Drawing.Size(138, 22);
+ this.audioList_remove.Size = new System.Drawing.Size(164, 22);
this.audioList_remove.Text = "Remove";
this.audioList_remove.Click += new System.EventHandler(this.AudioList_remove_Click);
//
@@ -150,7 +152,7 @@ namespace Handbrake.Controls "AC3 Passthru",
"AC3 (ffmpeg)",
"DTS Passthru"});
- this.drp_audioEncoder.Location = new System.Drawing.Point(191, 87);
+ this.drp_audioEncoder.Location = new System.Drawing.Point(191, 66);
this.drp_audioEncoder.Name = "drp_audioEncoder";
this.drp_audioEncoder.Size = new System.Drawing.Size(111, 21);
this.drp_audioEncoder.TabIndex = 52;
@@ -168,7 +170,7 @@ namespace Handbrake.Controls "Dolby Surround",
"Dolby Pro Logic II",
"6 Channel Discrete"});
- this.drp_audioMix.Location = new System.Drawing.Point(309, 87);
+ this.drp_audioMix.Location = new System.Drawing.Point(309, 66);
this.drp_audioMix.Name = "drp_audioMix";
this.drp_audioMix.Size = new System.Drawing.Size(147, 21);
this.drp_audioMix.TabIndex = 54;
@@ -181,7 +183,7 @@ namespace Handbrake.Controls this.drp_audioTrack.FormattingEnabled = true;
this.drp_audioTrack.Items.AddRange(new object[] {
"Automatic"});
- this.drp_audioTrack.Location = new System.Drawing.Point(16, 87);
+ this.drp_audioTrack.Location = new System.Drawing.Point(16, 66);
this.drp_audioTrack.Name = "drp_audioTrack";
this.drp_audioTrack.Size = new System.Drawing.Size(170, 21);
this.drp_audioTrack.TabIndex = 50;
@@ -203,7 +205,7 @@ namespace Handbrake.Controls "112",
"128",
"160"});
- this.drp_audioBitrate.Location = new System.Drawing.Point(534, 87);
+ this.drp_audioBitrate.Location = new System.Drawing.Point(534, 66);
this.drp_audioBitrate.Name = "drp_audioBitrate";
this.drp_audioBitrate.Size = new System.Drawing.Size(67, 21);
this.drp_audioBitrate.TabIndex = 58;
@@ -221,7 +223,7 @@ namespace Handbrake.Controls "32",
"24",
"22.05"});
- this.drp_audioSample.Location = new System.Drawing.Point(461, 87);
+ this.drp_audioSample.Location = new System.Drawing.Point(461, 66);
this.drp_audioSample.Name = "drp_audioSample";
this.drp_audioSample.Size = new System.Drawing.Size(67, 21);
this.drp_audioSample.TabIndex = 56;
@@ -234,27 +236,6 @@ namespace Handbrake.Controls this.AudioMenuRowHeightHack.ImageSize = new System.Drawing.Size(1, 18);
this.AudioMenuRowHeightHack.TransparentColor = System.Drawing.Color.Transparent;
//
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.BackColor = System.Drawing.Color.Transparent;
- this.label1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.label1.Location = new System.Drawing.Point(13, 66);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(94, 13);
- this.label1.TabIndex = 68;
- this.label1.Text = "Selected Track:";
- //
- // lbl_audioTrack
- //
- this.lbl_audioTrack.AutoSize = true;
- this.lbl_audioTrack.BackColor = System.Drawing.Color.Transparent;
- this.lbl_audioTrack.Location = new System.Drawing.Point(113, 66);
- this.lbl_audioTrack.Name = "lbl_audioTrack";
- this.lbl_audioTrack.Size = new System.Drawing.Size(32, 13);
- this.lbl_audioTrack.TabIndex = 69;
- this.lbl_audioTrack.Text = "None";
- //
// audioList
//
this.audioList.AllowUserToAddRows = false;
@@ -273,7 +254,7 @@ namespace Handbrake.Controls this.Gain});
this.audioList.ContextMenuStrip = this.audioMenu;
this.audioList.GridColor = System.Drawing.Color.White;
- this.audioList.Location = new System.Drawing.Point(16, 114);
+ this.audioList.Location = new System.Drawing.Point(16, 94);
this.audioList.Name = "audioList";
this.audioList.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
this.audioList.RowHeadersVisible = false;
@@ -283,7 +264,7 @@ namespace Handbrake.Controls this.audioList.ShowCellToolTips = false;
this.audioList.ShowEditingIcon = false;
this.audioList.ShowRowErrors = false;
- this.audioList.Size = new System.Drawing.Size(685, 180);
+ this.audioList.Size = new System.Drawing.Size(685, 200);
this.audioList.TabIndex = 67;
this.ToolTips.SetToolTip(this.audioList, "The audio tracks to be encoded into the output file.");
this.audioList.SelectionChanged += new System.EventHandler(this.audioList_SelectionChanged);
@@ -293,7 +274,7 @@ namespace Handbrake.Controls this.btn_AdvancedAudio.BackColor = System.Drawing.Color.Transparent;
this.btn_AdvancedAudio.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btn_AdvancedAudio.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
- this.btn_AdvancedAudio.Location = new System.Drawing.Point(607, 86);
+ this.btn_AdvancedAudio.Location = new System.Drawing.Point(607, 65);
this.btn_AdvancedAudio.Name = "btn_AdvancedAudio";
this.btn_AdvancedAudio.Size = new System.Drawing.Size(94, 23);
this.btn_AdvancedAudio.TabIndex = 70;
@@ -303,7 +284,7 @@ namespace Handbrake.Controls //
// Source
//
- this.Source.DataPropertyName = "SourceTrack";
+ this.Source.DataPropertyName = "TrackDisplay";
this.Source.FillWeight = 49.69727F;
this.Source.HeaderText = "Source";
this.Source.Name = "Source";
@@ -369,12 +350,24 @@ namespace Handbrake.Controls this.Gain.ReadOnly = true;
this.Gain.Width = 60;
//
+ // audioList_MoveToBottom
+ //
+ this.audioList_MoveToBottom.Name = "audioList_MoveToBottom";
+ this.audioList_MoveToBottom.Size = new System.Drawing.Size(164, 22);
+ this.audioList_MoveToBottom.Text = "Move To Bottom";
+ this.audioList_MoveToBottom.Click += new System.EventHandler(this.audioList_MoveToBottom_Click);
+ //
+ // audioList_MoveToTop
+ //
+ this.audioList_MoveToTop.Name = "audioList_MoveToTop";
+ this.audioList_MoveToTop.Size = new System.Drawing.Size(164, 22);
+ this.audioList_MoveToTop.Text = "Move to Top";
+ this.audioList_MoveToTop.Click += new System.EventHandler(this.audioList_MoveToTop_Click);
+ //
// AudioPanel
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.BackColor = System.Drawing.Color.Transparent;
- this.Controls.Add(this.label1);
- this.Controls.Add(this.lbl_audioTrack);
this.Controls.Add(this.drp_audioTrack);
this.Controls.Add(this.btn_AdvancedAudio);
this.Controls.Add(this.drp_audioSample);
@@ -411,8 +404,6 @@ namespace Handbrake.Controls private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem audioList_remove;
internal System.Windows.Forms.ComboBox drp_audioBitrate;
- internal System.Windows.Forms.Label label1;
- internal System.Windows.Forms.Label lbl_audioTrack;
private System.Windows.Forms.DataGridView audioList;
private System.Windows.Forms.ToolTip ToolTips;
private System.Windows.Forms.Button btn_AdvancedAudio;
@@ -423,5 +414,7 @@ namespace Handbrake.Controls private System.Windows.Forms.DataGridViewTextBoxColumn Bitrate;
private System.Windows.Forms.DataGridViewTextBoxColumn DRC;
private System.Windows.Forms.DataGridViewTextBoxColumn Gain;
+ private System.Windows.Forms.ToolStripMenuItem audioList_MoveToTop;
+ private System.Windows.Forms.ToolStripMenuItem audioList_MoveToBottom;
}
}
diff --git a/win/CS/Controls/AudioPanel.cs b/win/CS/Controls/AudioPanel.cs index ed38c368f..471ac9d2f 100644 --- a/win/CS/Controls/AudioPanel.cs +++ b/win/CS/Controls/AudioPanel.cs @@ -8,7 +8,6 @@ namespace Handbrake.Controls using System;
using System.Collections.Generic;
using System.ComponentModel;
- using System.Globalization;
using System.Linq;
using System.Windows.Forms;
@@ -20,24 +19,17 @@ namespace Handbrake.Controls using Handbrake.ToolWindows;
- using AudioTrack = HandBrake.ApplicationServices.Model.Encoding.AudioTrack;
-
/// <summary>
/// The AudioPanel Control
/// </summary>
public partial class AudioPanel : UserControl
{
- /**
- * TODO - There is a lot of old code in here that access the datagrid that can be refactored to work with
- * the new AudioTrack BindingList.
- */
-
- private static readonly CultureInfo Culture = new CultureInfo("en-US", false);
+ #region Private Variables
+ private readonly BindingList<AudioTrack> audioTracks = new BindingList<AudioTrack>();
private const string AC3Passthru = "AC3 Passthru";
private const string DTSPassthru = "DTS Passthru";
- AdvancedAudio advancedAudio = new AdvancedAudio();
-
- private readonly BindingList<AudioTrack> audioTracks = new BindingList<AudioTrack>();
+ private AdvancedAudio advancedAudio = new AdvancedAudio();
+ #endregion
#region Constructor and Events
@@ -48,13 +40,18 @@ namespace Handbrake.Controls {
InitializeComponent();
+ this.ScannedTracks = new BindingList<Audio>
+ {
+ Audio.NoneFound
+ };
+
this.audioList.AutoGenerateColumns = false;
this.audioList.DataSource = audioTracks;
drp_audioMix.SelectedItem = "Dolby Pro Logic II";
drp_audioSample.SelectedIndex = 1;
-
+ drp_audioTrack.DataSource = this.ScannedTracks;
}
/// <summary>
@@ -66,10 +63,12 @@ namespace Handbrake.Controls #region Properties
+ public BindingList<Audio> ScannedTracks { get; set; }
+
/// <summary>
/// Gets the AudioTracks Collection
/// </summary>
- public IEnumerable<AudioTrack> AudioTracks
+ public BindingList<AudioTrack> AudioTracks
{
get
{
@@ -115,21 +114,21 @@ namespace Handbrake.Controls /// <returns>True if m4v is required</returns>
public bool RequiresM4V()
{
- return true;
+ return this.AudioTracks.Any(item => item.Encoder == AudioEncoder.Ac3Passthrough || item.Encoder == AudioEncoder.DtsPassthrough || item.Encoder == AudioEncoder.Ac3);
}
/// <summary>
/// Load an arraylist of AudioTrack items into the list.
/// </summary>
- /// <param name="audioTracks">List of audio tracks</param>
- public void LoadTracks(List<AudioTrack> audioTracks)
+ /// <param name="tracks">List of audio tracks</param>
+ public void LoadTracks(List<AudioTrack> tracks)
{
ClearAudioList();
- if (audioTracks == null)
+ if (tracks == null)
return;
- foreach (AudioTrack track in audioTracks)
+ foreach (AudioTrack track in tracks)
{
this.audioTracks.Add(track);
}
@@ -150,15 +149,21 @@ namespace Handbrake.Controls if (selectedTitle.AudioTracks.Count == 0)
{
audioList.Rows.Clear();
- drp_audioTrack.Items.Clear();
- drp_audioTrack.Items.Add("None Found");
+ this.ScannedTracks.Clear();
+ this.ScannedTracks.Add(Audio.NoneFound);
+ this.drp_audioTrack.Refresh();
drp_audioTrack.SelectedIndex = 0;
return;
}
// Setup the Audio track source dropdown with the new audio tracks.
- drp_audioTrack.Items.Clear();
- drp_audioTrack.Items.AddRange(selectedTitle.AudioTracks.ToArray());
+ this.ScannedTracks.Clear();
+ foreach (var item in selectedTitle.AudioTracks)
+ {
+ this.ScannedTracks.Add(item);
+ }
+ this.drp_audioTrack.Refresh();
+ drp_audioTrack.SelectedIndex = 0;
// Add any tracks the preset has, if there is a preset and no audio tracks in the list currently
if (audioList.Rows.Count == 0 && preset != null)
@@ -206,17 +211,17 @@ namespace Handbrake.Controls case "drp_audioTrack":
if (audioList.Rows.Count != 0 && audioList.SelectedRows.Count != 0)
{
- track.SourceTrack = drp_audioTrack.Text;
+ track.ScannedTrack = drp_audioTrack.SelectedItem as Audio;
// If the track isn't AC3, and the encoder is, change it.
- if (track.Encoder == AudioEncoder.Ac3Passthrough && !track.SourceTrack.Contains("(AC3)"))
+ if (track.Encoder == AudioEncoder.Ac3Passthrough && !track.ScannedTrack.Format.Contains("AC3"))
{
// Switch to AAC
drp_audioEncoder.SelectedIndex = 0;
}
// If the track isn't DTS, and the encoder is, change it.
- if (track.Encoder == AudioEncoder.DtsPassthrough && !track.SourceTrack.Contains("DTS"))
+ if (track.Encoder == AudioEncoder.DtsPassthrough && !track.ScannedTrack.Format.Contains("DTS"))
{
// Switch to AAC
drp_audioEncoder.SelectedIndex = 0;
@@ -264,12 +269,6 @@ namespace Handbrake.Controls }
audioList.Refresh();
-
- if (audioList.SelectedRows.Count == 1)
- {
- AudioTrack item = audioList.SelectedRows[0].DataBoundItem as AudioTrack;
- if (item != null) lbl_audioTrack.Text = track.SourceTrack;
- }
}
/// <summary>
@@ -289,21 +288,17 @@ namespace Handbrake.Controls AudioTrack track = audioList.SelectedRows[0].DataBoundItem as AudioTrack;
if (track != null)
{
- drp_audioTrack.SelectedItem = track.SourceTrack;
+ drp_audioTrack.SelectedItem = track.ScannedTrack;
drp_audioEncoder.SelectedItem = EnumHelper<AudioEncoder>.GetDescription(track.Encoder);
drp_audioMix.SelectedItem = EnumHelper<Mixdown>.GetDescription(track.MixDown);
drp_audioSample.SelectedItem = track.SampleRate;
drp_audioBitrate.SelectedItem = track.Bitrate;
- lbl_audioTrack.Text = track.SourceTrack;
// Set the Advanced Control.
if (!advancedAudio.IsDisposed)
advancedAudio.Track = track;
}
}
- else
- lbl_audioTrack.Text = "(Click \"Add Track\" to add)";
-
}
#endregion
@@ -341,7 +336,7 @@ namespace Handbrake.Controls // Create the Model
AudioTrack track = new AudioTrack
{
- SourceTrack = this.drp_audioTrack.Text,
+ ScannedTrack = this.drp_audioTrack.SelectedItem as Audio,
Encoder = EnumHelper<AudioEncoder>.GetValue(this.drp_audioEncoder.Text),
MixDown = EnumHelper<Mixdown>.GetValue(this.drp_audioMix.Text),
SampleRate = samplerate,
@@ -422,6 +417,26 @@ namespace Handbrake.Controls RemoveTrack();
}
+ /// <summary>
+ /// Move to Top
+ /// </summary>
+ /// <param name="sender">The Sender</param>
+ /// <param name="e">The Event Args</param>
+ private void audioList_MoveToTop_Click(object sender, EventArgs e)
+ {
+ MoveTo(true);
+ }
+
+ /// <summary>
+ /// Move to Bottom
+ /// </summary>
+ /// <param name="sender">The Sender</param>
+ /// <param name="e">The Event Args</param>
+ private void audioList_MoveToBottom_Click(object sender, EventArgs e)
+ {
+ this.MoveTo(false);
+ }
+
#endregion
#region Private Functions
@@ -431,6 +446,12 @@ namespace Handbrake.Controls /// </summary>
private void AutomaticTrackSelection()
{
+ if (drp_audioTrack.SelectedItem.ToString() == Audio.NoneFound.Description)
+ {
+ this.AudioTracks.Clear();
+ return;
+ }
+
// Handle Native Language and "Dub Foreign language audio" and "Use Foreign language audio and Subtitles" Options
if (Properties.Settings.Default.NativeLanguage == "Any")
{
@@ -439,7 +460,7 @@ namespace Handbrake.Controls {
if (this.drp_audioTrack.SelectedItem != null)
{
- track.SourceTrack = this.drp_audioTrack.SelectedItem.ToString();
+ track.ScannedTrack = this.drp_audioTrack.SelectedItem as HandBrake.ApplicationServices.Parsing.Audio;
}
}
}
@@ -466,13 +487,14 @@ namespace Handbrake.Controls if (drp_audioTrack.SelectedItem != null)
foreach (AudioTrack track in this.audioTracks)
- track.SourceTrack = drp_audioTrack.SelectedItem.ToString();
+ track.ScannedTrack =
+ drp_audioTrack.SelectedItem as HandBrake.ApplicationServices.Parsing.Audio;
else
{
drp_audioTrack.SelectedIndex = 0;
if (drp_audioTrack.SelectedItem != null)
foreach (AudioTrack track in this.audioTracks)
- track.SourceTrack = drp_audioTrack.SelectedItem.ToString();
+ track.ScannedTrack = drp_audioTrack.SelectedItem as HandBrake.ApplicationServices.Parsing.Audio;
}
break;
@@ -483,7 +505,7 @@ namespace Handbrake.Controls if (drp_audioTrack.SelectedItem != null)
foreach (AudioTrack track in this.audioTracks)
- track.SourceTrack = drp_audioTrack.SelectedItem.ToString();
+ track.ScannedTrack = drp_audioTrack.SelectedItem as HandBrake.ApplicationServices.Parsing.Audio;
break;
}
}
@@ -542,6 +564,7 @@ namespace Handbrake.Controls if (audioList.SelectedRows.Count == 0) return;
DataGridViewRow item = audioList.SelectedRows[0];
+ AudioTrack track = item.DataBoundItem as AudioTrack;
int index = item.Index;
if (up) index--;
@@ -549,10 +572,30 @@ namespace Handbrake.Controls if (index < audioList.Rows.Count || (audioList.Rows.Count > index && index >= 0))
{
- audioList.Rows.Remove(item);
- audioList.Rows.Insert(index, item);
- audioList.ClearSelection();
- item.Selected = true;
+ this.AudioTracks.Remove(track);
+ this.audioTracks.Insert(index, track);
+ this.audioList.ClearSelection();
+ this.audioList.Rows[index].Selected = true;
+ }
+ }
+
+ private void MoveTo(bool top)
+ {
+ if (audioList.SelectedRows.Count == 0) return;
+
+ DataGridViewRow item = audioList.SelectedRows[0];
+ AudioTrack track = item.DataBoundItem as AudioTrack;
+ int index = item.Index;
+
+ if (top) index = 0;
+ else index = this.audioList.Rows.Count - 1;
+
+ if (index < audioList.Rows.Count || (audioList.Rows.Count > index && index >= 0))
+ {
+ this.AudioTracks.Remove(track);
+ this.audioTracks.Insert(index, track);
+ this.audioList.ClearSelection();
+ this.audioList.Rows[index].Selected = true;
}
}
@@ -683,6 +726,13 @@ namespace Handbrake.Controls private void btn_AdvancedAudio_Click(object sender, EventArgs e)
{
+ if (audioList.SelectedRows.Count == 0)
+ {
+ MessageBox.Show(
+ "Please select an audio track.", "No Track Selected", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ return;
+ }
+
if (advancedAudio.IsDisposed)
{
advancedAudio = new AdvancedAudio { Track = this.audioList.SelectedRows[0].DataBoundItem as AudioTrack };
@@ -690,7 +740,5 @@ namespace Handbrake.Controls advancedAudio.Show();
}
-
-
}
}
\ No newline at end of file |