OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 18 Sep 2010 17:07:40 +0000 (17:07 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 18 Sep 2010 17:07:40 +0000 (17:07 +0000)
- Some fixes to the AudioPanel. Changing presets now obeys the preferred language when selecting tracks.

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

win/C#/Controls/AudioPanel.Designer.cs
win/C#/Controls/AudioPanel.cs

index 5c64628..0931d2a 100644 (file)
@@ -59,13 +59,13 @@ namespace Handbrake.Controls
             this.AudioTrackGroup = new System.Windows.Forms.GroupBox();\r
             this.AudioMenuRowHeightHack = new System.Windows.Forms.ImageList(this.components);\r
             this.audioList = new System.Windows.Forms.DataGridView();\r
-            this.Track = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
-            this.Source = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
-            this.AudioCodec = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
-            this.Mixdown = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
-            this.Samplerate = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
-            this.Bitrate = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
             this.DRC = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
+            this.Bitrate = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
+            this.Samplerate = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
+            this.Mixdown = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
+            this.AudioCodec = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
+            this.Source = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
+            this.Track = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
             this.audioMenu.SuspendLayout();\r
             ((System.ComponentModel.ISupportInitialize)(this.tb_drc)).BeginInit();\r
             this.AudioTrackGroup.SuspendLayout();\r
@@ -371,29 +371,32 @@ namespace Handbrake.Controls
             this.audioList.TabIndex = 67;\r
             this.audioList.SelectionChanged += new System.EventHandler(this.audioList_SelectionChanged);\r
             // \r
-            // Track\r
+            // DRC\r
             // \r
-            this.Track.FillWeight = 304.2808F;\r
-            this.Track.HeaderText = "Track";\r
-            this.Track.Name = "Track";\r
-            this.Track.ReadOnly = true;\r
-            this.Track.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;\r
-            this.Track.Width = 50;\r
+            this.DRC.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;\r
+            this.DRC.FillWeight = 96.36334F;\r
+            this.DRC.HeaderText = "DRC";\r
+            this.DRC.Name = "DRC";\r
+            this.DRC.ReadOnly = true;\r
+            this.DRC.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;\r
             // \r
-            // Source\r
+            // Bitrate\r
             // \r
-            this.Source.FillWeight = 49.69727F;\r
-            this.Source.HeaderText = "Source";\r
-            this.Source.Name = "Source";\r
-            this.Source.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;\r
-            this.Source.Width = 150;\r
+            this.Bitrate.FillWeight = 49.69727F;\r
+            this.Bitrate.HeaderText = "Bitrate";\r
+            this.Bitrate.Name = "Bitrate";\r
+            this.Bitrate.ReadOnly = true;\r
+            this.Bitrate.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;\r
+            this.Bitrate.Width = 75;\r
             // \r
-            // AudioCodec\r
+            // Samplerate\r
             // \r
-            this.AudioCodec.HeaderText = "Audio Codec";\r
-            this.AudioCodec.Name = "AudioCodec";\r
-            this.AudioCodec.ReadOnly = true;\r
-            this.AudioCodec.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;\r
+            this.Samplerate.FillWeight = 49.69727F;\r
+            this.Samplerate.HeaderText = "Samplerate";\r
+            this.Samplerate.Name = "Samplerate";\r
+            this.Samplerate.ReadOnly = true;\r
+            this.Samplerate.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;\r
+            this.Samplerate.Width = 75;\r
             // \r
             // Mixdown\r
             // \r
@@ -404,32 +407,29 @@ namespace Handbrake.Controls
             this.Mixdown.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;\r
             this.Mixdown.Width = 150;\r
             // \r
-            // Samplerate\r
+            // AudioCodec\r
             // \r
-            this.Samplerate.FillWeight = 49.69727F;\r
-            this.Samplerate.HeaderText = "Samplerate";\r
-            this.Samplerate.Name = "Samplerate";\r
-            this.Samplerate.ReadOnly = true;\r
-            this.Samplerate.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;\r
-            this.Samplerate.Width = 75;\r
+            this.AudioCodec.HeaderText = "Audio Codec";\r
+            this.AudioCodec.Name = "AudioCodec";\r
+            this.AudioCodec.ReadOnly = true;\r
+            this.AudioCodec.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;\r
             // \r
-            // Bitrate\r
+            // Source\r
             // \r
-            this.Bitrate.FillWeight = 49.69727F;\r
-            this.Bitrate.HeaderText = "Bitrate";\r
-            this.Bitrate.Name = "Bitrate";\r
-            this.Bitrate.ReadOnly = true;\r
-            this.Bitrate.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;\r
-            this.Bitrate.Width = 75;\r
+            this.Source.FillWeight = 49.69727F;\r
+            this.Source.HeaderText = "Source";\r
+            this.Source.Name = "Source";\r
+            this.Source.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;\r
+            this.Source.Width = 150;\r
             // \r
-            // DRC\r
+            // Track\r
             // \r
-            this.DRC.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;\r
-            this.DRC.FillWeight = 96.36334F;\r
-            this.DRC.HeaderText = "DRC";\r
-            this.DRC.Name = "DRC";\r
-            this.DRC.ReadOnly = true;\r
-            this.DRC.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;\r
+            this.Track.FillWeight = 304.2808F;\r
+            this.Track.HeaderText = "Track";\r
+            this.Track.Name = "Track";\r
+            this.Track.ReadOnly = true;\r
+            this.Track.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;\r
+            this.Track.Width = 50;\r
             // \r
             // AudioPanel\r
             // \r
index 9fa9cfd..3555dcd 100644 (file)
@@ -117,10 +117,12 @@ namespace Handbrake.Controls
                 newTrack.Cells[2].Value = track.Encoder;\r
                 newTrack.Cells[3].Value = track.MixDown;\r
                 newTrack.Cells[4].Value = track.SampleRate;\r
-                newTrack.Cells[5].Value = track.Encoder.Contains("AC3") ? "Auto" : track.Bitrate;\r
+                newTrack.Cells[5].Value = track.Encoder.Contains("AC3") || track.Encoder.Contains("DTS") ? "Auto" : track.Bitrate;\r
                 newTrack.Cells[6].Value = track.DRC;\r
                 AddTrackForPreset(newTrack);\r
             }\r
+\r
+            this.AutomaticTrackSelection();\r
         }\r
 \r
         /// <summary>\r
@@ -128,7 +130,7 @@ namespace Handbrake.Controls
         /// </summary>\r
         /// <param name="selectedTitle">The selected title</param>\r
         /// <param name="preset">A preset</param>\r
-        public void SetTrackList(Title selectedTitle, Preset preset)\r
+        public void SetTrackListFromPreset(Title selectedTitle, Preset preset)\r
         {\r
             if (selectedTitle.AudioTracks.Count == 0)\r
             {\r
@@ -139,18 +141,17 @@ namespace Handbrake.Controls
                 return;\r
             }\r
 \r
-            // The Source Information for the title will have changed, so set all the tracks to Automatic.\r
+            // Setup the Audio track source dropdown with the new audio tracks.\r
+            drp_audioTrack.Items.Clear();\r
+            drp_audioTrack.Items.AddRange(selectedTitle.AudioTracks.ToArray());\r
+\r
+            // Reset the Audio Track Selection to the first audio track of the source, or Audiomatic if that fails\r
             foreach (DataGridViewRow row in this.audioList.Rows)\r
             {\r
                 row.Cells[1].Value = "Automatic";\r
             }\r
 \r
-            // Setup the Audio track source dropdown with the new audio tracks.\r
-            drp_audioTrack.Items.Clear();\r
-            drp_audioTrack.Items.Add("Automatic");\r
-            drp_audioTrack.Items.AddRange(selectedTitle.AudioTracks.ToArray());\r
-\r
-            // Re-add any audio tracks that the preset has.\r
+            // Add any tracks the preset has, if there is a preset and no audio tracks in the list currently\r
             if (audioList.Rows.Count == 0 && preset != null)\r
             {\r
                 QueryParser parsed = QueryParser.Parse(preset.Query);\r
@@ -169,39 +170,66 @@ namespace Handbrake.Controls
                 }\r
             }\r
 \r
+            this.AutomaticTrackSelection();\r
+        }\r
+\r
+        private void AutomaticTrackSelection()\r
+        {\r
             // Handle Native Language and "Dub Foreign language audio" and "Use Foreign language audio and Subtitles" Options\r
             if (Properties.Settings.Default.NativeLanguage == "Any")\r
-                drp_audioTrack.SelectedIndex = drp_audioTrack.Items.Count >= 2 ? 1 : 0;\r
-            else\r
             {\r
-                if (Properties.Settings.Default.DubMode > 1) // "Dub Foreign language audio" \r
+                drp_audioTrack.SelectedIndex = 0;\r
+                foreach (DataGridViewRow item in audioList.Rows)\r
                 {\r
-                    int i = 0;\r
-                    foreach (object item in drp_audioTrack.Items)\r
+                    if (this.drp_audioTrack.SelectedItem != null)\r
                     {\r
-                        if (item.ToString().Contains(Properties.Settings.Default.NativeLanguage))\r
+                        item.Cells[1].Value = this.drp_audioTrack.SelectedItem.ToString();\r
+                    }\r
+                }\r
+            }\r
+            else\r
+            {\r
+                int mode = Properties.Settings.Default.DubMode;\r
+                switch (mode)\r
+                {\r
+                    case 1:\r
+                    case 3:\r
+                        // Dub Foreign Language Audio \r
+                        // Select the prefered language audio, or the first track if it doesn't exist.\r
+                        int i = 0;\r
+                        foreach (object item in drp_audioTrack.Items)\r
                         {\r
-                            drp_audioTrack.SelectedIndex = i;\r
-                            break;\r
+                            if (item.ToString().Contains(Properties.Settings.Default.NativeLanguage))\r
+                            {\r
+                                drp_audioTrack.SelectedIndex = i;\r
+                                break;\r
+                            }\r
+\r
+                            i++;\r
                         }\r
 \r
-                        i++;\r
-                    }\r
+                        if (drp_audioTrack.SelectedItem != null)\r
+                            foreach (DataGridViewRow item in audioList.Rows)\r
+                                item.Cells[1].Value = drp_audioTrack.SelectedItem.ToString();\r
+                        else\r
+                        {\r
+                            drp_audioTrack.SelectedIndex = 0;\r
+                            if (drp_audioTrack.SelectedItem != null)\r
+                                foreach (DataGridViewRow item in audioList.Rows)\r
+                                    item.Cells[1].Value = drp_audioTrack.SelectedItem.ToString();\r
+                        }\r
 \r
-                    if (drp_audioTrack.SelectedItem != null)\r
-                        foreach (DataGridViewRow item in audioList.Rows)\r
-                            item.Cells[1].Value = drp_audioTrack.SelectedItem.ToString();\r
-                    else\r
-                    {\r
+                        break;\r
+                    case 2:\r
+                    default:\r
+                        // Select the first track which is hopefully the default and foreign track.\r
                         drp_audioTrack.SelectedIndex = 0;\r
+\r
                         if (drp_audioTrack.SelectedItem != null)\r
                             foreach (DataGridViewRow item in audioList.Rows)\r
                                 item.Cells[1].Value = drp_audioTrack.SelectedItem.ToString();\r
-                    }\r
+                        break;\r
                 }\r
-                else\r
-                    drp_audioTrack.SelectedIndex = drp_audioTrack.Items.Count >= 3 ? 2 : 0;\r
-                // "Use Foreign language audio and Subtitles"\r
             }\r
         }\r
 \r
@@ -528,7 +556,7 @@ namespace Handbrake.Controls
 \r
             if (up) index--;\r
             else index++;\r
-    \r
+\r
             if (index < audioList.Rows.Count || (audioList.Rows.Count > index && index >= 0))\r
             {\r
                 audioList.Rows.Remove(item);\r