using System;
using System.Collections.Generic;
using System.Text;
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.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