From 7d4c044ebd62fdeac7a5665ec8fcd2548611ff51 Mon Sep 17 00:00:00 2001 From: sr55 Date: Tue, 14 Apr 2009 21:48:34 +0000 Subject: WinGui: - Move some files around. Removes frmMain folder. Removes old x264panel file which is no longer used. Fixes namespace errors. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2327 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/frmMain/PresetLoader.cs | 307 ------------- win/C#/frmMain/QueryGenerator.cs | 520 --------------------- win/C#/frmMain/x264Panel.cs | 949 --------------------------------------- 3 files changed, 1776 deletions(-) delete mode 100644 win/C#/frmMain/PresetLoader.cs delete mode 100644 win/C#/frmMain/QueryGenerator.cs delete mode 100644 win/C#/frmMain/x264Panel.cs (limited to 'win/C#/frmMain') diff --git a/win/C#/frmMain/PresetLoader.cs b/win/C#/frmMain/PresetLoader.cs deleted file mode 100644 index 7d4f6397f..000000000 --- a/win/C#/frmMain/PresetLoader.cs +++ /dev/null @@ -1,307 +0,0 @@ -using System; -using System.Windows.Forms; -using System.Drawing; - -namespace Handbrake -{ - class PresetLoader - { - /// - /// This function takes in a Query which has been parsed by QueryParser and - /// set's all the GUI widgets correctly. - /// - /// - /// The Parsed CLI Query - /// Name of the preset - /// Save picture settings in the preset - public static void presetLoader(frmMain mainWindow, Functions.QueryParser presetQuery, string name, Boolean pictureSettings) - { - // --------------------------- - // Setup the GUI - // --------------------------- - - // Source tab - #region source - // Reset some vaules to stock first to prevent errors. - mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked; - - // Now load all the new settings onto the main window - if (presetQuery.Format != null) - { - string destination = mainWindow.text_destination.Text; - destination = destination.Replace(".mp4", "." + presetQuery.Format); - destination = destination.Replace(".m4v", "." + presetQuery.Format); - destination = destination.Replace(".mkv", "." + presetQuery.Format); - mainWindow.text_destination.Text = destination; - } - - #endregion - - // Destination tab - #region destination - - mainWindow.drp_videoEncoder.Text = presetQuery.VideoEncoder; - - if (presetQuery.Format != null) - { - if (presetQuery.Format == "mp4") - mainWindow.drop_format.SelectedIndex = 0; - else if (presetQuery.Format == "m4v") - mainWindow.drop_format.SelectedIndex = 1; - else if (presetQuery.Format == "mkv") - mainWindow.drop_format.SelectedIndex = 2; - - if (presetQuery.ChapterMarkers && presetQuery.Format == "mp4") - mainWindow.drop_format.SelectedIndex = 1; - } - - mainWindow.check_iPodAtom.CheckState = presetQuery.IpodAtom ? CheckState.Checked : CheckState.Unchecked; - - mainWindow.check_optimiseMP4.CheckState = presetQuery.OptimizeMP4 ? CheckState.Checked : CheckState.Unchecked; - - #endregion - - // Picture Settings Tab - #region Picture - mainWindow.check_autoCrop.Checked = true; - if (presetQuery.CropBottom == "0" && presetQuery.CropTop == "0") - if (presetQuery.CropLeft == "0" && presetQuery.CropRight == "0") - mainWindow.check_customCrop.Checked = true; - - mainWindow.text_width.Text = ""; - mainWindow.text_height.Text = ""; - - if (pictureSettings) - { - if (presetQuery.CropTop != null) - { - int top, bottom, left, right; - int.TryParse(presetQuery.CropTop, out top); - int.TryParse(presetQuery.CropBottom, out bottom); - int.TryParse(presetQuery.CropLeft, out left); - int.TryParse(presetQuery.CropRight, out right); - - mainWindow.check_customCrop.Checked = true; - mainWindow.text_top.Value = top; - mainWindow.text_bottom.Value = bottom; - mainWindow.text_left.Value = left; - mainWindow.text_right.Value = right; - } - - if (presetQuery.Width != 0) - mainWindow.text_width.Text = presetQuery.Width.ToString(); - - if (presetQuery.Height != 0) - mainWindow.text_height.Text = presetQuery.Height.ToString(); - } - - mainWindow.drp_anamorphic.SelectedIndex = presetQuery.Anamorphic ? 1 : 0; - - if (presetQuery.LooseAnamorphic) - mainWindow.drp_anamorphic.SelectedIndex = 2; - else - { - if (presetQuery.Anamorphic != true) - mainWindow.drp_anamorphic.SelectedIndex = 0; - } - - // Set the public max width and max height varibles in frmMain - // These are used by the query generator to determine if it should use -X or -w / -Y or -h - if (presetQuery.MaxWidth != 0) - { - mainWindow.text_width.Text = presetQuery.MaxWidth.ToString(); - mainWindow.maxWidth = presetQuery.MaxWidth; - } - - if (presetQuery.MaxHeight != 0) - { - mainWindow.text_height.Text = presetQuery.MaxHeight.ToString(); - mainWindow.maxHeight = presetQuery.MaxHeight; - } - - - #endregion - - // Filters Tab - #region Filters - - mainWindow.ctl_decomb.setOption(presetQuery.Decomb); - - if (mainWindow.ctl_decomb.getDropValue == "Off") - mainWindow.ctl_deinterlace.setOption(presetQuery.DeInterlace); - else - mainWindow.ctl_deinterlace.setOption("None"); // Don't want decomb and deinterlace on at the same time - - mainWindow.ctl_denoise.setOption(presetQuery.DeNoise); - mainWindow.ctl_detelecine.setOption(presetQuery.DeTelecine); - - if (presetQuery.DeBlock != 0) - { - mainWindow.slider_deblock.Value = presetQuery.DeBlock; - mainWindow.lbl_deblockVal.Text = presetQuery.DeBlock.ToString(); - } - else - { - mainWindow.slider_deblock.Value = 4; - mainWindow.lbl_deblockVal.Text = "Off"; - } - #endregion - - // Video Settings Tab - #region video - if (presetQuery.AverageVideoBitrate != null) - { - mainWindow.radio_avgBitrate.Checked = true; - mainWindow.text_bitrate.Text = presetQuery.AverageVideoBitrate; - } - if (presetQuery.VideoTargetSize != null) - { - mainWindow.radio_targetFilesize.Checked = true; - mainWindow.text_filesize.Text = presetQuery.VideoTargetSize; - } - - // Quality - if (presetQuery.VideoQuality != 0) - { - mainWindow.radio_cq.Checked = true; - if (presetQuery.VideoEncoder == "H.264 (x264)") - { - int value; - System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US"); - - double x264step; - double presetValue = presetQuery.VideoQuality; - double.TryParse(Properties.Settings.Default.x264cqstep, - System.Globalization.NumberStyles.Number, - culture, - out x264step); - - double x = 51 / x264step; - - double calculated = presetValue / x264step; - calculated = x - calculated; - - int.TryParse(calculated.ToString(), out value); - - // This will sometimes occur when the preset was generated - // with a different granularity, so, round and try again. - if (value == 0) - { - double val = Math.Round(calculated, 0); - int.TryParse(val.ToString(), out value); - } - - mainWindow.slider_videoQuality.Value = value; - } - else - { - int presetVal; - int.TryParse(presetQuery.VideoQuality.ToString(), out presetVal); - mainWindow.slider_videoQuality.Value = presetVal; - } - } - - mainWindow.check_2PassEncode.CheckState = presetQuery.TwoPass ? CheckState.Checked : CheckState.Unchecked; - - mainWindow.check_grayscale.CheckState = presetQuery.Grayscale ? CheckState.Checked : CheckState.Unchecked; - - mainWindow.drp_videoFramerate.Text = presetQuery.VideoFramerate; - - mainWindow.check_turbo.CheckState = presetQuery.TurboFirstPass ? CheckState.Checked : CheckState.Unchecked; - - if (presetQuery.LargeMP4) - mainWindow.check_largeFile.CheckState = CheckState.Checked; - else - { - mainWindow.check_largeFile.CheckState = CheckState.Unchecked; - mainWindow.check_largeFile.BackColor = Color.Transparent; - } - #endregion - - // Chapter Markers Tab - #region Chapter Markers - - if (presetQuery.ChapterMarkers) - { - mainWindow.Check_ChapterMarkers.CheckState = CheckState.Checked; - mainWindow.Check_ChapterMarkers.Enabled = true; - } - else - mainWindow.Check_ChapterMarkers.CheckState = CheckState.Unchecked; - - #endregion - - // Audio Settings Tab - #region Audio - // 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; - if (presetQuery.AudioTrack1 != "None") - { - 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") - { - 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); - } - - if (presetQuery.AudioTrack3 != "None") - { - 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); - } - - if (presetQuery.AudioTrack4 != "None") - { - 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); - } - - // Subtitle Stuff - mainWindow.drp_subtitle.Text = presetQuery.Subtitles; - - if (presetQuery.ForcedSubtitles) - { - mainWindow.check_forced.CheckState = CheckState.Checked; - mainWindow.check_forced.Enabled = true; - } - else - mainWindow.check_forced.CheckState = CheckState.Unchecked; - - #endregion - - // H264 Tab & Preset Name - #region other - mainWindow.x264Panel.x264Query = presetQuery.H264Query; - - // Set the preset name - mainWindow.groupBox_output.Text = "Output Settings (Preset: " + name + ")"; - #endregion - } - } -} \ No newline at end of file diff --git a/win/C#/frmMain/QueryGenerator.cs b/win/C#/frmMain/QueryGenerator.cs deleted file mode 100644 index 96f2cda3d..000000000 --- a/win/C#/frmMain/QueryGenerator.cs +++ /dev/null @@ -1,520 +0,0 @@ -/* QueryGenerator.cs $ - - This file is part of the HandBrake source code. - Homepage: . - It may be used under the terms of the GNU General Public License. */ - -using System; -using System.Text; -using System.Windows.Forms; -using System.Globalization; -using System.IO; -using System.Collections.Generic; - -namespace Handbrake -{ - class QueryGenerator - { - /// - /// Generates a CLI query based on the GUI widgets. - /// - /// - /// The CLI String - public string GenerateTheQuery(frmMain mainWindow) - { - // Source tab - string query = ""; - - if ((mainWindow.text_source.Text != "") && (mainWindow.text_source.Text.Trim() != "Click 'Source' to continue")) - query = " -i " + '"' + mainWindow.text_source.Text + '"'; - - if (mainWindow.drp_dvdtitle.Text != "Automatic") - { - string[] titleInfo = mainWindow.drp_dvdtitle.Text.Split(' '); - query += " -t " + titleInfo[0]; - } - - if (mainWindow.drop_chapterFinish.Text == mainWindow.drop_chapterStart.Text && mainWindow.drop_chapterStart.Text != "Auto") - query += " -c " + mainWindow.drop_chapterStart.Text; - else if (mainWindow.drop_chapterStart.Text == "Auto" && mainWindow.drop_chapterFinish.Text != "Auto") - query += " -c " + "0-" + mainWindow.drop_chapterFinish.Text; - else if (mainWindow.drop_chapterStart.Text != "Auto" && mainWindow.drop_chapterFinish.Text != "Auto") - query += " -c " + mainWindow.drop_chapterStart.Text + "-" + mainWindow.drop_chapterFinish.Text; - - // Destination tab - if (mainWindow.text_destination.Text != "") - query += " -o " + '"' + mainWindow.text_destination.Text + '"'; - - query += generateTabbedComponentsQuery(mainWindow); - return query; - } - - /// - /// Generates a CLI query for the preview function. - /// This basically forces a shortened version of the encdode. - /// - /// - /// Duration - /// Start at preview - /// Returns a CLI query String. - public string GeneratePreviewQuery(frmMain mainWindow, string duration, string preview) - { - int seconds; - int.TryParse(duration, out seconds); - - // Source tab - string query = ""; - - if ((mainWindow.text_source.Text != "") && (mainWindow.text_source.Text.Trim() != "Click 'Source' to continue")) - query = " -i " + '"' + mainWindow.text_source.Text + '"'; - - if (mainWindow.drp_dvdtitle.Text != "Automatic") - { - string[] titleInfo = mainWindow.drp_dvdtitle.Text.Split(' '); - query += " -t " + titleInfo[0]; - } - - query += " --start-at-preview " + preview; - query += " --stop-at duration:" + duration + " "; - - // Destination tab - if (mainWindow.text_destination.Text != "") - query += " -o " + '"' + mainWindow.text_destination.Text.Replace(".m", "_sample.m") + '"'; - - query += generateTabbedComponentsQuery(mainWindow); - return query; - } - - /// - /// Generates part of the CLI query, for the tabbed components only. - /// - /// - /// - public string generateTabbedComponentsQuery(frmMain mainWindow) - { - string query = ""; - - #region Output Settings Box - query += " -f " + mainWindow.drop_format.Text.ToLower().Replace(" file", ""); - - // These are output settings features - if (mainWindow.check_largeFile.Checked) - query += " -4 "; - - if (mainWindow.check_iPodAtom.Checked) - query += " -I "; - - if (mainWindow.check_optimiseMP4.Checked) - query += " -O "; - #endregion - - #region Picture Settings Tab - - // Use MaxWidth for built-in presets and width for user settings. - if (mainWindow.maxWidth == 0) - { - - if (mainWindow.text_width.Text != "") - query += " -w " + mainWindow.text_width.Text; - } - else - { - if (mainWindow.text_width.Text != "") - query += " -X " + mainWindow.text_width.Text; - } - - // Use MaxHeight for built-in presets and height for user settings. - if (mainWindow.maxHeight == 0) - { - if (mainWindow.text_height.Text != "") - query += " -l " + mainWindow.text_height.Text; - } - else - { - if (mainWindow.text_height.Text != "") - query += " -Y " + mainWindow.text_height.Text; - } - - string cropTop = mainWindow.text_top.Text; - string cropBottom = mainWindow.text_bottom.Text; - string cropLeft = mainWindow.text_left.Text; - string cropRight = mainWindow.text_right.Text; - - if (mainWindow.check_customCrop.Checked) - { - if (mainWindow.text_top.Text == string.Empty) - cropTop = "0"; - if (mainWindow.text_bottom.Text == string.Empty) - cropBottom = "0"; - if (mainWindow.text_left.Text == string.Empty) - cropLeft = "0"; - if (mainWindow.text_right.Text == string.Empty) - cropRight = "0"; - - query += " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight; - } - - if (mainWindow.drp_anamorphic.SelectedIndex == 1) - query += " -p "; - else if (mainWindow.drp_anamorphic.SelectedIndex == 2) - query += " -P "; - - if (mainWindow.slider_deblock.Value != 4) - query += " --deblock=" + mainWindow.slider_deblock.Value; - - - #endregion - - #region Filters - query += mainWindow.ctl_detelecine.getCLIQuery; - query += mainWindow.ctl_decomb.getCLIQuery; - query += mainWindow.ctl_deinterlace.getCLIQuery; - query += mainWindow.ctl_denoise.getCLIQuery; - #endregion - - #region Video Settings Tab - - switch (mainWindow.drp_videoEncoder.Text) - { - case "MPEG-4 (FFmpeg)": - query += " -e ffmpeg"; - break; - case "H.264 (x264)": - query += " -e x264"; - break; - case "VP3 (Theora)": - query += " -e theora"; - break; - default: - query += " -e x264"; - break; - } - - if (mainWindow.check_grayscale.Checked) - query += " -g "; - - // Video Settings - if (mainWindow.radio_avgBitrate.Checked) - query += " -b " + mainWindow.text_bitrate.Text; - - if (mainWindow.radio_targetFilesize.Checked) - query += " -S " + mainWindow.text_filesize.Text; - - // Video Quality Setting - if (mainWindow.radio_cq.Checked) - { - double value; - switch (mainWindow.drp_videoEncoder.Text) - { - case "MPEG-4 (FFmpeg)": - value = 31 - (mainWindow.slider_videoQuality.Value -1); - query += " -q " + value.ToString(new CultureInfo("en-US")); - break; - case "H.264 (x264)": - double divided; - CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US"); - double.TryParse(Properties.Settings.Default.x264cqstep, - NumberStyles.Number, - culture, - out divided); - value = 51 - mainWindow.slider_videoQuality.Value * divided; - value = Math.Round(value, 2); - query += " -q " + value.ToString(new CultureInfo("en-US")); - break; - case "VP3 (Theora)": - value = mainWindow.slider_videoQuality.Value; - query += " -q " + value.ToString(new CultureInfo("en-US")); - break; - } - } - - if (mainWindow.check_2PassEncode.Checked) - query += " -2 "; - - if (mainWindow.check_turbo.Checked) - query += " -T "; - - if (mainWindow.drp_videoFramerate.Text != "Same as source") - query += " -r " + mainWindow.drp_videoFramerate.Text; - #endregion - - #region Audio Settings Tab - - ListView audioTracks = mainWindow.lv_audioList; - List tracks = new List(); - List codecs = new List(); - List mixdowns = new List(); - List samplerates = new List(); - List bitrates = new List(); - List drcs = new List(); - - // No Audio - if (audioTracks.Items.Count == 0) - query += " -a none "; - - // Gather information about each audio track and store them in the declared lists. - foreach (ListViewItem row in audioTracks.Items) - { - // Audio Track (-a) - if (row.Text == "Automatic") - tracks.Add("1"); - else if (row.Text != "None") - { - string[] tempSub = row.Text.Split(' '); - tracks.Add(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); - } - - // Audio Track (-a) - String audioItems = ""; - Boolean firstLoop = true; - - foreach (String item in tracks) - { - if (firstLoop) - { - audioItems = item; firstLoop = false; - } - else - audioItems += "," + item; - } - if (audioItems.Trim() != String.Empty) - query += " -a " + audioItems; - firstLoop = true; audioItems = ""; // Reset for another pass. - - // Audio Codec (-E) - foreach (String item in codecs) - { - if (firstLoop) - { - audioItems = item; firstLoop = false; - } - else - audioItems += "," + item; - } - if (audioItems.Trim() != String.Empty) - query += " -E " + audioItems; - firstLoop = true; audioItems = ""; // Reset for another pass. - - // Audio Mixdown (-6) - foreach (String item in mixdowns) - { - if (firstLoop) - { - audioItems = item; firstLoop = false; - } - else - audioItems += "," + item; - } - if (audioItems.Trim() != String.Empty) - query += " -6 " + audioItems; - firstLoop = true; audioItems = ""; // Reset for another pass. - - // Sample Rate (-R) - foreach (String item in samplerates) - { - if (firstLoop) - { - audioItems = item; firstLoop = false; - } - else - audioItems += "," + item; - } - if (audioItems.Trim() != String.Empty) - query += " -R " + audioItems; - firstLoop = true; audioItems = ""; // Reset for another pass. - - // Audio Bitrate (-B) - foreach (String item in bitrates) - { - if (firstLoop) - { - audioItems = item; firstLoop = false; - } - else - audioItems += "," + item; - } - if (audioItems.Trim() != String.Empty) - query += " -B " + audioItems; - firstLoop = true; audioItems = ""; // Reset for another pass. - - // DRC (-D) - foreach (String item in drcs) - { - if (firstLoop) - { - audioItems = item; firstLoop = false; - } - else - audioItems += "," + item; - } - if (audioItems.Trim() != String.Empty) - query += " -D " + audioItems; - - // Subtitles - string subtitles = mainWindow.drp_subtitle.Text; - if (subtitles == "Autoselect") - query += " -U "; - else if (subtitles != "" && subtitles != "None") - { - string[] tempSub = subtitles.Split(' '); - query += " -s " + tempSub[0]; - } - - if (mainWindow.check_forced.Checked) - query += " -F "; - - #endregion - - #region Chapter Markers - - // Attach Source name and dvd title to the start of the chapters.csv filename. - // This is for the queue. It allows different chapter name files for each title. - string[] destName = mainWindow.text_destination.Text.Split('\\'); - string dest_name = destName[destName.Length - 1]; - dest_name = dest_name.Replace("\"", ""); - dest_name = dest_name.Replace(".mp4", "").Replace(".m4v", "").Replace(".mkv", ""); - - string source_title = mainWindow.drp_dvdtitle.Text; - string[] titlesplit = source_title.Split(' '); - source_title = titlesplit[0]; - - if (mainWindow.Check_ChapterMarkers.Checked) - { - if (dest_name.Trim() != String.Empty) - { - string path = source_title != "Automatic" - ? Path.Combine(Path.GetTempPath(), dest_name + "-" + source_title + "-chapters.csv") - : Path.Combine(Path.GetTempPath(), dest_name + "-chapters.csv"); - - if (chapterCSVSave(mainWindow, path) == false) - query += " -m "; - else - query += " --markers=" + "\"" + path + "\""; - } - else - query += " -m"; - } - #endregion - - #region H264 Tab - if (mainWindow.x264Panel.x264Query != "") - query += " -x " + mainWindow.x264Panel.x264Query; - #endregion - - #region Processors / Other - string processors = Properties.Settings.Default.Processors; - if (processors != "Automatic") - query += " -C " + processors + " "; - - query += " -v " + Properties.Settings.Default.verboseLevel; - #endregion - - return query; - } - - /// - /// Get the CLI equive of the audio mixdown from the widget name. - /// - /// - /// - /// - private static string getMixDown(string selectedAudio) - { - switch (selectedAudio) - { - case "Automatic": - return "auto"; - case "Mono": - return "mono"; - case "Stereo": - return "stereo"; - case "Dolby Surround": - return "dpl1"; - case "Dolby Pro Logic II": - return "dpl2"; - case "6 Channel Discrete": - return "6ch"; - default: - return "auto"; - } - } - - /// - /// Get the CLI equiv of the audio encoder from the widget name. - /// - /// - /// - /// - private static string getAudioEncoder(string selectedEncoder) - { - switch (selectedEncoder) - { - case "AAC": - return "faac"; - case "MP3": - return "lame"; - case "Vorbis": - return "vorbis"; - case "AC3": - return "ac3"; - default: - return ""; - } - } - - /// - /// This function saves the data in the chapters tab, dataGridView into a CSV file called chapters.csv - /// in a directory specified by file_path_name - /// - /// - /// - /// - private static Boolean chapterCSVSave(frmMain mainWindow, string file_path_name) - { - try - { - StringBuilder csv = new StringBuilder(); - - foreach (DataGridViewRow row in mainWindow.data_chpt.Rows) - { - csv.Append(row.Cells[0].Value.ToString()); - csv.Append(","); - csv.Append(row.Cells[1].Value.ToString()); - csv.Append(Environment.NewLine); - } - StreamWriter file = new StreamWriter(file_path_name); - file.Write(csv.ToString()); - file.Close(); - file.Dispose(); - return true; - - } - catch (Exception exc) - { - MessageBox.Show("Unable to save Chapter Makrers file! \nChapter marker names will NOT be saved in your encode \n\n" + exc, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); - return false; - } - } - } -} \ No newline at end of file diff --git a/win/C#/frmMain/x264Panel.cs b/win/C#/frmMain/x264Panel.cs deleted file mode 100644 index be4704183..000000000 --- a/win/C#/frmMain/x264Panel.cs +++ /dev/null @@ -1,949 +0,0 @@ -using System; -using System.Windows.Forms; - -namespace Handbrake -{ - class x264Panel - { - /// - /// Reset all components to defaults and clears the x264 rtf box - /// - public void reset2Defaults(frmMain mainWindow) - { - mainWindow.check_8x8DCT.CheckState = CheckState.Unchecked; - mainWindow.check_Cabac.CheckState = CheckState.Checked; - mainWindow.check_mixedReferences.CheckState = CheckState.Unchecked; - mainWindow.check_noDCTDecimate.CheckState = CheckState.Unchecked; - mainWindow.check_noFastPSkip.CheckState = CheckState.Unchecked; - mainWindow.check_pyrmidalBFrames.CheckState = CheckState.Unchecked; - mainWindow.check_weightedBFrames.CheckState = CheckState.Unchecked; - mainWindow.drop_analysis.SelectedIndex = 0; - mainWindow.drop_bFrames.SelectedIndex = 0; - mainWindow.drop_deblockAlpha.SelectedIndex = 0; - mainWindow.drop_deblockBeta.SelectedIndex = 0; - mainWindow.drop_directPrediction.SelectedIndex = 0; - mainWindow.drop_MotionEstimationMethod.SelectedIndex = 0; - mainWindow.drop_MotionEstimationRange.SelectedIndex = 0; - mainWindow.drop_refFrames.SelectedIndex = 0; - mainWindow.drop_subpixelMotionEstimation.SelectedIndex = 0; - mainWindow.drop_trellis.SelectedIndex = 0; - mainWindow.slider_psyrd.Value = 0; - mainWindow.slider_psytrellis.Value = 0; - mainWindow.drop_adaptBFrames.SelectedIndex = 0; - - mainWindow.rtf_x264Query.Text = ""; - } - - /// - /// Update GUI componets from the current x264 rtf string - /// - public void X264_SetCurrentSettingsInPanel(frmMain mainWindow) - { - /* Set widgets depending on the opt string in field */ - String thisOpt; // The separated option such as "bframes=3" - String optName; // The option name such as "bframes" - String optValue;// The option value such as "3" - String[] currentOptsArray; - - //Set currentOptString to the contents of the text box. - String currentOptString = mainWindow.rtf_x264Query.Text.Replace("\n", ""); - - /*verify there is an opt string to process */ - if (currentOptString.Contains("=")) - { - /*Put individual options into an array based on the ":" separator for processing, result is "="*/ - currentOptsArray = currentOptString.Split(':'); - - /*iterate through the array and get and and - /// Iterate over every x264 option, standardize it, write the full string to the x264 rtf box - /// - public void X264_StandardizeOptString(frmMain mainWindow) - { - /* Set widgets depending on the opt string in field */ - String thisOpt; // The separated option such as "bframes=3" - String optName; // The option name such as "bframes" - String optValue;// The option value such as "3" - String changedOptString = ""; - String[] currentOptsArray; - - /*First, we get an opt string to process */ - String currentOptString = mainWindow.rtf_x264Query.Text; - - /*verify there is an opt string to process */ - if (currentOptString.Contains("=")) - { - /*Put individual options into an array based on the ":" separator for processing, result is "="*/ - currentOptsArray = currentOptString.Split(':'); - - /*iterate through the array and get and - /// This function will update the X264 Query when one of the GUI widgets changes. - /// - public void on_x264_WidgetChange(string sender, frmMain mainWindow) - { - animate(mainWindow, sender); - String optNameToChange = sender; - String currentOptString = mainWindow.rtf_x264Query.Text; - - /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after - the first character of the opt string (hence the ":") */ - String checkOptNameToChange = ":" + optNameToChange + "="; - String checkOptNameToChangeBegin = optNameToChange + "="; - - // IF the current H264 Option String Contains Multiple Items or Just 1 Item - if ((currentOptString.Contains(checkOptNameToChange)) || (currentOptString.StartsWith(checkOptNameToChangeBegin))) - hasOptions(currentOptString, optNameToChange, mainWindow); - else // IF there is no options in the rich text box! - hasNoOptions(optNameToChange, mainWindow); - } - /* - * Used by on_x264_WidgetChange() - ** hasOptions - Called when the current x264 option string contains multiple (or a single) item(s) in it seperated by : - * it updates the current option that the widget corrosponds to, if it is already in thes string. - ** hasNoOptions - Add's an option to the x264 query string. - * Handles 2 cases. 1 Where rtf_x264Query.Text is empty, and one where there is an option with no value, - * e.g no-fast-pskip - */ - private void hasOptions(string currentOptString, string optNameToChange, frmMain mainWindow) - { - String thisOpt; // The separated option such as "bframes=3" - String optName; // The option name such as "bframes" - String[] currentOptsArray; - - /* Create new empty opt string*/ - String changedOptString = ""; - - /*Put individual options into an array based on the ":" separator for processing, result is "="*/ - currentOptsArray = currentOptString.Split(':'); - - /*iterate through the array and get and = 2 && mainWindow.check_Cabac.Checked && mainWindow.slider_psytrellis.Visible == false) - { - mainWindow.slider_psytrellis.Visible = true; - mainWindow.lbl_psytrellis.Visible = true; - } - } - - if (mainWindow.drop_trellis.SelectedIndex < 2) - { - mainWindow.slider_psytrellis.Visible = false; - mainWindow.slider_psytrellis.Value = 0; - mainWindow.lbl_psytrellis.Visible = false; - } - else - { - if ((mainWindow.drop_subpixelMotionEstimation.SelectedIndex == 0 || mainWindow.drop_subpixelMotionEstimation.SelectedIndex >= 7) && mainWindow.check_Cabac.Checked && mainWindow.slider_psytrellis.Visible == false) - { - mainWindow.slider_psytrellis.Visible = true; - mainWindow.lbl_psytrellis.Visible = true; - } - } - - } - - } -} \ No newline at end of file -- cgit v1.2.3