using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; namespace Handbrake.Functions { 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_bFrameRateDistortion.CheckState = CheckState.Unchecked; mainWindow.check_BidirectionalRefinement.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.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 optValue = ""; // The option value such as "3" 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 ) { /* Make sure to only display B-RDO if allowed by both the subme and bframe option settings. */ mainWindow.check_bFrameRateDistortion.Visible = true; } if (mainWindow.drop_analysis.SelectedIndex == 1) { /* No analysis? Disable 8x8dct and direct pred */ mainWindow.check_8x8DCT.Visible = false; if (sender != "8x8dct") mainWindow.check_8x8DCT.CheckState = CheckState.Unchecked; mainWindow.drop_directPrediction.Visible = false; if (sender != "direct") mainWindow.drop_directPrediction.SelectedIndex = 0; } else { mainWindow.check_8x8DCT.Visible = true; if ( mainWindow.drop_bFrames.SelectedIndex >= 2) { /* Onlt show direct pred when allowed by both analysis and bframes */ mainWindow.drop_directPrediction.Visible = true; } } if (mainWindow.drop_refFrames.SelectedIndex < 3) { mainWindow.check_mixedReferences.Visible = false; if (sender != "mixed-refs") mainWindow.check_mixedReferences.CheckState = CheckState.Unchecked; } else { mainWindow.check_mixedReferences.Visible = true; } } } }