summaryrefslogtreecommitdiffstats
path: root/win/C#/Functions
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/C#/Functions
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/C#/Functions')
-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
5 files changed, 104 insertions, 50 deletions
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());
}