diff options
author | sr55 <[email protected]> | 2008-12-27 20:59:18 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2008-12-27 20:59:18 +0000 |
commit | 37212c667350e676e43c3604ebe179667c5d6751 (patch) | |
tree | 30ca075e7773dc984c20fe70b6f21a484a36b51e /win/C#/frmMain | |
parent | bc224269a460a08723f7ebd245bf9fa0cda2af73 (diff) |
WinGui:
- List based Audio Tab (Similar to the Linux GUI)
- Fix for a small bug where x264 widgets are not set for user default settings.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2045 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/frmMain')
-rw-r--r-- | win/C#/frmMain/PresetLoader.cs | 175 | ||||
-rw-r--r-- | win/C#/frmMain/QueryGenerator.cs | 271 |
2 files changed, 138 insertions, 308 deletions
diff --git a/win/C#/frmMain/PresetLoader.cs b/win/C#/frmMain/PresetLoader.cs index 67ff53087..f634909b3 100644 --- a/win/C#/frmMain/PresetLoader.cs +++ b/win/C#/frmMain/PresetLoader.cs @@ -201,151 +201,51 @@ namespace Handbrake // Audio Settings Tab
#region Audio
-
- // Handle Track 1
- mainWindow.drp_track1Audio.Text = "Automatic";
-
- // Handle Track 2
- if (presetQuery.AudioEncoder2 != null) // Fix for loading in built in presets. Where 2 encoders but no tracks in the preset.
+ // Clear the audio listing
+ mainWindow.lv_audioList.Items.Clear();
+
+ // Create a new row for the Audio list based on the currently selected items in the dropdown.
+ ListViewItem newTrack = new ListViewItem("Automatic");
+ newTrack.SubItems.Add(presetQuery.AudioEncoder1);
+ newTrack.SubItems.Add(presetQuery.AudioTrackMix1);
+ newTrack.SubItems.Add(presetQuery.AudioSamplerate1);
+ newTrack.SubItems.Add(presetQuery.AudioBitrate1);
+ newTrack.SubItems.Add(presetQuery.DRC1.ToString());
+ mainWindow.lv_audioList.Items.Add(newTrack);
+
+ if (presetQuery.AudioTrack2 != "None")
{
- mainWindow.drp_track2Audio.Enabled = true;
- mainWindow.drp_audsr_2.Enabled = true;
- mainWindow.drp_audmix_2.Enabled = true;
- mainWindow.drp_audenc_2.Enabled = true;
- mainWindow.drp_audbit_2.Enabled = true;
- mainWindow.drp_audsr_2.Text = "48";
- mainWindow.drp_track2Audio.Text = "Automatic";
- }
- else if (presetQuery.AudioTrack2 == "None")
- {
- mainWindow.drp_track2Audio.Text = "None";
- mainWindow.drp_track2Audio.SelectedIndex = 0;
- mainWindow.drp_audsr_2.Enabled = false;
- mainWindow.drp_audmix_2.Enabled = false;
- mainWindow.drp_audenc_2.Enabled = false;
- mainWindow.drp_audbit_2.Enabled = false;
- }
- else
- {
- mainWindow.drp_track2Audio.Text = presetQuery.AudioTrack2;
- mainWindow.drp_audsr_2.Enabled = true;
- mainWindow.drp_audmix_2.Enabled = true;
- mainWindow.drp_audenc_2.Enabled = true;
- mainWindow.drp_audbit_2.Enabled = true;
+ newTrack = new ListViewItem("Automatic");
+ newTrack.SubItems.Add(presetQuery.AudioEncoder2);
+ newTrack.SubItems.Add(presetQuery.AudioTrackMix2);
+ newTrack.SubItems.Add(presetQuery.AudioSamplerate2);
+ newTrack.SubItems.Add(presetQuery.AudioBitrate2);
+ newTrack.SubItems.Add(presetQuery.DRC2.ToString());
+ mainWindow.lv_audioList.Items.Add(newTrack);
}
- // Handle Track 3
- if (presetQuery.AudioTrack3 == "None")
+ if (presetQuery.AudioTrack3 != "None")
{
- mainWindow.drp_track3Audio.SelectedIndex = 0;
- mainWindow.drp_audsr_3.Enabled = false;
- mainWindow.drp_audmix_3.Enabled = false;
- mainWindow.drp_audenc_3.Enabled = false;
- mainWindow.drp_audbit_3.Enabled = false;
- mainWindow.trackBar3.Enabled = false;
-
- mainWindow.drp_track3Audio.Text = "None";
- mainWindow.drp_audsr_3.Text = "";
- mainWindow.drp_audmix_3.Text = "Automatic";
- mainWindow.drp_audenc_3.Text = "";
- mainWindow.drp_audbit_3.Text = "";
- mainWindow.trackBar3.Value = 0;
-
- }
- else
- {
- mainWindow.drp_track3Audio.Text = presetQuery.AudioTrack3;
- mainWindow.drp_audsr_3.Enabled = true;
- mainWindow.drp_audmix_3.Enabled = true;
- mainWindow.drp_audenc_3.Enabled = true;
- mainWindow.drp_audbit_3.Enabled = true;
- mainWindow.trackBar3.Enabled = true;
+ newTrack = new ListViewItem("Automatic");
+ newTrack.SubItems.Add(presetQuery.AudioEncoder3);
+ newTrack.SubItems.Add(presetQuery.AudioTrackMix3);
+ newTrack.SubItems.Add(presetQuery.AudioSamplerate3);
+ newTrack.SubItems.Add(presetQuery.AudioBitrate3);
+ newTrack.SubItems.Add(presetQuery.DRC3.ToString());
+ mainWindow.lv_audioList.Items.Add(newTrack);
}
- // Handle Track 4
- if (presetQuery.AudioTrack4 == "None")
- {
- mainWindow.drp_track4Audio.SelectedIndex = 0;
- mainWindow.drp_audsr_4.Enabled = false;
- mainWindow.drp_audmix_4.Enabled = false;
- mainWindow.drp_audenc_4.Enabled = false;
- mainWindow.drp_audbit_4.Enabled = false;
- mainWindow.trackBar4.Enabled = false;
-
- mainWindow.drp_track4Audio.Text = "None";
- mainWindow.drp_audsr_4.Text = "";
- mainWindow.drp_audmix_4.Text = "Automatic";
- mainWindow.drp_audenc_4.Text = "";
- mainWindow.drp_audbit_4.Text = "";
- mainWindow.trackBar4.Value = 0;
- }
- else
+ if (presetQuery.AudioTrack4 != "None")
{
- mainWindow.drp_track4Audio.Text = presetQuery.AudioTrack4;
- mainWindow.drp_audsr_4.Enabled = true;
- mainWindow.drp_audmix_4.Enabled = true;
- mainWindow.drp_audenc_4.Enabled = true;
- mainWindow.drp_audbit_4.Enabled = true;
- mainWindow.trackBar4.Enabled = true;
+ newTrack = new ListViewItem("Automatic");
+ newTrack.SubItems.Add(presetQuery.AudioEncoder4);
+ newTrack.SubItems.Add(presetQuery.AudioTrackMix4);
+ newTrack.SubItems.Add(presetQuery.AudioSamplerate4);
+ newTrack.SubItems.Add(presetQuery.AudioBitrate4);
+ newTrack.SubItems.Add(presetQuery.DRC4.ToString());
+ mainWindow.lv_audioList.Items.Add(newTrack);
}
- // Now lets start setting stuff
- if (presetQuery.AudioEncoder1 != null)
- mainWindow.drp_audenc_1.Text = presetQuery.AudioEncoder1;
- mainWindow.drp_audenc_2.Text = presetQuery.AudioEncoder2;
- mainWindow.drp_audenc_3.Text = presetQuery.AudioEncoder3;
- mainWindow.drp_audenc_4.Text = presetQuery.AudioEncoder4;
-
- mainWindow.drp_audmix_1.Text = presetQuery.AudioTrackMix1;
- mainWindow.drp_audmix_2.Text = presetQuery.AudioTrackMix2;
- mainWindow.drp_audmix_3.Text = presetQuery.AudioTrackMix3;
- mainWindow.drp_audmix_4.Text = presetQuery.AudioTrackMix4;
-
- if (presetQuery.AudioBitrate1 != null)
- mainWindow.drp_audbit_1.Text = presetQuery.AudioBitrate1;
- mainWindow.drp_audbit_2.Text = presetQuery.AudioBitrate2;
- mainWindow.drp_audbit_3.Text = presetQuery.AudioBitrate4;
- mainWindow.drp_audbit_3.Text = presetQuery.AudioBitrate4;
-
- if (presetQuery.AudioSamplerate1 != null)
- mainWindow.drp_audsr_1.Text = presetQuery.AudioSamplerate1;
- mainWindow.drp_audsr_2.Text = presetQuery.AudioSamplerate2;
- mainWindow.drp_audsr_3.Text = presetQuery.AudioSamplerate3;
- mainWindow.drp_audsr_4.Text = presetQuery.AudioSamplerate4;
-
- // Dynamic Range Compression (Should be a float but we use double for ease)
- double value = 0;
- double actualValue = 0;
-
- value = presetQuery.DRC1;
- if (value > 0)
- value = value - 10;
- mainWindow.trackBar1.Value = int.Parse(value.ToString());
- actualValue = presetQuery.DRC1 / 10;
- mainWindow.lbl_drc1.Text = actualValue.ToString();
-
- value = presetQuery.DRC2;
- if (value > 0)
- value = value - 10;
- mainWindow.trackBar2.Value = int.Parse(value.ToString());
- actualValue = presetQuery.DRC2 / 10;
- mainWindow.lbl_drc2.Text = actualValue.ToString();
-
- value = presetQuery.DRC3;
- if (value > 0)
- value = value - 10;
- mainWindow.trackBar3.Value = int.Parse(value.ToString());
- actualValue = presetQuery.DRC3 / 10;
- mainWindow.lbl_drc3.Text = actualValue.ToString();
-
- value = presetQuery.DRC4;
- if (value > 0)
- value = value - 10;
- mainWindow.trackBar4.Value = int.Parse(value.ToString());
- actualValue = presetQuery.DRC4 / 10;
- mainWindow.lbl_drc4.Text = actualValue.ToString();
-
-
// Subtitle Stuff
mainWindow.drp_subtitle.Text = presetQuery.Subtitles;
@@ -357,7 +257,6 @@ namespace Handbrake else
mainWindow.check_forced.CheckState = CheckState.Unchecked;
-
#endregion
// H264 Tab & Preset Name
@@ -369,4 +268,4 @@ namespace Handbrake #endregion
}
}
-}
+}
\ No newline at end of file diff --git a/win/C#/frmMain/QueryGenerator.cs b/win/C#/frmMain/QueryGenerator.cs index b79510704..c10d3b10a 100644 --- a/win/C#/frmMain/QueryGenerator.cs +++ b/win/C#/frmMain/QueryGenerator.cs @@ -4,6 +4,7 @@ using System.Text; using System.Windows.Forms;
using System.Globalization;
using System.IO;
+using System.Collections.Generic;
namespace Handbrake
{
@@ -262,200 +263,130 @@ namespace Handbrake // Audio Settings Tab
#region Audio Settings Tab
- // Track 1
- string track1 = mainWindow.drp_track1Audio.Text;
- string aencoder1 = mainWindow.drp_audenc_1.Text;
- string audioBitrate1 = mainWindow.drp_audbit_1.Text;
- string audioSampleRate1 = mainWindow.drp_audsr_1.Text;
- string Mixdown1 = mainWindow.drp_audmix_1.Text;
- string drc1 = mainWindow.trackBar1.Value.ToString();
-
- // Track 2
- string track2 = mainWindow.drp_track2Audio.Text;
- string aencoder2 = mainWindow.drp_audenc_2.Text;
- string audioBitrate2 = mainWindow.drp_audbit_2.Text;
- string audioSampleRate2 = mainWindow.drp_audsr_2.Text;
- string Mixdown2 = mainWindow.drp_audmix_2.Text;
- string drc2 = mainWindow.trackBar2.Value.ToString();
-
- // Track 3
- string track3 = mainWindow.drp_track3Audio.Text;
- string aencoder3 = mainWindow.drp_audenc_3.Text;
- string audioBitrate3 = mainWindow.drp_audbit_3.Text;
- string audioSampleRate3 = mainWindow.drp_audsr_3.Text;
- string Mixdown3 = mainWindow.drp_audmix_3.Text;
- string drc3 = mainWindow.trackBar3.Value.ToString();
-
- // Track 4
- string track4 = mainWindow.drp_track4Audio.Text;
- string aencoder4 = mainWindow.drp_audenc_4.Text;
- string audioBitrate4 = mainWindow.drp_audbit_4.Text;
- string audioSampleRate4 = mainWindow.drp_audsr_4.Text;
- string Mixdown4 = mainWindow.drp_audmix_4.Text;
- string drc4 = mainWindow.trackBar4.Value.ToString();
-
- //
- // Audio Track Selections
- //
- if (track1 == "Automatic")
- query += " -a 1";
- else if (track1 != "None")
- {
- string[] tempSub = track1.Split(' ');
- query += " -a " + tempSub[0];
- }
- if (track2 == "Automatic")
- query += ",1";
- else if (track2 != "None")
+ ListView audioTracks = mainWindow.lv_audioList;
+ List<string> tracks = new List<string>();
+ List<string> codecs = new List<string>();
+ List<string> mixdowns = new List<string>();
+ List<string> samplerates = new List<string>();
+ List<string> bitrates = new List<string>();
+ List<string> drcs = new List<string>();
+
+ // Gather information about each audio track and store them in the declared lists.
+ foreach (ListViewItem row in audioTracks.Items)
{
- string[] tempSub;
- tempSub = track2.Split(' ');
+ // Audio Track (-a)
+ String track = String.Empty;
+ if (row.Text == "Automatic")
+ tracks.Add("1");
+ else if (row.Text != "None")
+ {
+ string[] tempSub = row.Text.Split(' ');
+ tracks.Add(tempSub[0]);
+ }
- if (track1 == "None")
- query += " -a none," + tempSub[0];
- else
- query += "," + tempSub[0];
+ // Audio Codec (-E)
+ if (row.SubItems[1].Text != String.Empty)
+ codecs.Add(getAudioEncoder(row.SubItems[1].Text));
+
+ // Audio Mixdown (-6)
+ if (row.SubItems[2].Text != String.Empty)
+ mixdowns.Add(getMixDown(row.SubItems[2].Text));
+
+ // Sample Rate (-R)
+ if (row.SubItems[3].Text != String.Empty)
+ samplerates.Add(row.SubItems[3].Text.Replace("Auto", "0"));
+
+ // Audio Bitrate (-B)
+ if (row.SubItems[4].Text != String.Empty)
+ bitrates.Add(row.SubItems[4].Text.Replace("Auto", "0"));
+
+ // DRC (-D)
+ if (row.SubItems[5].Text != String.Empty)
+ drcs.Add(row.SubItems[5].Text);
}
- if (track3 != "None")
+ // Audio Track (-a)
+ String audioItems = "";
+ Boolean firstLoop = true;
+
+ foreach (String item in tracks)
{
- string[] tempSub;
- tempSub = track3.Split(' ');
- query += "," + tempSub[0];
+ if (firstLoop == true)
+ {
+ audioItems = item; firstLoop = false;
+ }
+ else
+ audioItems += "," + item;
}
+ query += " -a " + audioItems;
+ firstLoop = true; audioItems = ""; // Reset for another pass.
- if (track4 != "None")
+ // Audio Codec (-E)
+ foreach (String item in codecs)
{
- string[] tempSub;
- tempSub = track4.Split(' ');
- query += "," + tempSub[0];
+ if (firstLoop == true)
+ {
+ audioItems = item; firstLoop = false;
+ }
+ else
+ audioItems += "," + item;
}
+ query += " -E " + audioItems;
+ firstLoop = true; audioItems = ""; // Reset for another pass.
- //
- // Audio Encoder
- //
- if (aencoder1 != "")
- query += " -E " + getAudioEncoder(aencoder1);
-
- if (aencoder2 != "")
+ // Audio Mixdown (-6)
+ foreach (String item in mixdowns)
{
- if (aencoder1 == string.Empty)
- query += " -E faac," + getAudioEncoder(aencoder2);
+ if (firstLoop == true)
+ {
+ audioItems = item; firstLoop = false;
+ }
else
- query += "," + getAudioEncoder(aencoder2);
+ audioItems += "," + item;
}
+ query += " -6 " + audioItems;
+ firstLoop = true; audioItems = ""; // Reset for another pass.
- if (aencoder3 != "")
- query += "," + getAudioEncoder(aencoder3);
-
- if (aencoder4 != "")
- query += "," + getAudioEncoder(aencoder4);
-
- //
- // Audio Bitrate Selections
- //
- if (audioBitrate1 != "")
- query += " -B " + audioBitrate1;
-
- if (audioBitrate2 != "")
+ // Sample Rate (-R)
+ foreach (String item in samplerates)
{
- if (audioBitrate1 == string.Empty)
- query += " -B 160," + audioBitrate2;
+ if (firstLoop == true)
+ {
+ audioItems = item; firstLoop = false;
+ }
else
- query += "," + audioBitrate2;
+ audioItems += "," + item;
}
+ query += " -R " + audioItems;
+ firstLoop = true; audioItems = ""; // Reset for another pass.
- if (audioBitrate3 != "")
- query += "," + audioBitrate3;
-
- if (audioBitrate4 != "")
- query += "," + audioBitrate4;
-
-
- //Audio Sample Rate - audioSampleRate
- if (audioSampleRate1 != "")
- query += " -R " + audioSampleRate1.Replace("Auto", "0");
-
- if (audioSampleRate2 != "")
+ // Audio Bitrate (-B)
+ foreach (String item in bitrates)
{
- if (audioSampleRate1 == string.Empty)
- query += " -R 0," + audioSampleRate2.Replace("Auto", "0");
+ if (firstLoop == true)
+ {
+ audioItems = item; firstLoop = false;
+ }
else
- query += "," + audioSampleRate2.Replace("Auto", "0");
+ audioItems += "," + item;
}
- else
- {
- // All this is a hack, because when AppleTV is selected, there is no sample rate selected. so just add a 48
- // It should probably be setup later so the GUI widget has the value 48 in it.
+ query += " -B " + audioItems;
+ firstLoop = true; audioItems = ""; // Reset for another pass.
- if ((track2 != "") && (track2 != "None"))
+ // DRC (-D)
+ foreach (String item in drcs)
+ {
+ if (firstLoop == true)
{
- if (audioSampleRate1 == string.Empty)
- query += " -R 0,0";
- else
- query += ",0";
+ audioItems = item; firstLoop = false;
}
+ else
+ audioItems += "," + item;
}
+ query += " -D " + audioItems;
+ firstLoop = true; audioItems = ""; // Reset for another pass.
- if (audioSampleRate3 != "")
- query += "," + audioSampleRate3.Replace("Auto", "0");
-
- if (audioSampleRate4 != "")
- query += "," + audioSampleRate4.Replace("Auto", "0");
-
- //
- // Audio Mixdown Selections
- //
-
- if (Mixdown1 != "")
- query += " -6 " + getMixDown(Mixdown1);
- else
- query += " -6 dpl2";
-
- if (Mixdown2 != "" && track2 != "None")
- query += "," + getMixDown(Mixdown2);
-
- if (Mixdown3 != "" && track3 != "None" && track2 != "None")
- query += "," + getMixDown(Mixdown3);
-
- if (Mixdown4 != "" && track4 != "None" && track3 != "None")
- query += "," + getMixDown(Mixdown4);
-
-
- //
- // DRC
- //
- double value = 0;
-
- value = mainWindow.trackBar1.Value / 10.0;
- value++;
-
- if (value > 1.0)
- query += " -D " + value;
- else
- query += " -D 1";
-
- value = mainWindow.trackBar2.Value / 10.0;
- value++;
- if (track2 != "None" && drc2 != "0")
- query += "," + value;
- else if (track2 != "None" && drc2 == "0")
- query += ",1";
-
- value = mainWindow.trackBar3.Value / 10.0;
- value++;
- if (track3 != "None" && drc3 != "0")
- query += "," + value;
- else if (track3 != "None" && drc3 == "0")
- query += ",1";
-
- value = mainWindow.trackBar4.Value / 10.0;
- value++;
- if (track4 != "None" && drc4 != "0")
- query += "," + value;
- else if (track4 != "None" && drc4 == "0")
- query += ",1";
// Subtitles
string subtitles = mainWindow.drp_subtitle.Text;
@@ -536,7 +467,7 @@ namespace Handbrake switch (selectedAudio)
{
case "Automatic":
- return "dpl2";
+ return "auto";
case "Mono":
return "mono";
case "Stereo":
@@ -548,7 +479,7 @@ namespace Handbrake case "6 Channel Discrete":
return "6ch";
default:
- return "dpl2";
+ return "auto";
}
}
@@ -609,4 +540,4 @@ namespace Handbrake }
}
}
-}
+}
\ No newline at end of file |