diff options
author | sr55 <[email protected]> | 2010-02-20 18:08:41 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2010-02-20 18:08:41 +0000 |
commit | b9d00019295781bed79eca280bac798b7bb7c64f (patch) | |
tree | 341aac9ec87d84d71be18a42afe0ee52ef497d3f /win/C#/Functions/Scan.cs | |
parent | e5d5bc94b2217a9eb65857d83d31138d126947e4 (diff) |
WinGui:
- Tied Microsoft StyleCop into the build process.
- Included a settings file for StyleCop so anyone who picks up the project can use the global project settings.
- Started Clearing up Warnings generated by stylecop.
- Also included Resharper 5 config files that users can use.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3129 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Functions/Scan.cs')
-rw-r--r-- | win/C#/Functions/Scan.cs | 132 |
1 files changed, 75 insertions, 57 deletions
diff --git a/win/C#/Functions/Scan.cs b/win/C#/Functions/Scan.cs index 8395eeb28..124f2309b 100644 --- a/win/C#/Functions/Scan.cs +++ b/win/C#/Functions/Scan.cs @@ -1,24 +1,41 @@ /* Scan.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.Windows.Forms;
-using System.IO;
-using System.Diagnostics;
-using System.Threading;
-using Handbrake.Parsing;
+ 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.Functions
{
+ using System;
+ using System.Diagnostics;
+ using System.IO;
+ using System.Threading;
+ using System.Windows.Forms;
+ using Parsing;
+
+ /// <summary>
+ /// Scan a Source
+ /// </summary>
public class Scan
{
- private DVD ThisDvd;
- private Parser ReadData;
- private Process HbProc;
- private string ScanProgress;
+ /// <summary>
+ /// The information for this source
+ /// </summary>
+ private DVD thisDvd;
+
+ /// <summary>
+ /// The CLI data parser
+ /// </summary>
+ private Parser readData;
+
+ /// <summary>
+ /// The Process belonging to the CLI
+ /// </summary>
+ private Process hbProc;
+
+ /// <summary>
+ /// The Progress of the scan
+ /// </summary>
+ private string scanProgress;
/// <summary>
/// Scan has Started
@@ -43,57 +60,57 @@ namespace Handbrake.Functions /// <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));
+ Thread t = new Thread(unused => this.RunScan(sourcePath, title));
t.Start();
}
/// <summary>
/// Object containing the information parsed in the scan.
/// </summary>
- /// <returns></returns>
+ /// <returns>The DVD object containing the scan information</returns>
public DVD SouceData()
{
- return ThisDvd;
+ return this.thisDvd;
}
/// <summary>
/// Raw log output from HandBrake CLI
/// </summary>
- /// <returns></returns>
- public String LogData()
+ /// <returns>The Log Data</returns>
+ public string LogData()
{
- return ReadData.Buffer;
+ return this.readData.Buffer;
}
/// <summary>
/// Progress of the scan.
/// </summary>
- /// <returns></returns>
- public String ScanStatus()
+ /// <returns>The progress of the scan</returns>
+ public string ScanStatus()
{
- return ScanProgress;
+ return this.scanProgress;
}
/// <summary>
/// The Scan Process
/// </summary>
- /// <returns></returns>
+ /// <returns>The CLI process</returns>
public Process ScanProcess()
{
- return HbProc;
+ return this.hbProc;
}
/// <summary>
/// Start a scan for a given source path and title
/// </summary>
- /// <param name="sourcePath"></param>
- /// <param name="title"></param>
+ /// <param name="sourcePath">Path to the source file</param>
+ /// <param name="title">the title number to look at</param>
private void RunScan(object sourcePath, int title)
{
try
{
- if (ScanStared != null)
- ScanStared(this, new EventArgs());
+ if (this.ScanStared != null)
+ this.ScanStared(this, new EventArgs());
string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");
string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
@@ -103,36 +120,37 @@ namespace Handbrake.Functions if (File.Exists(dvdInfoPath))
File.Delete(dvdInfoPath);
- String dvdnav = string.Empty;
+ string dvdnav = string.Empty;
if (Properties.Settings.Default.noDvdNav)
dvdnav = " --no-dvdnav";
- HbProc = new Process
- {
- StartInfo =
- {
- FileName = handbrakeCLIPath,
- Arguments = String.Format(@" -i ""{0}"" -t{1} {2} -v ", sourcePath, title, dvdnav),
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- UseShellExecute = false,
- CreateNoWindow = true
- }
- };
- HbProc.Start();
-
- ReadData = new Parser(HbProc.StandardError.BaseStream);
- ReadData.OnScanProgress += new ScanProgressEventHandler(OnScanProgress);
- ThisDvd = DVD.Parse(ReadData);
+ this.hbProc = new Process
+ {
+ StartInfo =
+ {
+ FileName = handbrakeCLIPath,
+ Arguments =
+ String.Format(@" -i ""{0}"" -t{1} {2} -v ", sourcePath, title, dvdnav),
+ RedirectStandardOutput = true,
+ RedirectStandardError = true,
+ UseShellExecute = false,
+ CreateNoWindow = true
+ }
+ };
+ this.hbProc.Start();
+
+ this.readData = new Parser(this.hbProc.StandardError.BaseStream);
+ this.readData.OnScanProgress += new ScanProgressEventHandler(this.OnScanProgress);
+ this.thisDvd = DVD.Parse(this.readData);
// Write the Buffer out to file.
StreamWriter scanLog = new StreamWriter(dvdInfoPath);
- scanLog.Write(ReadData.Buffer);
+ scanLog.Write(this.readData.Buffer);
scanLog.Flush();
scanLog.Close();
- if (ScanCompleted != null)
- ScanCompleted(this, new EventArgs());
+ if (this.ScanCompleted != null)
+ this.ScanCompleted(this, new EventArgs());
}
catch (Exception exc)
{
@@ -143,14 +161,14 @@ 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>
+ /// <param name="sender">the sender</param>
+ /// <param name="currentTitle">the current title being scanned</param>
+ /// <param name="titleCount">the total number of titles</param>
private void OnScanProgress(object sender, int currentTitle, int titleCount)
{
- ScanProgress = string.Format("Processing Title: {0} of {1}", currentTitle, titleCount);
- if (ScanStatusChanged != null)
- ScanStatusChanged(this, new EventArgs());
+ this.scanProgress = string.Format("Processing Title: {0} of {1}", currentTitle, titleCount);
+ if (this.ScanStatusChanged != null)
+ this.ScanStatusChanged(this, new EventArgs());
}
}
}
\ No newline at end of file |