\r
namespace Handbrake.EncodeQueue\r
{\r
+ /// <summary>\r
+ /// Class which handles the CLI\r
+ /// </summary>\r
public class Encode\r
{\r
+ /// <summary>\r
+ /// Process ID\r
+ /// </summary>\r
private int ProcessID { get; set; }\r
\r
/// <summary>\r
}\r
}\r
\r
+ /// <summary>\r
+ /// Function to run the CLI directly rather than via CMD\r
+ /// TODO: Code to handle the Log data has yet to be written.\r
+ /// TODO: Code to handle the % / ETA info has to be written.\r
+ /// </summary>\r
+ protected void DirectRun(string query)\r
+ {\r
+ try\r
+ {\r
+ if (EncodeStarted != null)\r
+ EncodeStarted(this, new EventArgs());\r
+\r
+ IsEncoding = true;\r
+\r
+ // Setup the job\r
+ string handbrakeCLIPath = Path.Combine(Environment.CurrentDirectory, "HandBrakeCLI.exe");\r
+ Process hbProc = new Process\r
+ {\r
+ StartInfo =\r
+ {\r
+ FileName = handbrakeCLIPath,\r
+ Arguments = query,\r
+ UseShellExecute = false,\r
+ RedirectStandardOutput = true,\r
+ RedirectStandardError = true,\r
+ RedirectStandardInput = true,\r
+ CreateNoWindow = false,\r
+ WindowStyle = ProcessWindowStyle.Minimized\r
+ }\r
+ };\r
+\r
+ // Setup the redirects\r
+ hbProc.ErrorDataReceived += new DataReceivedEventHandler(HbProcErrorDataReceived);\r
+ hbProc.OutputDataReceived += new DataReceivedEventHandler(HbProcOutputDataReceived);\r
+\r
+ // Start the process\r
+ hbProc.Start();\r
+\r
+ // Set the Process Priority\r
+ switch (Properties.Settings.Default.processPriority)\r
+ {\r
+ case "Realtime":\r
+ hbProc.PriorityClass = ProcessPriorityClass.RealTime;\r
+ break;\r
+ case "High":\r
+ hbProc.PriorityClass = ProcessPriorityClass.High;\r
+ break;\r
+ case "Above Normal":\r
+ hbProc.PriorityClass = ProcessPriorityClass.AboveNormal;\r
+ break;\r
+ case "Normal":\r
+ hbProc.PriorityClass = ProcessPriorityClass.Normal;\r
+ break;\r
+ case "Low":\r
+ hbProc.PriorityClass = ProcessPriorityClass.Idle;\r
+ break;\r
+ default:\r
+ hbProc.PriorityClass = ProcessPriorityClass.BelowNormal;\r
+ break;\r
+ }\r
+\r
+ // Set the class items\r
+ HbProcess = hbProc;\r
+ ProcessID = hbProc.Id;\r
+ ProcessHandle = hbProc.Handle;\r
+\r
+ }\r
+ catch (Exception exc)\r
+ {\r
+ Console.WriteLine(exc);\r
+ }\r
+ }\r
+\r
/// <summary>\r
/// Kill the CLI process\r
/// </summary>\r
EncodeEnded(this, new EventArgs());\r
}\r
\r
+ /// <summary>\r
+ /// Attempt to Safely kill a DirectRun() CLI\r
+ /// NOTE: This will not work with a MinGW CLI\r
+ /// Note: http://www.cygwin.com/ml/cygwin/2006-03/msg00330.html\r
+ /// </summary>\r
+ public void SafelyClose()\r
+ {\r
+ if ((int)ProcessHandle == 0)\r
+ return;\r
+\r
+ // Allow the CLI to exit cleanly\r
+ Win32.SetForegroundWindow((int)ProcessHandle);\r
+ SendKeys.Send("^C");\r
+\r
+ // HbProcess.StandardInput.AutoFlush = true;\r
+ // HbProcess.StandardInput.WriteLine("^C");\r
+ }\r
+\r
+ /// <summary>\r
+ /// Recieve the Standard Error information and process it\r
+ /// </summary>\r
+ /// <param name="sender"></param>\r
+ /// <param name="e"></param>\r
+ private static void HbProcErrorDataReceived(object sender, DataReceivedEventArgs e)\r
+ {\r
+ // TODO: Recieve the Log data and process it\r
+ throw new NotImplementedException();\r
+ }\r
+\r
+ /// <summary>\r
+ /// Standard Input Data Recieved from the CLI\r
+ /// </summary>\r
+ /// <param name="sender"></param>\r
+ /// <param name="e"></param>\r
+ private static void HbProcOutputDataReceived(object sender, DataReceivedEventArgs e)\r
+ {\r
+ // TODO: Recieve the %, ETA, FPS etc and process it\r
+ throw new NotImplementedException();\r
+ }\r
+\r
/// <summary>\r
/// Perform an action after an encode. e.g a shutdown, standby, restart etc.\r
/// </summary>\r
protected void Finish()\r
{\r
+ if (EncodeEnded != null)\r
+ EncodeEnded(this, new EventArgs());\r
+\r
IsEncoding = false;\r
\r
//Growl\r
private readonly List<Job> queue = new List<Job>();\r
private int NextJobId;\r
\r
- #region Event Handlers\r
- /// <summary>\r
- /// Fires when an encode job has been started.\r
- /// </summary>\r
- public event EventHandler NewJobStarted;\r
-\r
/// <summary>\r
/// Fires when a pause to the encode queue has been requested.\r
/// </summary>\r
public event EventHandler QueuePauseRequested;\r
\r
- /// <summary>\r
- /// Fires when an encode job has been completed.\r
- /// </summary>\r
- public event EventHandler CurrentJobCompleted;\r
-\r
/// <summary>\r
/// Fires when the entire encode queue has completed.\r
/// </summary>\r
public event EventHandler QueueCompleted;\r
- #endregion\r
\r
#region Queue\r
/// <summary>\r
\r
Run(query);\r
\r
- if (NewJobStarted != null)\r
- NewJobStarted(this, new EventArgs());\r
-\r
HbProcess.WaitForExit();\r
\r
AddCLIQueryToLog(encJob);\r
if (Properties.Settings.Default.growlEncode)\r
GrowlCommunicator.Notify("Encode Completed", "Put down that cocktail...\nyour Handbrake encode is done.");\r
\r
- if (CurrentJobCompleted != null)\r
- CurrentJobCompleted(this, new EventArgs());\r
-\r
while (PauseRequested) // Need to find a better way of doing this.\r
{\r
Thread.Sleep(2000);\r
/// Function which generates the filename and path automatically based on \r
/// the Source Name, DVD title and DVD Chapters\r
/// </summary>\r
- public static string AutoName(frmMain mainWindow) //ComboBox drpDvdtitle, string chapter_start, string chatper_end, string source, string dest, int format, Boolean chapters)\r
+ public static string AutoName(frmMain mainWindow)\r
{\r
string AutoNamePath = string.Empty;\r
if (mainWindow.drp_dvdtitle.Text != "Automatic")\r
using System;\r
using System.Drawing;\r
using System.Windows.Forms;\r
+using Handbrake.Model;\r
\r
namespace Handbrake.Functions\r
{\r
/// <param name="presetQuery">The Parsed CLI Query</param>\r
/// <param name="name">Name of the preset</param>\r
/// <param name="pictureSettings">Save picture settings in the preset</param>\r
- public static void presetLoader(frmMain mainWindow, QueryParser presetQuery, string name, Boolean pictureSettings)\r
+ public static void LoadPreset(frmMain mainWindow, QueryParser presetQuery, string name, Boolean pictureSettings)\r
{\r
- // ---------------------------\r
- // Setup the GUI\r
- // ---------------------------\r
-\r
#region Source\r
// Reset some vaules to stock first to prevent errors.\r
mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked;\r
/// <summary>\r
/// Generates a full CLI query for either encoding or previe encoeds if duration and preview are defined.\r
/// </summary>\r
- /// <param name="mainWindow"></param>\r
- /// <param name="mode"></param>\r
- /// <param name="duration"></param>\r
- /// <param name="preview"></param>\r
- /// <returns></returns>\r
- public string GenerateCLIQuery(frmMain mainWindow, int mode, int duration, string preview)\r
+ /// <param name="mainWindow">The Main Window</param>\r
+ /// <param name="mode">What Mode. (Point to Point Encoding) Chapters, Seconds, Frames OR Preview Encode</param>\r
+ /// <param name="duration">time in seconds for preview mode</param>\r
+ /// <param name="preview"> --start-at-preview (int) </param>\r
+ /// <returns>CLI Query </returns>\r
+ public static string GenerateCLIQuery(frmMain mainWindow, int mode, int duration, string preview)\r
{\r
string query = "";\r
\r
return query;\r
}\r
\r
+ /// <summary>\r
+ /// Return the CLI Mixdown name\r
+ /// </summary>\r
+ /// <param name="selectedAudio">GUI mixdown name</param>\r
+ /// <returns>CLI mixdown name</returns>\r
private static string GetMixDown(string selectedAudio)\r
{\r
switch (selectedAudio)\r
return "auto";\r
}\r
}\r
+\r
+ /// <summary>\r
+ /// Get the CLI Audio Encoder name\r
+ /// </summary>\r
+ /// <param name="selectedEncoder">string The GUI Encode name</param>\r
+ /// <returns>string CLI encoder name</returns>\r
private static string GetAudioEncoder(string selectedEncoder)\r
{\r
switch (selectedEncoder)\r
return "";\r
}\r
}\r
+\r
+ /// <summary>\r
+ /// Create a CSV file with the data from the Main Window Chapters tab\r
+ /// </summary>\r
+ /// <param name="mainWindow">Main Window</param>\r
+ /// <param name="filePathName">Path to save the csv file</param>\r
+ /// <returns>True if successful </returns>\r
private static Boolean ChapterCSVSave(frmMain mainWindow, string filePathName)\r
{\r
try\r
using System.Text.RegularExpressions;\r
using System.Windows.Forms;\r
using System.Collections;\r
+using Handbrake.Model;\r
\r
namespace Handbrake.Functions\r
{\r
- internal class QueryParser\r
+ public class QueryParser\r
{\r
private static readonly CultureInfo Culture = new CultureInfo("en-US", false);\r
\r
trackDRCvalues = drcValues.ToString().Replace("-D ", "").Split(',');\r
\r
// Create new Audio Track Classes and store them in the ArrayList\r
- ArrayList AllAudioTrackInfo = new ArrayList();\r
+ ArrayList allAudioTrackInfo = new ArrayList();\r
for (int x = 0; x < encoderCount; x++)\r
{\r
AudioTrack track = new AudioTrack();\r
if (trackDRCvalues.Length >= (x + 1)) // Audio DRC Values\r
track.DRC = trackDRCvalues[x].Trim();\r
\r
- AllAudioTrackInfo.Add(track);\r
+ allAudioTrackInfo.Add(track);\r
}\r
- thisQuery.AudioInformation = AllAudioTrackInfo;\r
+ thisQuery.AudioInformation = allAudioTrackInfo;\r
\r
// Subtitle Stuff\r
if (subtitles.Success)\r
\r
return thisQuery;\r
}\r
+\r
+ /// <summary>\r
+ /// Get the GUI equiv to a CLI mixdown\r
+ /// </summary>\r
+ /// <param name="mixdown"></param>\r
+ /// <returns></returns>\r
private static string GetMixDown(string mixdown)\r
{\r
switch (mixdown.Trim())\r
return "Automatic";\r
}\r
}\r
+\r
+ /// <summary>\r
+ /// Get the GUI equiv to a CLI audio encoder\r
+ /// </summary>\r
+ /// <param name="audioEnc"></param>\r
+ /// <returns></returns>\r
private static string GetAudioEncoder(string audioEnc)\r
{\r
switch (audioEnc)\r
}\r
}\r
}\r
-\r
- public class AudioTrack\r
- {\r
- public AudioTrack()\r
- {\r
- // Default Values\r
- Track = "Automatic";\r
- MixDown = "Automatic";\r
- SampleRate = "Auto";\r
- Bitrate = "Auto";\r
- DRC = "1";\r
- }\r
- public string Track { get; set; }\r
- public string MixDown { get; set; }\r
- public string Encoder { get; set; }\r
- public string Bitrate { get; set; }\r
- public string SampleRate { get; set; }\r
- public string DRC { get; set; }\r
- }\r
}
\ No newline at end of file
{\r
public class Scan\r
{\r
- private DVD _thisDvd;\r
- private Parser _readData;\r
- private Process _hbProc;\r
- private string _scanProgress;\r
+ private DVD ThisDvd;\r
+ private Parser ReadData;\r
+ private Process HbProc;\r
+ private string ScanProgress;\r
+\r
+ /// <summary>\r
+ /// Scan has Started\r
+ /// </summary>\r
public event EventHandler ScanStared;\r
+\r
+ /// <summary>\r
+ /// Scan has completed\r
+ /// </summary>\r
public event EventHandler ScanCompleted;\r
+\r
+ /// <summary>\r
+ /// Scan process has changed to a new title\r
+ /// </summary>\r
public event EventHandler ScanStatusChanged;\r
\r
+ /// <summary>\r
+ /// Scan a Source Path.\r
+ /// Title 0: scan all\r
+ /// </summary>\r
+ /// <param name="sourcePath">Path to the file to scan</param>\r
+ /// <param name="title">int title number. 0 for scan all</param>\r
public void ScanSource(string sourcePath, int title)\r
{\r
Thread t = new Thread(unused => RunScan(sourcePath, title));\r
t.Start();\r
}\r
\r
+ /// <summary>\r
+ /// Object containing the information parsed in the scan.\r
+ /// </summary>\r
+ /// <returns></returns>\r
public DVD SouceData()\r
{\r
- return _thisDvd;\r
+ return ThisDvd;\r
}\r
\r
+ /// <summary>\r
+ /// Raw log output from HandBrake CLI\r
+ /// </summary>\r
+ /// <returns></returns>\r
public String LogData()\r
{\r
- return _readData.Buffer;\r
+ return ReadData.Buffer;\r
}\r
\r
+ /// <summary>\r
+ /// Progress of the scan.\r
+ /// </summary>\r
+ /// <returns></returns>\r
public String ScanStatus()\r
{\r
- return _scanProgress;\r
+ return ScanProgress;\r
}\r
\r
+ /// <summary>\r
+ /// The Scan Process\r
+ /// </summary>\r
+ /// <returns></returns>\r
public Process ScanProcess()\r
{\r
- return _hbProc;\r
+ return HbProc;\r
}\r
\r
+ /// <summary>\r
+ /// Start a scan for a given source path and title\r
+ /// </summary>\r
+ /// <param name="sourcePath"></param>\r
+ /// <param name="title"></param>\r
private void RunScan(object sourcePath, int title)\r
{\r
try\r
if (Properties.Settings.Default.noDvdNav)\r
dvdnav = " --no-dvdnav";\r
\r
- _hbProc = new Process\r
+ HbProc = new Process\r
{\r
StartInfo =\r
{\r
CreateNoWindow = true\r
}\r
};\r
- _hbProc.Start();\r
+ HbProc.Start();\r
\r
- _readData = new Parser(_hbProc.StandardError.BaseStream);\r
- _readData.OnScanProgress += new ScanProgressEventHandler(OnScanProgress);\r
- _thisDvd = DVD.Parse(_readData);\r
+ ReadData = new Parser(HbProc.StandardError.BaseStream);\r
+ ReadData.OnScanProgress += new ScanProgressEventHandler(OnScanProgress);\r
+ ThisDvd = DVD.Parse(ReadData);\r
\r
// Write the Buffer out to file.\r
StreamWriter scanLog = new StreamWriter(dvdInfoPath);\r
- scanLog.Write(_readData.Buffer);\r
+ scanLog.Write(ReadData.Buffer);\r
scanLog.Flush();\r
scanLog.Close();\r
\r
}\r
}\r
\r
+ /// <summary>\r
+ /// Fire an event when the scan process progresses\r
+ /// </summary>\r
+ /// <param name="sender"></param>\r
+ /// <param name="currentTitle"></param>\r
+ /// <param name="titleCount"></param>\r
private void OnScanProgress(object sender, int currentTitle, int titleCount)\r
{\r
- _scanProgress = string.Format("Processing Title: {0} of {1}", currentTitle, titleCount);\r
+ ScanProgress = string.Format("Processing Title: {0} of {1}", currentTitle, titleCount);\r
if (ScanStatusChanged != null)\r
ScanStatusChanged(this, new EventArgs());\r
}\r
<Compile Include="frmActivityWindow.Designer.cs">\r
<DependentUpon>frmActivityWindow.cs</DependentUpon>\r
</Compile>\r
+ <Compile Include="Model\AudioTrack.cs" />\r
<Compile Include="Presets\Export.cs" />\r
- <Compile Include="Presets\Import.cs" />\r
+ <Compile Include="Presets\PlistPresetHandler.cs" />\r
<Compile Include="Presets\preset.cs" />\r
<Compile Include="Presets\PresetsHandler.cs" />\r
<Compile Include="EncodeQueue\Queue.cs" />\r
--- /dev/null
+/* AudioTrack.cs $\r
+ \r
+ This file is part of the HandBrake source code.\r
+ Homepage: <http://handbrake.fr>.\r
+ It may be used under the terms of the GNU General Public License. */\r
+\r
+namespace Handbrake.Model\r
+{\r
+ /// <summary>\r
+ /// An Audio Track for the Audio Panel\r
+ /// </summary>\r
+ public class AudioTrack\r
+ {\r
+ /// <summary>\r
+ /// Audio Track instance\r
+ /// </summary>\r
+ public AudioTrack()\r
+ {\r
+ // Default Values\r
+ Track = "Automatic";\r
+ MixDown = "Automatic";\r
+ SampleRate = "Auto";\r
+ Bitrate = "Auto";\r
+ DRC = "1";\r
+ }\r
+\r
+ /// <summary>\r
+ /// Audio Track Name\r
+ /// </summary>\r
+ public string Track { get; set; }\r
+\r
+ /// <summary>\r
+ /// Audio Mixdown\r
+ /// </summary>\r
+ public string MixDown { get; set; }\r
+\r
+ /// <summary>\r
+ /// Audio Encoder\r
+ /// </summary>\r
+ public string Encoder { get; set; }\r
+\r
+ /// <summary>\r
+ /// Audio Bitrate\r
+ /// </summary>\r
+ public string Bitrate { get; set; }\r
+\r
+ /// <summary>\r
+ /// Audio SampleRate\r
+ /// </summary>\r
+ public string SampleRate { get; set; }\r
+\r
+ /// <summary>\r
+ /// Dynamic Range Compression\r
+ /// </summary>\r
+ public string DRC { get; set; }\r
+ }\r
+}\r
+++ /dev/null
-/* Export.cs $\r
- \r
- This file is part of the HandBrake source code.\r
- Homepage: <http://handbrake.fr/>.\r
- It may be used under the terms of the GNU General Public License. */\r
-\r
-using System;\r
-using System.Text;\r
-using System.Xml;\r
-\r
-namespace Handbrake.Presets\r
-{\r
- class Export\r
- {\r
- // WARNING This file is not complete!!!!!!\r
-\r
- // TODO \r
- // 1. Hookup all the widgets in the GUI so it exports real values.\r
- // 2. Check for any missing key/value pairs\r
- // 3. Test with MacGui / Cleanup code / Retest\r
-\r
- private XmlTextWriter writer;\r
-\r
- public void ExportMacPreset(string path)\r
- {\r
- writer = new XmlTextWriter("C:\\test.xml", Encoding.UTF8);\r
-\r
- // Header\r
- writer.WriteStartDocument();\r
- writer.WriteDocType("plist", "-//Apple//DTD PLIST 1.0//EN", @"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);\r
-\r
- writer.WriteStartElement("plist");\r
- writer.WriteStartElement("array");\r
- \r
- // Add New Preset Here. Can write multiple presets here if required in future.\r
- WritePreset();\r
-\r
- // Footer\r
- writer.WriteEndElement();\r
- writer.WriteEndElement();\r
-\r
- writer.WriteEndDocument();\r
-\r
- // Closeout\r
- writer.Close();\r
- }\r
-\r
- // Primary function for writing dict.\r
- private void WritePreset()\r
- {\r
- writer.WriteStartElement("dict");\r
- AudioListArrayDict();\r
- AddEncodeSettings();\r
-\r
- writer.WriteEndElement();\r
- }\r
-\r
- // Add all the encode settings to the preset\r
- private void AddEncodeSettings()\r
- {\r
- AddEncodeElement("ChapterMarkers", "integer", "");\r
- AddEncodeElement("Default", "integer", "");\r
- AddEncodeElement("FileFormat", "String", "");\r
- AddBooleanElement("Folder", true);\r
- AddEncodeElement("Mp4HttpOptimize", "integer", "");\r
- AddEncodeElement("Mp4LargeFile", "integer", "");\r
- AddEncodeElement("Mp4iPodCompatible", "integer", "");\r
- AddEncodeElement("PictureAutoCrop", "integer", "");\r
- AddEncodeElement("PictureBottomCrop", "integer", "");\r
- AddEncodeElement("PictureDeblock", "integer", "");\r
- AddEncodeElement("PictureDecomb", "integer", "");\r
- AddEncodeElement("PictureDecombCustom", "string", "");\r
- AddEncodeElement("PictureDecombDeinterlace", "integer", "");\r
- AddEncodeElement("PictureDeinterlace", "integer", "");\r
- AddEncodeElement("PictureDeinterlaceCustom", "string", "");\r
- AddEncodeElement("PictureDenoise", "integer", "");\r
- AddEncodeElement("PictureDenoiseCustom", "string", "");\r
- AddEncodeElement("PictureDetelecine", "integer", "");\r
- AddEncodeElement("PictureDetelecineCustom", "string", "");\r
- AddEncodeElement("PictureHeight", "integer", "");\r
- AddEncodeElement("PictureKeepRatio", "integer", "");\r
- AddEncodeElement("PictureLeftCrop", "integer", "");\r
- AddEncodeElement("PicturePAR", "integer", "");\r
- AddEncodeElement("PictureRightCrop", "integer", "");\r
- AddEncodeElement("PictureTopCrop", "integer", "");\r
- AddEncodeElement("PictureWidth", "integer", "");\r
- AddEncodeElement("PresetBuildNumber", "string", "");\r
- AddEncodeElement("PresetDescription", "string", "");\r
- AddEncodeElement("PresetName", "string", "");\r
- AddEncodeElement("Type", "integer", "");\r
- AddEncodeElement("UsesMaxPictureSettings", "integer", "");\r
- AddEncodeElement("UsesPictureFilters", "integer", "");\r
- AddEncodeElement("UsesPictureSettings", "integer", "");\r
- AddEncodeElement("VideoAvgBitrate", "string", "");\r
- AddEncodeElement("VideoEncoder", "string", "");\r
- AddEncodeElement("VideoFramerate", "string", "");\r
- AddEncodeElement("VideoGrayScale", "integer", "");\r
- AddEncodeElement("VideoQualitySlider", "real", "");\r
- AddEncodeElement("VideoQualityType", "integer", "");\r
- AddEncodeElement("VideoTargetSize", "string", "");\r
- AddEncodeElement("VideoTurboTwoPass", "integer", "");\r
- AddEncodeElement("VideoTwoPass", "integer", "");\r
- AddEncodeElement("x264Option", "string", "");\r
- }\r
-\r
- // Add Preset setting + value\r
- private void AddBooleanElement(string keyName, Boolean value)\r
- {\r
- writer.WriteStartElement("key");\r
- writer.WriteString(keyName);\r
- writer.WriteEndElement();\r
- if (value)\r
- {\r
- writer.WriteStartElement("true");\r
- writer.WriteEndElement();\r
- }\r
- else\r
- {\r
- writer.WriteStartElement("false");\r
- writer.WriteEndElement();\r
- }\r
- }\r
- private void AddEncodeElement(string keyName, string type, string value)\r
- {\r
- writer.WriteElementString("key", keyName);\r
- writer.WriteElementString(type, value);\r
- }\r
-\r
- // Add List of audio tracks\r
- private void AudioListArrayDict()\r
- {\r
- writer.WriteStartElement("key");\r
- writer.WriteString("AudioList");\r
- writer.WriteEndElement();\r
-\r
- writer.WriteStartElement("array");\r
- AddAudioItem();\r
- AddAudioItem();\r
- writer.WriteEndElement();\r
- }\r
- private void AddAudioItem()\r
- {\r
- int bitrate = 448;\r
- string encoder = "AC3 Passthru";\r
- string mixdown = "AC3 Passthru";\r
- string sample = "Auto";\r
- int track = 1;\r
- double drc = 0.0;\r
- string desc = "English (AC3) (5.1 ch)";\r
-\r
- writer.WriteStartElement("dict");\r
-\r
- writer.WriteElementString("key", "AudioBitrate");\r
- writer.WriteElementString("string", bitrate.ToString());\r
-\r
- writer.WriteElementString("key", "AudioEncoder");\r
- writer.WriteElementString("string", encoder);\r
-\r
- writer.WriteElementString("key", "AudioMixdown");\r
- writer.WriteElementString("string", mixdown);\r
-\r
- writer.WriteElementString("key", "AudioSamplerate");\r
- writer.WriteElementString("string", sample);\r
-\r
- writer.WriteElementString("key", "AudioTrack");\r
- writer.WriteElementString("integer", track.ToString());\r
-\r
- writer.WriteElementString("key", "AudioTrackDRCSlider");\r
- writer.WriteElementString("real", drc.ToString());\r
-\r
- writer.WriteElementString("key", "AudioTrackDescription");\r
- writer.WriteElementString("string", desc);\r
-\r
- writer.WriteEndElement();\r
- }\r
- }\r
-}
\ No newline at end of file
-using System;\r
+/* PlistPresetHandler.cs $\r
+ \r
+ This file is part of the HandBrake source code.\r
+ Homepage: <http://handbrake.fr/>.\r
+ It may be used under the terms of the GNU General Public License. */\r
+\r
+using System;\r
using System.IO;\r
+using System.Text;\r
using System.Xml;\r
using System.Windows.Forms;\r
using System.Collections;\r
using Handbrake.Functions;\r
+using Handbrake.Model;\r
\r
namespace Handbrake.Presets\r
{\r
- class Import\r
+ public class PlistPresetHandler\r
{\r
- public QueryParser importMacPreset(string filename)\r
+ /* WARNING This file is not complete!!!!!!\r
+ *\r
+ * TODO \r
+ * 1. Hookup all the widgets in the GUI so it exports real values.\r
+ * 2. Check for any missing key/value pairs\r
+ * 3. Test with MacGui / Cleanup code / Retest \r
+ */\r
+\r
+ private XmlTextWriter Writer;\r
+\r
+ /// <summary>\r
+ /// Import a Plist preset generated by the Mac or Linux GUI\r
+ /// </summary>\r
+ /// <param name="filename"></param>\r
+ /// <returns></returns>\r
+ public static QueryParser Import(string filename)\r
{\r
XmlNode root = null;\r
try\r
return queryParsed;\r
}\r
\r
- // --- It's the end of the road\r
+ /// <summary>\r
+ /// Export a preset to a Plist file readable by the Mac and Linux GUI's\r
+ /// </summary>\r
+ /// <param name="path"></param>\r
+ public void Export(string path)\r
+ {\r
+ Writer = new XmlTextWriter("C:\\test.xml", Encoding.UTF8);\r
+\r
+ // Header\r
+ Writer.WriteStartDocument();\r
+ Writer.WriteDocType("plist", "-//Apple//DTD PLIST 1.0//EN", @"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);\r
+\r
+ Writer.WriteStartElement("plist");\r
+ Writer.WriteStartElement("array");\r
+\r
+ // Add New Preset Here. Can write multiple presets here if required in future.\r
+ WritePreset();\r
+\r
+ // Footer\r
+ Writer.WriteEndElement();\r
+ Writer.WriteEndElement();\r
+\r
+ Writer.WriteEndDocument();\r
+\r
+ // Closeout\r
+ Writer.Close();\r
+ }\r
+ \r
+ /// <summary>\r
+ /// Write a Plist file\r
+ /// </summary>\r
+ private void WritePreset()\r
+ {\r
+ Writer.WriteStartElement("dict");\r
+ AudioListArrayDict();\r
+ AddEncodeSettings();\r
+\r
+ Writer.WriteEndElement();\r
+ }\r
+\r
+ /// <summary>\r
+ /// Add all the encode settings to the preset\r
+ /// </summary>\r
+ private void AddEncodeSettings()\r
+ {\r
+ AddEncodeElement("ChapterMarkers", "integer", "");\r
+ AddEncodeElement("Default", "integer", "");\r
+ AddEncodeElement("FileFormat", "String", "");\r
+ AddBooleanElement("Folder", true);\r
+ AddEncodeElement("Mp4HttpOptimize", "integer", "");\r
+ AddEncodeElement("Mp4LargeFile", "integer", "");\r
+ AddEncodeElement("Mp4iPodCompatible", "integer", "");\r
+ AddEncodeElement("PictureAutoCrop", "integer", "");\r
+ AddEncodeElement("PictureBottomCrop", "integer", "");\r
+ AddEncodeElement("PictureDeblock", "integer", "");\r
+ AddEncodeElement("PictureDecomb", "integer", "");\r
+ AddEncodeElement("PictureDecombCustom", "string", "");\r
+ AddEncodeElement("PictureDecombDeinterlace", "integer", "");\r
+ AddEncodeElement("PictureDeinterlace", "integer", "");\r
+ AddEncodeElement("PictureDeinterlaceCustom", "string", "");\r
+ AddEncodeElement("PictureDenoise", "integer", "");\r
+ AddEncodeElement("PictureDenoiseCustom", "string", "");\r
+ AddEncodeElement("PictureDetelecine", "integer", "");\r
+ AddEncodeElement("PictureDetelecineCustom", "string", "");\r
+ AddEncodeElement("PictureHeight", "integer", "");\r
+ AddEncodeElement("PictureKeepRatio", "integer", "");\r
+ AddEncodeElement("PictureLeftCrop", "integer", "");\r
+ AddEncodeElement("PicturePAR", "integer", "");\r
+ AddEncodeElement("PictureRightCrop", "integer", "");\r
+ AddEncodeElement("PictureTopCrop", "integer", "");\r
+ AddEncodeElement("PictureWidth", "integer", "");\r
+ AddEncodeElement("PresetBuildNumber", "string", "");\r
+ AddEncodeElement("PresetDescription", "string", "");\r
+ AddEncodeElement("PresetName", "string", "");\r
+ AddEncodeElement("Type", "integer", "");\r
+ AddEncodeElement("UsesMaxPictureSettings", "integer", "");\r
+ AddEncodeElement("UsesPictureFilters", "integer", "");\r
+ AddEncodeElement("UsesPictureSettings", "integer", "");\r
+ AddEncodeElement("VideoAvgBitrate", "string", "");\r
+ AddEncodeElement("VideoEncoder", "string", "");\r
+ AddEncodeElement("VideoFramerate", "string", "");\r
+ AddEncodeElement("VideoGrayScale", "integer", "");\r
+ AddEncodeElement("VideoQualitySlider", "real", "");\r
+ AddEncodeElement("VideoQualityType", "integer", "");\r
+ AddEncodeElement("VideoTargetSize", "string", "");\r
+ AddEncodeElement("VideoTurboTwoPass", "integer", "");\r
+ AddEncodeElement("VideoTwoPass", "integer", "");\r
+ AddEncodeElement("x264Option", "string", "");\r
+ }\r
+\r
+ /// <summary>\r
+ /// Add Preset setting + value\r
+ /// </summary>\r
+ /// <param name="keyName"></param>\r
+ /// <param name="value"></param>\r
+ private void AddBooleanElement(string keyName, Boolean value)\r
+ {\r
+ Writer.WriteStartElement("key");\r
+ Writer.WriteString(keyName);\r
+ Writer.WriteEndElement();\r
+ if (value)\r
+ {\r
+ Writer.WriteStartElement("true");\r
+ Writer.WriteEndElement();\r
+ }\r
+ else\r
+ {\r
+ Writer.WriteStartElement("false");\r
+ Writer.WriteEndElement();\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Add Preset setting + value\r
+ /// </summary>\r
+ /// <param name="keyName"></param>\r
+ /// <param name="type"></param>\r
+ /// <param name="value"></param>\r
+ private void AddEncodeElement(string keyName, string type, string value)\r
+ {\r
+ Writer.WriteElementString("key", keyName);\r
+ Writer.WriteElementString(type, value);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Add List of audio tracks\r
+ /// </summary>\r
+ private void AudioListArrayDict()\r
+ {\r
+ Writer.WriteStartElement("key");\r
+ Writer.WriteString("AudioList");\r
+ Writer.WriteEndElement();\r
+\r
+ Writer.WriteStartElement("array");\r
+ AddAudioItem();\r
+ AddAudioItem();\r
+ Writer.WriteEndElement();\r
+ }\r
+\r
+ /// <summary>\r
+ /// Add List of audio tracks\r
+ /// </summary>\r
+ private void AddAudioItem()\r
+ {\r
+ int bitrate = 448;\r
+ string encoder = "AC3 Passthru";\r
+ string mixdown = "AC3 Passthru";\r
+ string sample = "Auto";\r
+ int track = 1;\r
+ double drc = 0.0;\r
+ string desc = "English (AC3) (5.1 ch)";\r
+\r
+ Writer.WriteStartElement("dict");\r
+\r
+ Writer.WriteElementString("key", "AudioBitrate");\r
+ Writer.WriteElementString("string", bitrate.ToString());\r
+\r
+ Writer.WriteElementString("key", "AudioEncoder");\r
+ Writer.WriteElementString("string", encoder);\r
+\r
+ Writer.WriteElementString("key", "AudioMixdown");\r
+ Writer.WriteElementString("string", mixdown);\r
+\r
+ Writer.WriteElementString("key", "AudioSamplerate");\r
+ Writer.WriteElementString("string", sample);\r
+\r
+ Writer.WriteElementString("key", "AudioTrack");\r
+ Writer.WriteElementString("integer", track.ToString());\r
+\r
+ Writer.WriteElementString("key", "AudioTrackDRCSlider");\r
+ Writer.WriteElementString("real", drc.ToString());\r
+\r
+ Writer.WriteElementString("key", "AudioTrackDescription");\r
+ Writer.WriteElementString("string", desc);\r
+\r
+ Writer.WriteEndElement();\r
+ }\r
}\r
}
\ No newline at end of file
{\r
public class PresetsHandler\r
{\r
- List<Preset> _presets = new List<Preset>();\r
- List<Preset> _userPresets = new List<Preset>();\r
+ List<Preset> Presets = new List<Preset>();\r
+ List<Preset> UserPresets = new List<Preset>();\r
private static readonly XmlSerializer Ser = new XmlSerializer(typeof(List<Preset>));\r
- readonly string _userPresetFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\user_presets.xml";\r
- readonly string _hbPresetFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\presets.xml";\r
+ readonly string UserPresetFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\user_presets.xml";\r
+ readonly string HbPresetFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\presets.xml";\r
\r
/// <summary>\r
/// Add a new preset to the system\r
/// </summary>\r
/// <param name="presetName">String, The name of the new preset</param>\r
/// <param name="query">String, the CLI query for the new preset</param>\r
- /// <param name="pictureSettings"> Bool, store crop/picture sizes in the _presets</param>\r
+ /// <param name="pictureSettings"> Bool, store crop/picture sizes in the Presets</param>\r
public Boolean Add(string presetName, string query, Boolean pictureSettings)\r
{\r
if (CheckIfPresetExists(presetName) == false)\r
{\r
Preset newPreset = new Preset { Name = presetName, Query = query, PictureSettings = pictureSettings, Version = Properties.Settings.Default.hb_version };\r
- _userPresets.Add(newPreset);\r
+ UserPresets.Add(newPreset);\r
UpdatePresetFiles();\r
return true;\r
}\r
List<Preset> newUserPresets = new List<Preset>();\r
\r
// Built In Presets\r
- foreach (Preset item in _presets)\r
+ foreach (Preset item in Presets)\r
{\r
if (item.Name != name)\r
{\r
newPresets.Add(item);\r
}\r
}\r
- _presets = newPresets;\r
+ Presets = newPresets;\r
\r
// User Presets\r
- foreach (Preset item in _userPresets)\r
+ foreach (Preset item in UserPresets)\r
{\r
if (item.Name != name)\r
{\r
newUserPresets.Add(item);\r
}\r
}\r
- _userPresets = newUserPresets;\r
+ UserPresets = newUserPresets;\r
\r
- // Rebuild the _userPresets.xml file\r
+ // Rebuild the UserPresets.xml file\r
UpdatePresetFiles();\r
UpdatePresetFiles();\r
}\r
\r
/// <summary>\r
- /// Remove all built in _presets;\r
+ /// Remove all built in Presets;\r
/// </summary>\r
public void RemoveBuiltInPresets()\r
{\r
- _presets.Clear();\r
+ Presets.Clear();\r
UpdatePresetFiles();\r
}\r
\r
public void Update(string presetName, string query, Boolean pictureSettings)\r
{\r
// User Presets\r
- foreach (Preset item in _userPresets)\r
+ foreach (Preset item in UserPresets)\r
{\r
if (item.Name == presetName)\r
{\r
public Preset GetPreset(string name)\r
{\r
// Built In Presets\r
- foreach (Preset item in _presets)\r
+ foreach (Preset item in Presets)\r
{\r
if (item.Name == name)\r
return item;\r
}\r
\r
// User Presets\r
- foreach (Preset item in _userPresets)\r
+ foreach (Preset item in UserPresets)\r
{\r
if (item.Name == name)\r
return item;\r
/// </summary>\r
public void UpdateBuiltInPresets()\r
{\r
- // Create a new tempory file and execute the CLI to get the built in _presets.\r
+ // Create a new tempory file and execute the CLI to get the built in Presets.\r
string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");\r
string presetsPath = Path.Combine(Path.GetTempPath(), "temp_presets.dat");\r
string strCmdLine = String.Format(@"cmd /c """"{0}"" --preset-list >""{1}"" 2>&1""", handbrakeCLIPath, presetsPath);\r
hbproc.Close();\r
}\r
\r
- // Clear the current built in _presets and now parse the tempory _presets file.\r
- _presets.Clear();\r
+ // Clear the current built in Presets and now parse the tempory Presets file.\r
+ Presets.Clear();\r
\r
if (File.Exists(presetsPath))\r
{\r
Version = Properties.Settings.Default.hb_version,\r
PictureSettings = pic\r
};\r
- _presets.Add(newPreset);\r
+ Presets.Add(newPreset);\r
}\r
}\r
presetInput.Close();\r
presetInput.Dispose();\r
}\r
\r
- // Finally, Create a new or update the current _presets.xml file\r
+ // Finally, Create a new or update the current Presets.xml file\r
UpdatePresetFiles();\r
}\r
\r
/// <summary>\r
- /// Load in the preset data from _presets.xml and _userPresets.xml\r
- /// Load it into the 2 arraylist's _presets and _userPresets\r
+ /// Load in the preset data from Presets.xml and UserPresets.xml\r
+ /// Load it into the 2 arraylist's Presets and UserPresets\r
/// </summary>\r
private void LoadPresetData()\r
{\r
- // First clear the _presets arraylists\r
- _presets.Clear();\r
- _userPresets.Clear();\r
+ // First clear the Presets arraylists\r
+ Presets.Clear();\r
+ UserPresets.Clear();\r
\r
try\r
{\r
- // Load in the users _presets from _userPresets.xml\r
- if (File.Exists(_hbPresetFile))\r
+ // Load in the users Presets from UserPresets.xml\r
+ if (File.Exists(HbPresetFile))\r
{\r
- using (FileStream strm = new FileStream(_hbPresetFile, FileMode.Open, FileAccess.Read))\r
+ using (FileStream strm = new FileStream(HbPresetFile, FileMode.Open, FileAccess.Read))\r
{\r
if (strm.Length != 0)\r
{\r
\r
if (list != null)\r
foreach (Preset preset in list)\r
- _presets.Add(preset);\r
+ Presets.Add(preset);\r
}\r
}\r
}\r
{\r
MessageBox.Show(\r
"HandBrakes preset file appears to have been corrupted. This file will now be re-generated!\n" +\r
- "If the problem presists, please delete the file: \n\n" + _hbPresetFile, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+ "If the problem presists, please delete the file: \n\n" + HbPresetFile, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
UpdateBuiltInPresets();\r
}\r
\r
try\r
{\r
- // Load in the users _presets from _userPresets.xml\r
- if (File.Exists(_userPresetFile))\r
+ // Load in the users Presets from UserPresets.xml\r
+ if (File.Exists(UserPresetFile))\r
{\r
- using (FileStream strm = new FileStream(_userPresetFile, FileMode.Open, FileAccess.Read))\r
+ using (FileStream strm = new FileStream(UserPresetFile, FileMode.Open, FileAccess.Read))\r
{\r
if (strm.Length != 0)\r
{\r
\r
if (list != null)\r
foreach (Preset preset in list)\r
- _userPresets.Add(preset);\r
+ UserPresets.Add(preset);\r
}\r
}\r
}\r
"Your User presets file appears to have been corrupted.\n" +\r
"Your presets will not be loaded. You may need to re-create your presets.\n\n" +\r
"Your user presets file has been renamed to 'user_presets.xml.old' and is located in:\n " +\r
- Path.GetDirectoryName(_userPresetFile) + "\n" +\r
+ Path.GetDirectoryName(UserPresetFile) + "\n" +\r
"You may be able to recover some presets if you know the XML language.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
\r
// Recover from Error.\r
- if (File.Exists(_userPresetFile))\r
+ if (File.Exists(UserPresetFile))\r
{\r
- string disabledFile = _userPresetFile + ".old";\r
+ string disabledFile = UserPresetFile + ".old";\r
if (File.Exists(disabledFile))\r
File.Delete(disabledFile);\r
- File.Move(_userPresetFile, disabledFile);\r
+ File.Move(UserPresetFile, disabledFile);\r
}\r
\r
}\r
string category = string.Empty;\r
TreeNode rootNode = null;\r
\r
- if (_presets.Count != 0) // Built In Presets\r
+ if (Presets.Count != 0) // Built In Presets\r
{\r
\r
- foreach (Preset preset in _presets)\r
+ foreach (Preset preset in Presets)\r
{\r
if (preset.Category != category)\r
{\r
}\r
\r
rootNode = null; category = null;\r
- foreach (Preset preset in _userPresets) // User Presets\r
+ foreach (Preset preset in UserPresets) // User Presets\r
{\r
if (preset.Category != category && preset.Category != null)\r
{\r
{\r
try\r
{\r
- using (FileStream strm = new FileStream(_hbPresetFile, FileMode.Create, FileAccess.Write))\r
+ using (FileStream strm = new FileStream(HbPresetFile, FileMode.Create, FileAccess.Write))\r
{\r
- Ser.Serialize(strm, _presets);\r
+ Ser.Serialize(strm, Presets);\r
strm.Close();\r
strm.Dispose();\r
}\r
\r
- using (FileStream strm = new FileStream(_userPresetFile, FileMode.Create, FileAccess.Write))\r
+ using (FileStream strm = new FileStream(UserPresetFile, FileMode.Create, FileAccess.Write))\r
{\r
- Ser.Serialize(strm, _userPresets);\r
+ Ser.Serialize(strm, UserPresets);\r
strm.Close();\r
strm.Dispose();\r
}\r
}\r
\r
/// <summary>\r
- /// Check if the preset "name" exists in either _presets or _userPresets lists.\r
+ /// Check if the preset "name" exists in either Presets or UserPresets lists.\r
/// </summary>\r
/// <param name="name"></param>\r
/// <returns></returns>\r
return true;\r
\r
// Built In Presets\r
- foreach (Preset item in _presets)\r
+ foreach (Preset item in Presets)\r
{\r
if (item.Name == name)\r
return true;\r
}\r
\r
// User Presets\r
- foreach (Preset item in _userPresets)\r
+ foreach (Preset item in UserPresets)\r
{\r
if (item.Name == name)\r
return true;\r
}\r
\r
/// <summary>\r
- /// Check if the user preset "name" exists in _userPresets list.\r
+ /// Check if the user preset "name" exists in UserPresets list.\r
/// </summary>\r
/// <param name="name"></param>\r
/// <returns></returns>\r
return false;\r
\r
// User Presets\r
- foreach (Preset item in _userPresets)\r
+ foreach (Preset item in UserPresets)\r
{\r
if (item.Name == name)\r
return true;\r
}\r
\r
/// <summary>\r
- /// Check if the built in _presets stored are not out of date.\r
+ /// Check if the built in Presets stored are not out of date.\r
/// Update them if they are.\r
/// </summary>\r
/// <returns></returns>\r
public Boolean CheckIfPresetsAreOutOfDate()\r
{\r
LoadPresetData();\r
- // Update built-in _presets if the built-in _presets belong to an older version.\r
- if (_presets.Count != 0)\r
- if (_presets[0].Version != Properties.Settings.Default.hb_version)\r
+ // Update built-in Presets if the built-in Presets belong to an older version.\r
+ if (Presets.Count != 0)\r
+ if (Presets[0].Version != Properties.Settings.Default.hb_version)\r
{\r
UpdateBuiltInPresets();\r
return true;\r
// Objects which may be used by one or more other objects *************\r
Queue encodeQueue = new Queue();\r
PresetsHandler presetHandler = new PresetsHandler();\r
- QueryGenerator queryGen = new QueryGenerator();\r
\r
// Globals: Mainly used for tracking. *********************************\r
public Title selectedTitle;\r
x264Panel.reset2Defaults();\r
\r
QueryParser presetQuery = QueryParser.Parse(query);\r
- PresetLoader.presetLoader(this, presetQuery, Properties.Settings.Default.defaultPreset, loadPictureSettings);\r
+ PresetLoader.LoadPreset(this, presetQuery, Properties.Settings.Default.defaultPreset, loadPictureSettings);\r
\r
x264Panel.X264_StandardizeOptString();\r
x264Panel.X264_SetCurrentSettingsInPanel();\r
this.Resize += new EventHandler(frmMain_Resize);\r
\r
// Handle Encode Start / Finish / Pause\r
- encodeQueue.CurrentJobCompleted += new EventHandler(encodeEnded);\r
+ \r
encodeQueue.QueuePauseRequested += new EventHandler(encodePaused);\r
- encodeQueue.NewJobStarted += new EventHandler(encodeStarted);\r
+ encodeQueue.EncodeStarted += new EventHandler(encodeStarted);\r
+ encodeQueue.EncodeEnded += new EventHandler(encodeEnded);\r
\r
// Handle a file being draged onto the GUI.\r
this.DragEnter += new DragEventHandler(frmMain_DragEnter);\r
}\r
private void btn_new_preset_Click(object sender, EventArgs e)\r
{\r
- Form preset = new frmAddPreset(this, queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), presetHandler);\r
+ Form preset = new frmAddPreset(this, QueryGenerator.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), presetHandler);\r
preset.ShowDialog();\r
}\r
#endregion\r
QueryParser presetQuery = QueryParser.Parse(query);\r
\r
// Now load the preset\r
- PresetLoader.presetLoader(this, presetQuery, presetName, loadPictureSettings);\r
+ PresetLoader.LoadPreset(this, presetQuery, presetName, loadPictureSettings);\r
\r
// The x264 widgets will need updated, so do this now:\r
x264Panel.X264_StandardizeOptString();\r
}\r
private void importPreset()\r
{\r
- Import imp = new Import();\r
if (openPreset.ShowDialog() == DialogResult.OK)\r
{\r
- QueryParser parsed = imp.importMacPreset(openPreset.FileName);\r
+ QueryParser parsed = PlistPresetHandler.Import(openPreset.FileName);\r
if (presetHandler.CheckIfUserPresetExists(parsed.PresetName + " (Imported)"))\r
{\r
DialogResult result = MessageBox.Show("This preset appears to already exist. Would you like to overwrite it?", "Overwrite preset?",\r
MessageBoxButtons.YesNo, MessageBoxIcon.Warning);\r
if (result == DialogResult.Yes)\r
{\r
- PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);\r
- presetHandler.Update(parsed.PresetName + " (Imported)", queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null),\r
+ PresetLoader.LoadPreset(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);\r
+ presetHandler.Update(parsed.PresetName + " (Imported)", QueryGenerator.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null),\r
parsed.UsesPictureSettings);\r
}\r
}\r
else\r
{\r
- PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);\r
- presetHandler.Add(parsed.PresetName, queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), parsed.UsesPictureSettings);\r
+ PresetLoader.LoadPreset(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);\r
+ presetHandler.Add(parsed.PresetName, QueryGenerator.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), parsed.UsesPictureSettings);\r
\r
- if (presetHandler.Add(parsed.PresetName + " (Imported)", queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), parsed.UsesPictureSettings))\r
+ if (presetHandler.Add(parsed.PresetName + " (Imported)", QueryGenerator.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), parsed.UsesPictureSettings))\r
{\r
TreeNode preset_treeview = new TreeNode(parsed.PresetName + " (Imported)") { ForeColor = Color.Black };\r
treeView_presets.Nodes.Add(preset_treeview);\r
{\r
DialogResult result;\r
if (Properties.Settings.Default.enocdeStatusInGui && !Properties.Settings.Default.showCliForInGuiEncodeStatus)\r
- result = MessageBox.Show("Are you sure you wish to cancel the encode?\n\nPlease note, when 'Enable in-GUI encode status' is enabled, stopping this encode will render the file unplayable. ",\r
- "Cancel Encode?",MessageBoxButtons.YesNo,MessageBoxIcon.Question);\r
+ {\r
+ result = MessageBox.Show(\r
+ "Are you sure you wish to cancel the encode?\n\nPlease note, when 'Enable in-GUI encode status' is enabled, stopping this encode will render the file unplayable. ",\r
+ "Cancel Encode?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+ }\r
else\r
+ {\r
result = MessageBox.Show("Are you sure you wish to cancel the encode?", "Cancel Encode?",\r
- MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+ }\r
\r
if (result == DialogResult.Yes)\r
{\r
}\r
else\r
{\r
- // Allow the CLI to exit cleanly\r
- Win32.SetForegroundWindow((int) encodeQueue.ProcessHandle);\r
- SendKeys.Send("^C");\r
+ encodeQueue.SafelyClose();\r
}\r
\r
// Update the GUI\r
{\r
if (encodeQueue.Count != 0 || (!string.IsNullOrEmpty(sourcePath) && !string.IsNullOrEmpty(text_destination.Text)))\r
{\r
- string generatedQuery = queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);\r
- string specifiedQuery = rtf_query.Text != "" ? rtf_query.Text : queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);\r
+ string generatedQuery = QueryGenerator.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);\r
+ string specifiedQuery = rtf_query.Text != "" ? rtf_query.Text : QueryGenerator.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);\r
string query = string.Empty;\r
\r
// Check to make sure the generated query matches the GUI settings\r
MessageBox.Show("No source or destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
else\r
{\r
- String query = queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);\r
+ String query = QueryGenerator.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);\r
if (rtf_query.Text != "")\r
query = rtf_query.Text;\r
\r
// Query Editor Tab\r
private void btn_generate_Query_Click(object sender, EventArgs e)\r
{\r
- rtf_query.Text = queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);\r
+ rtf_query.Text = QueryGenerator.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);\r
}\r
private void btn_clear_Click(object sender, EventArgs e)\r
{\r
QueryParser presetQuery = QueryParser.Parse(query);\r
\r
// Now load the preset\r
- PresetLoader.presetLoader(this, presetQuery, "Load Back From Queue", true);\r
+ PresetLoader.LoadPreset(this, presetQuery, "Load Back From Queue", true);\r
\r
// The x264 widgets will need updated, so do this now:\r
x264Panel.X264_StandardizeOptString();\r
{\r
public partial class frmPreview : Form\r
{\r
- readonly QueryGenerator HbCommonFunc = new QueryGenerator();\r
readonly Queue Process = new Queue();\r
private delegate void UpdateUIHandler();\r
String CurrentlyPlaying = "";\r
lbl_status.Text = "Encoding Sample for (VLC) ...";\r
int duration;\r
int.TryParse(cb_duration.Text, out duration);\r
- String query = HbCommonFunc.GenerateCLIQuery(MainWindow, 3, duration, cb_preview.Text);\r
+ String query = QueryGenerator.GenerateCLIQuery(MainWindow, 3, duration, cb_preview.Text);\r
ThreadPool.QueueUserWorkItem(ProcMonitor, query);\r
}\r
private void btn_playQT_Click(object sender, EventArgs e)\r
lbl_status.Text = "Encoding Sample for (QT) ...";\r
int duration;\r
int.TryParse(cb_duration.Text, out duration);\r
- String query = HbCommonFunc.GenerateCLIQuery(MainWindow, 3, duration, cb_preview.Text);\r
+ String query = QueryGenerator.GenerateCLIQuery(MainWindow, 3, duration, cb_preview.Text);\r
\r
ThreadPool.QueueUserWorkItem(ProcMonitor, query);\r
}\r
using System.Windows.Forms;\r
using Handbrake.EncodeQueue;\r
using System.Collections.ObjectModel;\r
+using Handbrake.Model;\r
\r
namespace Handbrake\r
{\r
this.mainWindow = mw;\r
\r
this.queue = q;\r
- queue.NewJobStarted += new EventHandler(QueueOnEncodeStart);\r
+ queue.EncodeStarted += new EventHandler(QueueOnEncodeStart);\r
queue.QueueCompleted += new EventHandler(QueueOnQueueFinished);\r
queue.QueuePauseRequested += new EventHandler(QueueOnPaused);\r
}\r
\r
// Display The Audio Track Information\r
string audio = string.Empty;\r
- foreach (Functions.AudioTrack track in parsed.AudioInformation)\r
+ foreach (AudioTrack track in parsed.AudioInformation)\r
{\r
if (audio != "")\r
audio += ", " + track.Encoder;\r
\r
// Display The Audio Track Information\r
string audio = string.Empty;\r
- foreach (Functions.AudioTrack track in parsed.AudioInformation)\r
+ foreach (AudioTrack track in parsed.AudioInformation)\r
{\r
if (audio != "")\r
audio += ", " + track.Encoder;\r