summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2010-01-30 23:52:47 +0000
committersr55 <[email protected]>2010-01-30 23:52:47 +0000
commit377768a2a90f5b470a1c047a02f4c998a8b348b4 (patch)
tree90ce0b844e17f6525a75805811555bde12cb6bcd /win
parent971ab73d6af6d07838922a667648c97e2f07c041 (diff)
WinGui:
- Added some code to allow direct execution of the CLI rather than using CMD. This may be useful later on. - Re-factoring. Added Many code comments / Cleaned up some code style issues. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3088 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r--win/C#/EncodeQueue/Encode.cs122
-rw-r--r--win/C#/EncodeQueue/Queue.cs18
-rw-r--r--win/C#/Functions/Main.cs2
-rw-r--r--win/C#/Functions/PresetLoader.cs7
-rw-r--r--win/C#/Functions/QueryGenerator.cs30
-rw-r--r--win/C#/Functions/QueryParser.cs40
-rw-r--r--win/C#/Functions/Scan.cs75
-rw-r--r--win/C#/HandBrakeCS.csproj3
-rw-r--r--win/C#/Model/AudioTrack.cs57
-rw-r--r--win/C#/Presets/Export.cs177
-rw-r--r--win/C#/Presets/PlistPresetHandler.cs (renamed from win/C#/Presets/Import.cs)207
-rw-r--r--win/C#/Presets/Preset.cs (renamed from win/C#/Presets/preset.cs)0
-rw-r--r--win/C#/Presets/PresetsHandler.cs110
-rw-r--r--win/C#/frmMain.cs50
-rw-r--r--win/C#/frmPreview.cs5
-rw-r--r--win/C#/frmQueue.cs7
16 files changed, 575 insertions, 335 deletions
diff --git a/win/C#/EncodeQueue/Encode.cs b/win/C#/EncodeQueue/Encode.cs
index 49a836bb4..28ef3ae46 100644
--- a/win/C#/EncodeQueue/Encode.cs
+++ b/win/C#/EncodeQueue/Encode.cs
@@ -12,8 +12,14 @@ using Handbrake.Functions;
namespace Handbrake.EncodeQueue
{
+ /// <summary>
+ /// Class which handles the CLI
+ /// </summary>
public class Encode
{
+ /// <summary>
+ /// Process ID
+ /// </summary>
private int ProcessID { get; set; }
/// <summary>
@@ -120,6 +126,79 @@ namespace Handbrake.EncodeQueue
}
/// <summary>
+ /// Function to run the CLI directly rather than via CMD
+ /// TODO: Code to handle the Log data has yet to be written.
+ /// TODO: Code to handle the % / ETA info has to be written.
+ /// </summary>
+ protected void DirectRun(string query)
+ {
+ try
+ {
+ if (EncodeStarted != null)
+ EncodeStarted(this, new EventArgs());
+
+ IsEncoding = true;
+
+ // Setup the job
+ string handbrakeCLIPath = Path.Combine(Environment.CurrentDirectory, "HandBrakeCLI.exe");
+ Process hbProc = new Process
+ {
+ StartInfo =
+ {
+ FileName = handbrakeCLIPath,
+ Arguments = query,
+ UseShellExecute = false,
+ RedirectStandardOutput = true,
+ RedirectStandardError = true,
+ RedirectStandardInput = true,
+ CreateNoWindow = false,
+ WindowStyle = ProcessWindowStyle.Minimized
+ }
+ };
+
+ // Setup the redirects
+ hbProc.ErrorDataReceived += new DataReceivedEventHandler(HbProcErrorDataReceived);
+ hbProc.OutputDataReceived += new DataReceivedEventHandler(HbProcOutputDataReceived);
+
+ // Start the process
+ hbProc.Start();
+
+ // Set the Process Priority
+ switch (Properties.Settings.Default.processPriority)
+ {
+ case "Realtime":
+ hbProc.PriorityClass = ProcessPriorityClass.RealTime;
+ break;
+ case "High":
+ hbProc.PriorityClass = ProcessPriorityClass.High;
+ break;
+ case "Above Normal":
+ hbProc.PriorityClass = ProcessPriorityClass.AboveNormal;
+ break;
+ case "Normal":
+ hbProc.PriorityClass = ProcessPriorityClass.Normal;
+ break;
+ case "Low":
+ hbProc.PriorityClass = ProcessPriorityClass.Idle;
+ break;
+ default:
+ hbProc.PriorityClass = ProcessPriorityClass.BelowNormal;
+ break;
+ }
+
+ // Set the class items
+ HbProcess = hbProc;
+ ProcessID = hbProc.Id;
+ ProcessHandle = hbProc.Handle;
+
+ }
+ catch (Exception exc)
+ {
+ Console.WriteLine(exc);
+ }
+ }
+
+ /// <summary>
/// Kill the CLI process
/// </summary>
public void Stop()
@@ -138,10 +217,53 @@ namespace Handbrake.EncodeQueue
}
/// <summary>
+ /// Attempt to Safely kill a DirectRun() CLI
+ /// NOTE: This will not work with a MinGW CLI
+ /// Note: http://www.cygwin.com/ml/cygwin/2006-03/msg00330.html
+ /// </summary>
+ public void SafelyClose()
+ {
+ if ((int)ProcessHandle == 0)
+ return;
+
+ // Allow the CLI to exit cleanly
+ Win32.SetForegroundWindow((int)ProcessHandle);
+ SendKeys.Send("^C");
+
+ // HbProcess.StandardInput.AutoFlush = true;
+ // HbProcess.StandardInput.WriteLine("^C");
+ }
+
+ /// <summary>
+ /// Recieve the Standard Error information and process it
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private static void HbProcErrorDataReceived(object sender, DataReceivedEventArgs e)
+ {
+ // TODO: Recieve the Log data and process it
+ throw new NotImplementedException();
+ }
+
+ /// <summary>
+ /// Standard Input Data Recieved from the CLI
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private static void HbProcOutputDataReceived(object sender, DataReceivedEventArgs e)
+ {
+ // TODO: Recieve the %, ETA, FPS etc and process it
+ throw new NotImplementedException();
+ }
+
+ /// <summary>
/// Perform an action after an encode. e.g a shutdown, standby, restart etc.
/// </summary>
protected void Finish()
{
+ if (EncodeEnded != null)
+ EncodeEnded(this, new EventArgs());
+
IsEncoding = false;
//Growl
diff --git a/win/C#/EncodeQueue/Queue.cs b/win/C#/EncodeQueue/Queue.cs
index 87db876df..664710ec6 100644
--- a/win/C#/EncodeQueue/Queue.cs
+++ b/win/C#/EncodeQueue/Queue.cs
@@ -21,27 +21,15 @@ namespace Handbrake.EncodeQueue
private readonly List<Job> queue = new List<Job>();
private int NextJobId;
- #region Event Handlers
- /// <summary>
- /// Fires when an encode job has been started.
- /// </summary>
- public event EventHandler NewJobStarted;
-
/// <summary>
/// Fires when a pause to the encode queue has been requested.
/// </summary>
public event EventHandler QueuePauseRequested;
/// <summary>
- /// Fires when an encode job has been completed.
- /// </summary>
- public event EventHandler CurrentJobCompleted;
-
- /// <summary>
/// Fires when the entire encode queue has completed.
/// </summary>
public event EventHandler QueueCompleted;
- #endregion
#region Queue
/// <summary>
@@ -329,9 +317,6 @@ namespace Handbrake.EncodeQueue
Run(query);
- if (NewJobStarted != null)
- NewJobStarted(this, new EventArgs());
-
HbProcess.WaitForExit();
AddCLIQueryToLog(encJob);
@@ -346,9 +331,6 @@ namespace Handbrake.EncodeQueue
if (Properties.Settings.Default.growlEncode)
GrowlCommunicator.Notify("Encode Completed", "Put down that cocktail...\nyour Handbrake encode is done.");
- if (CurrentJobCompleted != null)
- CurrentJobCompleted(this, new EventArgs());
-
while (PauseRequested) // Need to find a better way of doing this.
{
Thread.Sleep(2000);
diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs
index 8c92d7668..6e66f49a2 100644
--- a/win/C#/Functions/Main.cs
+++ b/win/C#/Functions/Main.cs
@@ -125,7 +125,7 @@ namespace Handbrake.Functions
/// Function which generates the filename and path automatically based on
/// the Source Name, DVD title and DVD Chapters
/// </summary>
- public static string AutoName(frmMain mainWindow) //ComboBox drpDvdtitle, string chapter_start, string chatper_end, string source, string dest, int format, Boolean chapters)
+ public static string AutoName(frmMain mainWindow)
{
string AutoNamePath = string.Empty;
if (mainWindow.drp_dvdtitle.Text != "Automatic")
diff --git a/win/C#/Functions/PresetLoader.cs b/win/C#/Functions/PresetLoader.cs
index 33a7c1267..f42e734eb 100644
--- a/win/C#/Functions/PresetLoader.cs
+++ b/win/C#/Functions/PresetLoader.cs
@@ -7,6 +7,7 @@
using System;
using System.Drawing;
using System.Windows.Forms;
+using Handbrake.Model;
namespace Handbrake.Functions
{
@@ -20,12 +21,8 @@ namespace Handbrake.Functions
/// <param name="presetQuery">The Parsed CLI Query</param>
/// <param name="name">Name of the preset</param>
/// <param name="pictureSettings">Save picture settings in the preset</param>
- public static void presetLoader(frmMain mainWindow, QueryParser presetQuery, string name, Boolean pictureSettings)
+ public static void LoadPreset(frmMain mainWindow, QueryParser presetQuery, string name, Boolean pictureSettings)
{
- // ---------------------------
- // Setup the GUI
- // ---------------------------
-
#region Source
// Reset some vaules to stock first to prevent errors.
mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked;
diff --git a/win/C#/Functions/QueryGenerator.cs b/win/C#/Functions/QueryGenerator.cs
index 3c15f7352..050e9b76c 100644
--- a/win/C#/Functions/QueryGenerator.cs
+++ b/win/C#/Functions/QueryGenerator.cs
@@ -17,12 +17,12 @@ namespace Handbrake.Functions
/// <summary>
/// Generates a full CLI query for either encoding or previe encoeds if duration and preview are defined.
/// </summary>
- /// <param name="mainWindow"></param>
- /// <param name="mode"></param>
- /// <param name="duration"></param>
- /// <param name="preview"></param>
- /// <returns></returns>
- public string GenerateCLIQuery(frmMain mainWindow, int mode, int duration, string preview)
+ /// <param name="mainWindow">The Main Window</param>
+ /// <param name="mode">What Mode. (Point to Point Encoding) Chapters, Seconds, Frames OR Preview Encode</param>
+ /// <param name="duration">time in seconds for preview mode</param>
+ /// <param name="preview"> --start-at-preview (int) </param>
+ /// <returns>CLI Query </returns>
+ public static string GenerateCLIQuery(frmMain mainWindow, int mode, int duration, string preview)
{
string query = "";
@@ -542,6 +542,11 @@ namespace Handbrake.Functions
return query;
}
+ /// <summary>
+ /// Return the CLI Mixdown name
+ /// </summary>
+ /// <param name="selectedAudio">GUI mixdown name</param>
+ /// <returns>CLI mixdown name</returns>
private static string GetMixDown(string selectedAudio)
{
switch (selectedAudio)
@@ -562,6 +567,12 @@ namespace Handbrake.Functions
return "auto";
}
}
+
+ /// <summary>
+ /// Get the CLI Audio Encoder name
+ /// </summary>
+ /// <param name="selectedEncoder">string The GUI Encode name</param>
+ /// <returns>string CLI encoder name</returns>
private static string GetAudioEncoder(string selectedEncoder)
{
switch (selectedEncoder)
@@ -580,6 +591,13 @@ namespace Handbrake.Functions
return "";
}
}
+
+ /// <summary>
+ /// Create a CSV file with the data from the Main Window Chapters tab
+ /// </summary>
+ /// <param name="mainWindow">Main Window</param>
+ /// <param name="filePathName">Path to save the csv file</param>
+ /// <returns>True if successful </returns>
private static Boolean ChapterCSVSave(frmMain mainWindow, string filePathName)
{
try
diff --git a/win/C#/Functions/QueryParser.cs b/win/C#/Functions/QueryParser.cs
index 60afe7bca..413f8fa4c 100644
--- a/win/C#/Functions/QueryParser.cs
+++ b/win/C#/Functions/QueryParser.cs
@@ -9,10 +9,11 @@ using System.Globalization;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Collections;
+using Handbrake.Model;
namespace Handbrake.Functions
{
- internal class QueryParser
+ public class QueryParser
{
private static readonly CultureInfo Culture = new CultureInfo("en-US", false);
@@ -365,7 +366,7 @@ namespace Handbrake.Functions
trackDRCvalues = drcValues.ToString().Replace("-D ", "").Split(',');
// Create new Audio Track Classes and store them in the ArrayList
- ArrayList AllAudioTrackInfo = new ArrayList();
+ ArrayList allAudioTrackInfo = new ArrayList();
for (int x = 0; x < encoderCount; x++)
{
AudioTrack track = new AudioTrack();
@@ -393,9 +394,9 @@ namespace Handbrake.Functions
if (trackDRCvalues.Length >= (x + 1)) // Audio DRC Values
track.DRC = trackDRCvalues[x].Trim();
- AllAudioTrackInfo.Add(track);
+ allAudioTrackInfo.Add(track);
}
- thisQuery.AudioInformation = AllAudioTrackInfo;
+ thisQuery.AudioInformation = allAudioTrackInfo;
// Subtitle Stuff
if (subtitles.Success)
@@ -431,6 +432,12 @@ namespace Handbrake.Functions
return thisQuery;
}
+
+ /// <summary>
+ /// Get the GUI equiv to a CLI mixdown
+ /// </summary>
+ /// <param name="mixdown"></param>
+ /// <returns></returns>
private static string GetMixDown(string mixdown)
{
switch (mixdown.Trim())
@@ -449,6 +456,12 @@ namespace Handbrake.Functions
return "Automatic";
}
}
+
+ /// <summary>
+ /// Get the GUI equiv to a CLI audio encoder
+ /// </summary>
+ /// <param name="audioEnc"></param>
+ /// <returns></returns>
private static string GetAudioEncoder(string audioEnc)
{
switch (audioEnc)
@@ -468,23 +481,4 @@ namespace Handbrake.Functions
}
}
}
-
- public class AudioTrack
- {
- public AudioTrack()
- {
- // Default Values
- Track = "Automatic";
- MixDown = "Automatic";
- SampleRate = "Auto";
- Bitrate = "Auto";
- DRC = "1";
- }
- public string Track { get; set; }
- public string MixDown { get; set; }
- public string Encoder { get; set; }
- public string Bitrate { get; set; }
- public string SampleRate { get; set; }
- public string DRC { get; set; }
- }
} \ No newline at end of file
diff --git a/win/C#/Functions/Scan.cs b/win/C#/Functions/Scan.cs
index 1aadf0afd..8395eeb28 100644
--- a/win/C#/Functions/Scan.cs
+++ b/win/C#/Functions/Scan.cs
@@ -15,40 +15,79 @@ namespace Handbrake.Functions
{
public class Scan
{
- private DVD _thisDvd;
- private Parser _readData;
- private Process _hbProc;
- private string _scanProgress;
+ private DVD ThisDvd;
+ private Parser ReadData;
+ private Process HbProc;
+ private string ScanProgress;
+
+ /// <summary>
+ /// Scan has Started
+ /// </summary>
public event EventHandler ScanStared;
+
+ /// <summary>
+ /// Scan has completed
+ /// </summary>
public event EventHandler ScanCompleted;
+
+ /// <summary>
+ /// Scan process has changed to a new title
+ /// </summary>
public event EventHandler ScanStatusChanged;
+ /// <summary>
+ /// Scan a Source Path.
+ /// Title 0: scan all
+ /// </summary>
+ /// <param name="sourcePath">Path to the file to scan</param>
+ /// <param name="title">int title number. 0 for scan all</param>
public void ScanSource(string sourcePath, int title)
{
Thread t = new Thread(unused => RunScan(sourcePath, title));
t.Start();
}
+ /// <summary>
+ /// Object containing the information parsed in the scan.
+ /// </summary>
+ /// <returns></returns>
public DVD SouceData()
{
- return _thisDvd;
+ return ThisDvd;
}
+ /// <summary>
+ /// Raw log output from HandBrake CLI
+ /// </summary>
+ /// <returns></returns>
public String LogData()
{
- return _readData.Buffer;
+ return ReadData.Buffer;
}
+ /// <summary>
+ /// Progress of the scan.
+ /// </summary>
+ /// <returns></returns>
public String ScanStatus()
{
- return _scanProgress;
+ return ScanProgress;
}
+ /// <summary>
+ /// The Scan Process
+ /// </summary>
+ /// <returns></returns>
public Process ScanProcess()
{
- return _hbProc;
+ return HbProc;
}
+ /// <summary>
+ /// Start a scan for a given source path and title
+ /// </summary>
+ /// <param name="sourcePath"></param>
+ /// <param name="title"></param>
private void RunScan(object sourcePath, int title)
{
try
@@ -68,7 +107,7 @@ namespace Handbrake.Functions
if (Properties.Settings.Default.noDvdNav)
dvdnav = " --no-dvdnav";
- _hbProc = new Process
+ HbProc = new Process
{
StartInfo =
{
@@ -80,15 +119,15 @@ namespace Handbrake.Functions
CreateNoWindow = true
}
};
- _hbProc.Start();
+ HbProc.Start();
- _readData = new Parser(_hbProc.StandardError.BaseStream);
- _readData.OnScanProgress += new ScanProgressEventHandler(OnScanProgress);
- _thisDvd = DVD.Parse(_readData);
+ ReadData = new Parser(HbProc.StandardError.BaseStream);
+ ReadData.OnScanProgress += new ScanProgressEventHandler(OnScanProgress);
+ ThisDvd = DVD.Parse(ReadData);
// Write the Buffer out to file.
StreamWriter scanLog = new StreamWriter(dvdInfoPath);
- scanLog.Write(_readData.Buffer);
+ scanLog.Write(ReadData.Buffer);
scanLog.Flush();
scanLog.Close();
@@ -101,9 +140,15 @@ namespace Handbrake.Functions
}
}
+ /// <summary>
+ /// Fire an event when the scan process progresses
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="currentTitle"></param>
+ /// <param name="titleCount"></param>
private void OnScanProgress(object sender, int currentTitle, int titleCount)
{
- _scanProgress = string.Format("Processing Title: {0} of {1}", currentTitle, titleCount);
+ ScanProgress = string.Format("Processing Title: {0} of {1}", currentTitle, titleCount);
if (ScanStatusChanged != null)
ScanStatusChanged(this, new EventArgs());
}
diff --git a/win/C#/HandBrakeCS.csproj b/win/C#/HandBrakeCS.csproj
index 6123b2c73..f32223683 100644
--- a/win/C#/HandBrakeCS.csproj
+++ b/win/C#/HandBrakeCS.csproj
@@ -222,8 +222,9 @@
<Compile Include="frmActivityWindow.Designer.cs">
<DependentUpon>frmActivityWindow.cs</DependentUpon>
</Compile>
+ <Compile Include="Model\AudioTrack.cs" />
<Compile Include="Presets\Export.cs" />
- <Compile Include="Presets\Import.cs" />
+ <Compile Include="Presets\PlistPresetHandler.cs" />
<Compile Include="Presets\preset.cs" />
<Compile Include="Presets\PresetsHandler.cs" />
<Compile Include="EncodeQueue\Queue.cs" />
diff --git a/win/C#/Model/AudioTrack.cs b/win/C#/Model/AudioTrack.cs
new file mode 100644
index 000000000..822488b8e
--- /dev/null
+++ b/win/C#/Model/AudioTrack.cs
@@ -0,0 +1,57 @@
+/* AudioTrack.cs $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr>.
+ It may be used under the terms of the GNU General Public License. */
+
+namespace Handbrake.Model
+{
+ /// <summary>
+ /// An Audio Track for the Audio Panel
+ /// </summary>
+ public class AudioTrack
+ {
+ /// <summary>
+ /// Audio Track instance
+ /// </summary>
+ public AudioTrack()
+ {
+ // Default Values
+ Track = "Automatic";
+ MixDown = "Automatic";
+ SampleRate = "Auto";
+ Bitrate = "Auto";
+ DRC = "1";
+ }
+
+ /// <summary>
+ /// Audio Track Name
+ /// </summary>
+ public string Track { get; set; }
+
+ /// <summary>
+ /// Audio Mixdown
+ /// </summary>
+ public string MixDown { get; set; }
+
+ /// <summary>
+ /// Audio Encoder
+ /// </summary>
+ public string Encoder { get; set; }
+
+ /// <summary>
+ /// Audio Bitrate
+ /// </summary>
+ public string Bitrate { get; set; }
+
+ /// <summary>
+ /// Audio SampleRate
+ /// </summary>
+ public string SampleRate { get; set; }
+
+ /// <summary>
+ /// Dynamic Range Compression
+ /// </summary>
+ public string DRC { get; set; }
+ }
+}
diff --git a/win/C#/Presets/Export.cs b/win/C#/Presets/Export.cs
deleted file mode 100644
index a2facd1a6..000000000
--- a/win/C#/Presets/Export.cs
+++ /dev/null
@@ -1,177 +0,0 @@
-/* Export.cs $
-
- This file is part of the HandBrake source code.
- Homepage: <http://handbrake.fr/>.
- It may be used under the terms of the GNU General Public License. */
-
-using System;
-using System.Text;
-using System.Xml;
-
-namespace Handbrake.Presets
-{
- class Export
- {
- // WARNING This file is not complete!!!!!!
-
- // TODO
- // 1. Hookup all the widgets in the GUI so it exports real values.
- // 2. Check for any missing key/value pairs
- // 3. Test with MacGui / Cleanup code / Retest
-
- private XmlTextWriter writer;
-
- public void ExportMacPreset(string path)
- {
- writer = new XmlTextWriter("C:\\test.xml", Encoding.UTF8);
-
- // Header
- writer.WriteStartDocument();
- writer.WriteDocType("plist", "-//Apple//DTD PLIST 1.0//EN", @"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
-
- writer.WriteStartElement("plist");
- writer.WriteStartElement("array");
-
- // Add New Preset Here. Can write multiple presets here if required in future.
- WritePreset();
-
- // Footer
- writer.WriteEndElement();
- writer.WriteEndElement();
-
- writer.WriteEndDocument();
-
- // Closeout
- writer.Close();
- }
-
- // Primary function for writing dict.
- private void WritePreset()
- {
- writer.WriteStartElement("dict");
- AudioListArrayDict();
- AddEncodeSettings();
-
- writer.WriteEndElement();
- }
-
- // Add all the encode settings to the preset
- private void AddEncodeSettings()
- {
- AddEncodeElement("ChapterMarkers", "integer", "");
- AddEncodeElement("Default", "integer", "");
- AddEncodeElement("FileFormat", "String", "");
- AddBooleanElement("Folder", true);
- AddEncodeElement("Mp4HttpOptimize", "integer", "");
- AddEncodeElement("Mp4LargeFile", "integer", "");
- AddEncodeElement("Mp4iPodCompatible", "integer", "");
- AddEncodeElement("PictureAutoCrop", "integer", "");
- AddEncodeElement("PictureBottomCrop", "integer", "");
- AddEncodeElement("PictureDeblock", "integer", "");
- AddEncodeElement("PictureDecomb", "integer", "");
- AddEncodeElement("PictureDecombCustom", "string", "");
- AddEncodeElement("PictureDecombDeinterlace", "integer", "");
- AddEncodeElement("PictureDeinterlace", "integer", "");
- AddEncodeElement("PictureDeinterlaceCustom", "string", "");
- AddEncodeElement("PictureDenoise", "integer", "");
- AddEncodeElement("PictureDenoiseCustom", "string", "");
- AddEncodeElement("PictureDetelecine", "integer", "");
- AddEncodeElement("PictureDetelecineCustom", "string", "");
- AddEncodeElement("PictureHeight", "integer", "");
- AddEncodeElement("PictureKeepRatio", "integer", "");
- AddEncodeElement("PictureLeftCrop", "integer", "");
- AddEncodeElement("PicturePAR", "integer", "");
- AddEncodeElement("PictureRightCrop", "integer", "");
- AddEncodeElement("PictureTopCrop", "integer", "");
- AddEncodeElement("PictureWidth", "integer", "");
- AddEncodeElement("PresetBuildNumber", "string", "");
- AddEncodeElement("PresetDescription", "string", "");
- AddEncodeElement("PresetName", "string", "");
- AddEncodeElement("Type", "integer", "");
- AddEncodeElement("UsesMaxPictureSettings", "integer", "");
- AddEncodeElement("UsesPictureFilters", "integer", "");
- AddEncodeElement("UsesPictureSettings", "integer", "");
- AddEncodeElement("VideoAvgBitrate", "string", "");
- AddEncodeElement("VideoEncoder", "string", "");
- AddEncodeElement("VideoFramerate", "string", "");
- AddEncodeElement("VideoGrayScale", "integer", "");
- AddEncodeElement("VideoQualitySlider", "real", "");
- AddEncodeElement("VideoQualityType", "integer", "");
- AddEncodeElement("VideoTargetSize", "string", "");
- AddEncodeElement("VideoTurboTwoPass", "integer", "");
- AddEncodeElement("VideoTwoPass", "integer", "");
- AddEncodeElement("x264Option", "string", "");
- }
-
- // Add Preset setting + value
- private void AddBooleanElement(string keyName, Boolean value)
- {
- writer.WriteStartElement("key");
- writer.WriteString(keyName);
- writer.WriteEndElement();
- if (value)
- {
- writer.WriteStartElement("true");
- writer.WriteEndElement();
- }
- else
- {
- writer.WriteStartElement("false");
- writer.WriteEndElement();
- }
- }
- private void AddEncodeElement(string keyName, string type, string value)
- {
- writer.WriteElementString("key", keyName);
- writer.WriteElementString(type, value);
- }
-
- // Add List of audio tracks
- private void AudioListArrayDict()
- {
- writer.WriteStartElement("key");
- writer.WriteString("AudioList");
- writer.WriteEndElement();
-
- writer.WriteStartElement("array");
- AddAudioItem();
- AddAudioItem();
- writer.WriteEndElement();
- }
- private void AddAudioItem()
- {
- int bitrate = 448;
- string encoder = "AC3 Passthru";
- string mixdown = "AC3 Passthru";
- string sample = "Auto";
- int track = 1;
- double drc = 0.0;
- string desc = "English (AC3) (5.1 ch)";
-
- writer.WriteStartElement("dict");
-
- writer.WriteElementString("key", "AudioBitrate");
- writer.WriteElementString("string", bitrate.ToString());
-
- writer.WriteElementString("key", "AudioEncoder");
- writer.WriteElementString("string", encoder);
-
- writer.WriteElementString("key", "AudioMixdown");
- writer.WriteElementString("string", mixdown);
-
- writer.WriteElementString("key", "AudioSamplerate");
- writer.WriteElementString("string", sample);
-
- writer.WriteElementString("key", "AudioTrack");
- writer.WriteElementString("integer", track.ToString());
-
- writer.WriteElementString("key", "AudioTrackDRCSlider");
- writer.WriteElementString("real", drc.ToString());
-
- writer.WriteElementString("key", "AudioTrackDescription");
- writer.WriteElementString("string", desc);
-
- writer.WriteEndElement();
- }
- }
-} \ No newline at end of file
diff --git a/win/C#/Presets/Import.cs b/win/C#/Presets/PlistPresetHandler.cs
index 8b39662bc..871ef38a8 100644
--- a/win/C#/Presets/Import.cs
+++ b/win/C#/Presets/PlistPresetHandler.cs
@@ -1,15 +1,38 @@
-using System;
+/* PlistPresetHandler.cs $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr/>.
+ It may be used under the terms of the GNU General Public License. */
+
+using System;
using System.IO;
+using System.Text;
using System.Xml;
using System.Windows.Forms;
using System.Collections;
using Handbrake.Functions;
+using Handbrake.Model;
namespace Handbrake.Presets
{
- class Import
+ public class PlistPresetHandler
{
- public QueryParser importMacPreset(string filename)
+ /* WARNING This file is not complete!!!!!!
+ *
+ * TODO
+ * 1. Hookup all the widgets in the GUI so it exports real values.
+ * 2. Check for any missing key/value pairs
+ * 3. Test with MacGui / Cleanup code / Retest
+ */
+
+ private XmlTextWriter Writer;
+
+ /// <summary>
+ /// Import a Plist preset generated by the Mac or Linux GUI
+ /// </summary>
+ /// <param name="filename"></param>
+ /// <returns></returns>
+ public static QueryParser Import(string filename)
{
XmlNode root = null;
try
@@ -269,6 +292,182 @@ namespace Handbrake.Presets
return queryParsed;
}
- // --- It's the end of the road
+ /// <summary>
+ /// Export a preset to a Plist file readable by the Mac and Linux GUI's
+ /// </summary>
+ /// <param name="path"></param>
+ public void Export(string path)
+ {
+ Writer = new XmlTextWriter("C:\\test.xml", Encoding.UTF8);
+
+ // Header
+ Writer.WriteStartDocument();
+ Writer.WriteDocType("plist", "-//Apple//DTD PLIST 1.0//EN", @"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
+
+ Writer.WriteStartElement("plist");
+ Writer.WriteStartElement("array");
+
+ // Add New Preset Here. Can write multiple presets here if required in future.
+ WritePreset();
+
+ // Footer
+ Writer.WriteEndElement();
+ Writer.WriteEndElement();
+
+ Writer.WriteEndDocument();
+
+ // Closeout
+ Writer.Close();
+ }
+
+ /// <summary>
+ /// Write a Plist file
+ /// </summary>
+ private void WritePreset()
+ {
+ Writer.WriteStartElement("dict");
+ AudioListArrayDict();
+ AddEncodeSettings();
+
+ Writer.WriteEndElement();
+ }
+
+ /// <summary>
+ /// Add all the encode settings to the preset
+ /// </summary>
+ private void AddEncodeSettings()
+ {
+ AddEncodeElement("ChapterMarkers", "integer", "");
+ AddEncodeElement("Default", "integer", "");
+ AddEncodeElement("FileFormat", "String", "");
+ AddBooleanElement("Folder", true);
+ AddEncodeElement("Mp4HttpOptimize", "integer", "");
+ AddEncodeElement("Mp4LargeFile", "integer", "");
+ AddEncodeElement("Mp4iPodCompatible", "integer", "");
+ AddEncodeElement("PictureAutoCrop", "integer", "");
+ AddEncodeElement("PictureBottomCrop", "integer", "");
+ AddEncodeElement("PictureDeblock", "integer", "");
+ AddEncodeElement("PictureDecomb", "integer", "");
+ AddEncodeElement("PictureDecombCustom", "string", "");
+ AddEncodeElement("PictureDecombDeinterlace", "integer", "");
+ AddEncodeElement("PictureDeinterlace", "integer", "");
+ AddEncodeElement("PictureDeinterlaceCustom", "string", "");
+ AddEncodeElement("PictureDenoise", "integer", "");
+ AddEncodeElement("PictureDenoiseCustom", "string", "");
+ AddEncodeElement("PictureDetelecine", "integer", "");
+ AddEncodeElement("PictureDetelecineCustom", "string", "");
+ AddEncodeElement("PictureHeight", "integer", "");
+ AddEncodeElement("PictureKeepRatio", "integer", "");
+ AddEncodeElement("PictureLeftCrop", "integer", "");
+ AddEncodeElement("PicturePAR", "integer", "");
+ AddEncodeElement("PictureRightCrop", "integer", "");
+ AddEncodeElement("PictureTopCrop", "integer", "");
+ AddEncodeElement("PictureWidth", "integer", "");
+ AddEncodeElement("PresetBuildNumber", "string", "");
+ AddEncodeElement("PresetDescription", "string", "");
+ AddEncodeElement("PresetName", "string", "");
+ AddEncodeElement("Type", "integer", "");
+ AddEncodeElement("UsesMaxPictureSettings", "integer", "");
+ AddEncodeElement("UsesPictureFilters", "integer", "");
+ AddEncodeElement("UsesPictureSettings", "integer", "");
+ AddEncodeElement("VideoAvgBitrate", "string", "");
+ AddEncodeElement("VideoEncoder", "string", "");
+ AddEncodeElement("VideoFramerate", "string", "");
+ AddEncodeElement("VideoGrayScale", "integer", "");
+ AddEncodeElement("VideoQualitySlider", "real", "");
+ AddEncodeElement("VideoQualityType", "integer", "");
+ AddEncodeElement("VideoTargetSize", "string", "");
+ AddEncodeElement("VideoTurboTwoPass", "integer", "");
+ AddEncodeElement("VideoTwoPass", "integer", "");
+ AddEncodeElement("x264Option", "string", "");
+ }
+
+ /// <summary>
+ /// Add Preset setting + value
+ /// </summary>
+ /// <param name="keyName"></param>
+ /// <param name="value"></param>
+ private void AddBooleanElement(string keyName, Boolean value)
+ {
+ Writer.WriteStartElement("key");
+ Writer.WriteString(keyName);
+ Writer.WriteEndElement();
+ if (value)
+ {
+ Writer.WriteStartElement("true");
+ Writer.WriteEndElement();
+ }
+ else
+ {
+ Writer.WriteStartElement("false");
+ Writer.WriteEndElement();
+ }
+ }
+
+ /// <summary>
+ /// Add Preset setting + value
+ /// </summary>
+ /// <param name="keyName"></param>
+ /// <param name="type"></param>
+ /// <param name="value"></param>
+ private void AddEncodeElement(string keyName, string type, string value)
+ {
+ Writer.WriteElementString("key", keyName);
+ Writer.WriteElementString(type, value);
+ }
+
+ /// <summary>
+ /// Add List of audio tracks
+ /// </summary>
+ private void AudioListArrayDict()
+ {
+ Writer.WriteStartElement("key");
+ Writer.WriteString("AudioList");
+ Writer.WriteEndElement();
+
+ Writer.WriteStartElement("array");
+ AddAudioItem();
+ AddAudioItem();
+ Writer.WriteEndElement();
+ }
+
+ /// <summary>
+ /// Add List of audio tracks
+ /// </summary>
+ private void AddAudioItem()
+ {
+ int bitrate = 448;
+ string encoder = "AC3 Passthru";
+ string mixdown = "AC3 Passthru";
+ string sample = "Auto";
+ int track = 1;
+ double drc = 0.0;
+ string desc = "English (AC3) (5.1 ch)";
+
+ Writer.WriteStartElement("dict");
+
+ Writer.WriteElementString("key", "AudioBitrate");
+ Writer.WriteElementString("string", bitrate.ToString());
+
+ Writer.WriteElementString("key", "AudioEncoder");
+ Writer.WriteElementString("string", encoder);
+
+ Writer.WriteElementString("key", "AudioMixdown");
+ Writer.WriteElementString("string", mixdown);
+
+ Writer.WriteElementString("key", "AudioSamplerate");
+ Writer.WriteElementString("string", sample);
+
+ Writer.WriteElementString("key", "AudioTrack");
+ Writer.WriteElementString("integer", track.ToString());
+
+ Writer.WriteElementString("key", "AudioTrackDRCSlider");
+ Writer.WriteElementString("real", drc.ToString());
+
+ Writer.WriteElementString("key", "AudioTrackDescription");
+ Writer.WriteElementString("string", desc);
+
+ Writer.WriteEndElement();
+ }
}
} \ No newline at end of file
diff --git a/win/C#/Presets/preset.cs b/win/C#/Presets/Preset.cs
index 088d39c85..088d39c85 100644
--- a/win/C#/Presets/preset.cs
+++ b/win/C#/Presets/Preset.cs
diff --git a/win/C#/Presets/PresetsHandler.cs b/win/C#/Presets/PresetsHandler.cs
index a26538b73..155086b52 100644
--- a/win/C#/Presets/PresetsHandler.cs
+++ b/win/C#/Presets/PresetsHandler.cs
@@ -16,24 +16,24 @@ namespace Handbrake.Presets
{
public class PresetsHandler
{
- List<Preset> _presets = new List<Preset>();
- List<Preset> _userPresets = new List<Preset>();
+ List<Preset> Presets = new List<Preset>();
+ List<Preset> UserPresets = new List<Preset>();
private static readonly XmlSerializer Ser = new XmlSerializer(typeof(List<Preset>));
- readonly string _userPresetFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\user_presets.xml";
- readonly string _hbPresetFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\presets.xml";
+ readonly string UserPresetFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\user_presets.xml";
+ readonly string HbPresetFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\presets.xml";
/// <summary>
/// Add a new preset to the system
/// </summary>
/// <param name="presetName">String, The name of the new preset</param>
/// <param name="query">String, the CLI query for the new preset</param>
- /// <param name="pictureSettings"> Bool, store crop/picture sizes in the _presets</param>
+ /// <param name="pictureSettings"> Bool, store crop/picture sizes in the Presets</param>
public Boolean Add(string presetName, string query, Boolean pictureSettings)
{
if (CheckIfPresetExists(presetName) == false)
{
Preset newPreset = new Preset { Name = presetName, Query = query, PictureSettings = pictureSettings, Version = Properties.Settings.Default.hb_version };
- _userPresets.Add(newPreset);
+ UserPresets.Add(newPreset);
UpdatePresetFiles();
return true;
}
@@ -50,36 +50,36 @@ namespace Handbrake.Presets
List<Preset> newUserPresets = new List<Preset>();
// Built In Presets
- foreach (Preset item in _presets)
+ foreach (Preset item in Presets)
{
if (item.Name != name)
{
newPresets.Add(item);
}
}
- _presets = newPresets;
+ Presets = newPresets;
// User Presets
- foreach (Preset item in _userPresets)
+ foreach (Preset item in UserPresets)
{
if (item.Name != name)
{
newUserPresets.Add(item);
}
}
- _userPresets = newUserPresets;
+ UserPresets = newUserPresets;
- // Rebuild the _userPresets.xml file
+ // Rebuild the UserPresets.xml file
UpdatePresetFiles();
UpdatePresetFiles();
}
/// <summary>
- /// Remove all built in _presets;
+ /// Remove all built in Presets;
/// </summary>
public void RemoveBuiltInPresets()
{
- _presets.Clear();
+ Presets.Clear();
UpdatePresetFiles();
}
@@ -92,7 +92,7 @@ namespace Handbrake.Presets
public void Update(string presetName, string query, Boolean pictureSettings)
{
// User Presets
- foreach (Preset item in _userPresets)
+ foreach (Preset item in UserPresets)
{
if (item.Name == presetName)
{
@@ -112,14 +112,14 @@ namespace Handbrake.Presets
public Preset GetPreset(string name)
{
// Built In Presets
- foreach (Preset item in _presets)
+ foreach (Preset item in Presets)
{
if (item.Name == name)
return item;
}
// User Presets
- foreach (Preset item in _userPresets)
+ foreach (Preset item in UserPresets)
{
if (item.Name == name)
return item;
@@ -133,7 +133,7 @@ namespace Handbrake.Presets
/// </summary>
public void UpdateBuiltInPresets()
{
- // Create a new tempory file and execute the CLI to get the built in _presets.
+ // Create a new tempory file and execute the CLI to get the built in Presets.
string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");
string presetsPath = Path.Combine(Path.GetTempPath(), "temp_presets.dat");
string strCmdLine = String.Format(@"cmd /c """"{0}"" --preset-list >""{1}"" 2>&1""", handbrakeCLIPath, presetsPath);
@@ -147,8 +147,8 @@ namespace Handbrake.Presets
hbproc.Close();
}
- // Clear the current built in _presets and now parse the tempory _presets file.
- _presets.Clear();
+ // Clear the current built in Presets and now parse the tempory Presets file.
+ Presets.Clear();
if (File.Exists(presetsPath))
{
@@ -179,33 +179,33 @@ namespace Handbrake.Presets
Version = Properties.Settings.Default.hb_version,
PictureSettings = pic
};
- _presets.Add(newPreset);
+ Presets.Add(newPreset);
}
}
presetInput.Close();
presetInput.Dispose();
}
- // Finally, Create a new or update the current _presets.xml file
+ // Finally, Create a new or update the current Presets.xml file
UpdatePresetFiles();
}
/// <summary>
- /// Load in the preset data from _presets.xml and _userPresets.xml
- /// Load it into the 2 arraylist's _presets and _userPresets
+ /// Load in the preset data from Presets.xml and UserPresets.xml
+ /// Load it into the 2 arraylist's Presets and UserPresets
/// </summary>
private void LoadPresetData()
{
- // First clear the _presets arraylists
- _presets.Clear();
- _userPresets.Clear();
+ // First clear the Presets arraylists
+ Presets.Clear();
+ UserPresets.Clear();
try
{
- // Load in the users _presets from _userPresets.xml
- if (File.Exists(_hbPresetFile))
+ // Load in the users Presets from UserPresets.xml
+ if (File.Exists(HbPresetFile))
{
- using (FileStream strm = new FileStream(_hbPresetFile, FileMode.Open, FileAccess.Read))
+ using (FileStream strm = new FileStream(HbPresetFile, FileMode.Open, FileAccess.Read))
{
if (strm.Length != 0)
{
@@ -213,7 +213,7 @@ namespace Handbrake.Presets
if (list != null)
foreach (Preset preset in list)
- _presets.Add(preset);
+ Presets.Add(preset);
}
}
}
@@ -222,16 +222,16 @@ namespace Handbrake.Presets
{
MessageBox.Show(
"HandBrakes preset file appears to have been corrupted. This file will now be re-generated!\n" +
- "If the problem presists, please delete the file: \n\n" + _hbPresetFile, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ "If the problem presists, please delete the file: \n\n" + HbPresetFile, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
UpdateBuiltInPresets();
}
try
{
- // Load in the users _presets from _userPresets.xml
- if (File.Exists(_userPresetFile))
+ // Load in the users Presets from UserPresets.xml
+ if (File.Exists(UserPresetFile))
{
- using (FileStream strm = new FileStream(_userPresetFile, FileMode.Open, FileAccess.Read))
+ using (FileStream strm = new FileStream(UserPresetFile, FileMode.Open, FileAccess.Read))
{
if (strm.Length != 0)
{
@@ -239,7 +239,7 @@ namespace Handbrake.Presets
if (list != null)
foreach (Preset preset in list)
- _userPresets.Add(preset);
+ UserPresets.Add(preset);
}
}
}
@@ -250,16 +250,16 @@ namespace Handbrake.Presets
"Your User presets file appears to have been corrupted.\n" +
"Your presets will not be loaded. You may need to re-create your presets.\n\n" +
"Your user presets file has been renamed to 'user_presets.xml.old' and is located in:\n " +
- Path.GetDirectoryName(_userPresetFile) + "\n" +
+ Path.GetDirectoryName(UserPresetFile) + "\n" +
"You may be able to recover some presets if you know the XML language.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
// Recover from Error.
- if (File.Exists(_userPresetFile))
+ if (File.Exists(UserPresetFile))
{
- string disabledFile = _userPresetFile + ".old";
+ string disabledFile = UserPresetFile + ".old";
if (File.Exists(disabledFile))
File.Delete(disabledFile);
- File.Move(_userPresetFile, disabledFile);
+ File.Move(UserPresetFile, disabledFile);
}
}
@@ -276,10 +276,10 @@ namespace Handbrake.Presets
string category = string.Empty;
TreeNode rootNode = null;
- if (_presets.Count != 0) // Built In Presets
+ if (Presets.Count != 0) // Built In Presets
{
- foreach (Preset preset in _presets)
+ foreach (Preset preset in Presets)
{
if (preset.Category != category)
{
@@ -294,7 +294,7 @@ namespace Handbrake.Presets
}
rootNode = null; category = null;
- foreach (Preset preset in _userPresets) // User Presets
+ foreach (Preset preset in UserPresets) // User Presets
{
if (preset.Category != category && preset.Category != null)
{
@@ -317,16 +317,16 @@ namespace Handbrake.Presets
{
try
{
- using (FileStream strm = new FileStream(_hbPresetFile, FileMode.Create, FileAccess.Write))
+ using (FileStream strm = new FileStream(HbPresetFile, FileMode.Create, FileAccess.Write))
{
- Ser.Serialize(strm, _presets);
+ Ser.Serialize(strm, Presets);
strm.Close();
strm.Dispose();
}
- using (FileStream strm = new FileStream(_userPresetFile, FileMode.Create, FileAccess.Write))
+ using (FileStream strm = new FileStream(UserPresetFile, FileMode.Create, FileAccess.Write))
{
- Ser.Serialize(strm, _userPresets);
+ Ser.Serialize(strm, UserPresets);
strm.Close();
strm.Dispose();
}
@@ -338,7 +338,7 @@ namespace Handbrake.Presets
}
/// <summary>
- /// Check if the preset "name" exists in either _presets or _userPresets lists.
+ /// Check if the preset "name" exists in either Presets or UserPresets lists.
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
@@ -348,14 +348,14 @@ namespace Handbrake.Presets
return true;
// Built In Presets
- foreach (Preset item in _presets)
+ foreach (Preset item in Presets)
{
if (item.Name == name)
return true;
}
// User Presets
- foreach (Preset item in _userPresets)
+ foreach (Preset item in UserPresets)
{
if (item.Name == name)
return true;
@@ -365,7 +365,7 @@ namespace Handbrake.Presets
}
/// <summary>
- /// Check if the user preset "name" exists in _userPresets list.
+ /// Check if the user preset "name" exists in UserPresets list.
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
@@ -375,7 +375,7 @@ namespace Handbrake.Presets
return false;
// User Presets
- foreach (Preset item in _userPresets)
+ foreach (Preset item in UserPresets)
{
if (item.Name == name)
return true;
@@ -385,16 +385,16 @@ namespace Handbrake.Presets
}
/// <summary>
- /// Check if the built in _presets stored are not out of date.
+ /// Check if the built in Presets stored are not out of date.
/// Update them if they are.
/// </summary>
/// <returns></returns>
public Boolean CheckIfPresetsAreOutOfDate()
{
LoadPresetData();
- // Update built-in _presets if the built-in _presets belong to an older version.
- if (_presets.Count != 0)
- if (_presets[0].Version != Properties.Settings.Default.hb_version)
+ // Update built-in Presets if the built-in Presets belong to an older version.
+ if (Presets.Count != 0)
+ if (Presets[0].Version != Properties.Settings.Default.hb_version)
{
UpdateBuiltInPresets();
return true;
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs
index 2f8c1c142..103c28edb 100644
--- a/win/C#/frmMain.cs
+++ b/win/C#/frmMain.cs
@@ -24,7 +24,6 @@ namespace Handbrake
// Objects which may be used by one or more other objects *************
Queue encodeQueue = new Queue();
PresetsHandler presetHandler = new PresetsHandler();
- QueryGenerator queryGen = new QueryGenerator();
// Globals: Mainly used for tracking. *********************************
public Title selectedTitle;
@@ -114,7 +113,7 @@ namespace Handbrake
x264Panel.reset2Defaults();
QueryParser presetQuery = QueryParser.Parse(query);
- PresetLoader.presetLoader(this, presetQuery, Properties.Settings.Default.defaultPreset, loadPictureSettings);
+ PresetLoader.LoadPreset(this, presetQuery, Properties.Settings.Default.defaultPreset, loadPictureSettings);
x264Panel.X264_StandardizeOptString();
x264Panel.X264_SetCurrentSettingsInPanel();
@@ -222,9 +221,10 @@ namespace Handbrake
this.Resize += new EventHandler(frmMain_Resize);
// Handle Encode Start / Finish / Pause
- encodeQueue.CurrentJobCompleted += new EventHandler(encodeEnded);
+
encodeQueue.QueuePauseRequested += new EventHandler(encodePaused);
- encodeQueue.NewJobStarted += new EventHandler(encodeStarted);
+ encodeQueue.EncodeStarted += new EventHandler(encodeStarted);
+ encodeQueue.EncodeEnded += new EventHandler(encodeEnded);
// Handle a file being draged onto the GUI.
this.DragEnter += new DragEventHandler(frmMain_DragEnter);
@@ -396,7 +396,7 @@ namespace Handbrake
}
private void btn_new_preset_Click(object sender, EventArgs e)
{
- Form preset = new frmAddPreset(this, queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), presetHandler);
+ Form preset = new frmAddPreset(this, QueryGenerator.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), presetHandler);
preset.ShowDialog();
}
#endregion
@@ -602,7 +602,7 @@ namespace Handbrake
QueryParser presetQuery = QueryParser.Parse(query);
// Now load the preset
- PresetLoader.presetLoader(this, presetQuery, presetName, loadPictureSettings);
+ PresetLoader.LoadPreset(this, presetQuery, presetName, loadPictureSettings);
// The x264 widgets will need updated, so do this now:
x264Panel.X264_StandardizeOptString();
@@ -628,27 +628,26 @@ namespace Handbrake
}
private void importPreset()
{
- Import imp = new Import();
if (openPreset.ShowDialog() == DialogResult.OK)
{
- QueryParser parsed = imp.importMacPreset(openPreset.FileName);
+ QueryParser parsed = PlistPresetHandler.Import(openPreset.FileName);
if (presetHandler.CheckIfUserPresetExists(parsed.PresetName + " (Imported)"))
{
DialogResult result = MessageBox.Show("This preset appears to already exist. Would you like to overwrite it?", "Overwrite preset?",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result == DialogResult.Yes)
{
- PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);
- presetHandler.Update(parsed.PresetName + " (Imported)", queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null),
+ PresetLoader.LoadPreset(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);
+ presetHandler.Update(parsed.PresetName + " (Imported)", QueryGenerator.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null),
parsed.UsesPictureSettings);
}
}
else
{
- PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);
- presetHandler.Add(parsed.PresetName, queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), parsed.UsesPictureSettings);
+ PresetLoader.LoadPreset(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);
+ presetHandler.Add(parsed.PresetName, QueryGenerator.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), parsed.UsesPictureSettings);
- if (presetHandler.Add(parsed.PresetName + " (Imported)", queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), parsed.UsesPictureSettings))
+ if (presetHandler.Add(parsed.PresetName + " (Imported)", QueryGenerator.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), parsed.UsesPictureSettings))
{
TreeNode preset_treeview = new TreeNode(parsed.PresetName + " (Imported)") { ForeColor = Color.Black };
treeView_presets.Nodes.Add(preset_treeview);
@@ -671,11 +670,16 @@ namespace Handbrake
{
DialogResult result;
if (Properties.Settings.Default.enocdeStatusInGui && !Properties.Settings.Default.showCliForInGuiEncodeStatus)
- 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. ",
- "Cancel Encode?",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
+ {
+ 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. ",
+ "Cancel Encode?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
+ }
else
+ {
result = MessageBox.Show("Are you sure you wish to cancel the encode?", "Cancel Encode?",
- MessageBoxButtons.YesNo, MessageBoxIcon.Question);
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question);
+ }
if (result == DialogResult.Yes)
{
@@ -690,9 +694,7 @@ namespace Handbrake
}
else
{
- // Allow the CLI to exit cleanly
- Win32.SetForegroundWindow((int) encodeQueue.ProcessHandle);
- SendKeys.Send("^C");
+ encodeQueue.SafelyClose();
}
// Update the GUI
@@ -703,8 +705,8 @@ namespace Handbrake
{
if (encodeQueue.Count != 0 || (!string.IsNullOrEmpty(sourcePath) && !string.IsNullOrEmpty(text_destination.Text)))
{
- string generatedQuery = queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);
- string specifiedQuery = rtf_query.Text != "" ? rtf_query.Text : queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);
+ string generatedQuery = QueryGenerator.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);
+ string specifiedQuery = rtf_query.Text != "" ? rtf_query.Text : QueryGenerator.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);
string query = string.Empty;
// Check to make sure the generated query matches the GUI settings
@@ -773,7 +775,7 @@ namespace Handbrake
MessageBox.Show("No source or destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
else
{
- String query = queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);
+ String query = QueryGenerator.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);
if (rtf_query.Text != "")
query = rtf_query.Text;
@@ -1488,7 +1490,7 @@ namespace Handbrake
// Query Editor Tab
private void btn_generate_Query_Click(object sender, EventArgs e)
{
- rtf_query.Text = queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);
+ rtf_query.Text = QueryGenerator.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);
}
private void btn_clear_Click(object sender, EventArgs e)
{
@@ -1682,7 +1684,7 @@ namespace Handbrake
QueryParser presetQuery = QueryParser.Parse(query);
// Now load the preset
- PresetLoader.presetLoader(this, presetQuery, "Load Back From Queue", true);
+ PresetLoader.LoadPreset(this, presetQuery, "Load Back From Queue", true);
// The x264 widgets will need updated, so do this now:
x264Panel.X264_StandardizeOptString();
diff --git a/win/C#/frmPreview.cs b/win/C#/frmPreview.cs
index 6118b43da..840975bb6 100644
--- a/win/C#/frmPreview.cs
+++ b/win/C#/frmPreview.cs
@@ -13,7 +13,6 @@ namespace Handbrake
{
public partial class frmPreview : Form
{
- readonly QueryGenerator HbCommonFunc = new QueryGenerator();
readonly Queue Process = new Queue();
private delegate void UpdateUIHandler();
String CurrentlyPlaying = "";
@@ -63,7 +62,7 @@ namespace Handbrake
lbl_status.Text = "Encoding Sample for (VLC) ...";
int duration;
int.TryParse(cb_duration.Text, out duration);
- String query = HbCommonFunc.GenerateCLIQuery(MainWindow, 3, duration, cb_preview.Text);
+ String query = QueryGenerator.GenerateCLIQuery(MainWindow, 3, duration, cb_preview.Text);
ThreadPool.QueueUserWorkItem(ProcMonitor, query);
}
private void btn_playQT_Click(object sender, EventArgs e)
@@ -98,7 +97,7 @@ namespace Handbrake
lbl_status.Text = "Encoding Sample for (QT) ...";
int duration;
int.TryParse(cb_duration.Text, out duration);
- String query = HbCommonFunc.GenerateCLIQuery(MainWindow, 3, duration, cb_preview.Text);
+ String query = QueryGenerator.GenerateCLIQuery(MainWindow, 3, duration, cb_preview.Text);
ThreadPool.QueueUserWorkItem(ProcMonitor, query);
}
diff --git a/win/C#/frmQueue.cs b/win/C#/frmQueue.cs
index 739413cef..326fb7241 100644
--- a/win/C#/frmQueue.cs
+++ b/win/C#/frmQueue.cs
@@ -10,6 +10,7 @@ using System.ComponentModel;
using System.Windows.Forms;
using Handbrake.EncodeQueue;
using System.Collections.ObjectModel;
+using Handbrake.Model;
namespace Handbrake
{
@@ -26,7 +27,7 @@ namespace Handbrake
this.mainWindow = mw;
this.queue = q;
- queue.NewJobStarted += new EventHandler(QueueOnEncodeStart);
+ queue.EncodeStarted += new EventHandler(QueueOnEncodeStart);
queue.QueueCompleted += new EventHandler(QueueOnQueueFinished);
queue.QueuePauseRequested += new EventHandler(QueueOnPaused);
}
@@ -176,7 +177,7 @@ namespace Handbrake
// Display The Audio Track Information
string audio = string.Empty;
- foreach (Functions.AudioTrack track in parsed.AudioInformation)
+ foreach (AudioTrack track in parsed.AudioInformation)
{
if (audio != "")
audio += ", " + track.Encoder;
@@ -229,7 +230,7 @@ namespace Handbrake
// Display The Audio Track Information
string audio = string.Empty;
- foreach (Functions.AudioTrack track in parsed.AudioInformation)
+ foreach (AudioTrack track in parsed.AudioInformation)
{
if (audio != "")
audio += ", " + track.Encoder;