summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2011-01-07 21:19:49 +0000
committersr55 <[email protected]>2011-01-07 21:19:49 +0000
commit9f60eb35c21d513c6ce6b272e371a279b8a32ae5 (patch)
tree8663ceb2de2b74c05bc639fdcdd720034005a1af /win
parentee94883ba1b2e3d0dc432c84a2c05db5812fe1c6 (diff)
WinGui:
- First of many check-ins to refactor the ApplicationServices library to make it more friendly and reliable. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3737 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r--win/C#/HandBrake.ApplicationServices/EventArgs/EncodeCompletedEventArgs.cs49
-rw-r--r--win/C#/HandBrake.ApplicationServices/EventArgs/EncodeProgressEventArgs.cs (renamed from win/C#/HandBrake.ApplicationServices/EncodeProgressEventArgs.cs)4
-rw-r--r--win/C#/HandBrake.ApplicationServices/EventArgs/QueueProgressEventArgs.cs33
-rw-r--r--win/C#/HandBrake.ApplicationServices/EventArgs/ScanCompletedEventArgs.cs49
-rw-r--r--win/C#/HandBrake.ApplicationServices/EventArgs/ScanProgressEventArgs.cs25
-rw-r--r--win/C#/HandBrake.ApplicationServices/Functions/Converters.cs70
-rw-r--r--win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj7
-rw-r--r--win/C#/HandBrake.ApplicationServices/Services/Encode.cs3
-rw-r--r--win/C#/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs32
-rw-r--r--win/C#/HandBrake.ApplicationServices/Services/Scan.cs131
-rw-r--r--win/C#/frmMain.cs52
-rw-r--r--win/C#/frmPreview.cs2
-rw-r--r--win/C#/frmQueue.cs2
13 files changed, 357 insertions, 102 deletions
diff --git a/win/C#/HandBrake.ApplicationServices/EventArgs/EncodeCompletedEventArgs.cs b/win/C#/HandBrake.ApplicationServices/EventArgs/EncodeCompletedEventArgs.cs
new file mode 100644
index 000000000..2d613f6d5
--- /dev/null
+++ b/win/C#/HandBrake.ApplicationServices/EventArgs/EncodeCompletedEventArgs.cs
@@ -0,0 +1,49 @@
+/* EncodeCompletedEventArgs.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.ApplicationServices.EventArgs
+{
+ using System;
+
+ /// <summary>
+ /// Encode Progress Event Args
+ /// </summary>
+ public class EncodeCompletedEventArgs : EventArgs
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="EncodeCompletedEventArgs"/> class.
+ /// </summary>
+ /// <param name="sucessful">
+ /// The sucessful.
+ /// </param>
+ /// <param name="exception">
+ /// The exception.
+ /// </param>
+ /// <param name="errorInformation">
+ /// The error information.
+ /// </param>
+ public EncodeCompletedEventArgs(bool sucessful, Exception exception, string errorInformation)
+ {
+ this.Successful = sucessful;
+ this.Exception = exception;
+ this.ErrorInformation = errorInformation;
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether Successful.
+ /// </summary>
+ public bool Successful { get; set; }
+
+ /// <summary>
+ /// Gets or sets Exception.
+ /// </summary>
+ public Exception Exception { get; set; }
+
+ /// <summary>
+ /// Gets or sets ErrorInformation.
+ /// </summary>
+ public string ErrorInformation { get; set; }
+ }
+}
diff --git a/win/C#/HandBrake.ApplicationServices/EncodeProgressEventArgs.cs b/win/C#/HandBrake.ApplicationServices/EventArgs/EncodeProgressEventArgs.cs
index 8c46f8738..b4d6b9a64 100644
--- a/win/C#/HandBrake.ApplicationServices/EncodeProgressEventArgs.cs
+++ b/win/C#/HandBrake.ApplicationServices/EventArgs/EncodeProgressEventArgs.cs
@@ -3,7 +3,7 @@
Homepage: <http://handbrake.fr>.
It may be used under the terms of the GNU General Public License. */
-namespace HandBrake.ApplicationServices
+namespace HandBrake.ApplicationServices.EventArgs
{
using System;
@@ -30,7 +30,7 @@ namespace HandBrake.ApplicationServices
/// <summary>
/// Gets or sets EstimatedTimeLeft.
/// </summary>
- public string EstimatedTimeLeft { get; set; }
+ public TimeSpan EstimatedTimeLeft { get; set; }
/// <summary>
/// Gets or sets Task.
diff --git a/win/C#/HandBrake.ApplicationServices/EventArgs/QueueProgressEventArgs.cs b/win/C#/HandBrake.ApplicationServices/EventArgs/QueueProgressEventArgs.cs
new file mode 100644
index 000000000..c2af07fb1
--- /dev/null
+++ b/win/C#/HandBrake.ApplicationServices/EventArgs/QueueProgressEventArgs.cs
@@ -0,0 +1,33 @@
+/* QueueProgressEventArgs.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.ApplicationServices.EventArgs
+{
+ using System;
+
+ using HandBrake.ApplicationServices.Model;
+
+ /// <summary>
+ /// Queue Progress Event Args
+ /// </summary>
+ public class QueueProgressEventArgs : EventArgs
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueueProgressEventArgs"/> class.
+ /// </summary>
+ /// <param name="newJob">
+ /// The new job.
+ /// </param>
+ public QueueProgressEventArgs(Job newJob)
+ {
+ this.NewJob = newJob;
+ }
+
+ /// <summary>
+ /// Gets or sets the new job which is about to be processed.
+ /// </summary>
+ public Job NewJob { get; set; }
+ }
+}
diff --git a/win/C#/HandBrake.ApplicationServices/EventArgs/ScanCompletedEventArgs.cs b/win/C#/HandBrake.ApplicationServices/EventArgs/ScanCompletedEventArgs.cs
new file mode 100644
index 000000000..9b0437ac7
--- /dev/null
+++ b/win/C#/HandBrake.ApplicationServices/EventArgs/ScanCompletedEventArgs.cs
@@ -0,0 +1,49 @@
+/* ScanCompletedEventArgs.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.ApplicationServices.EventArgs
+{
+ using System;
+
+ /// <summary>
+ /// Scan Progress Event Args
+ /// </summary>
+ public class ScanCompletedEventArgs : EventArgs
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ScanCompletedEventArgs"/> class.
+ /// </summary>
+ /// <param name="sucessful">
+ /// The sucessful.
+ /// </param>
+ /// <param name="exception">
+ /// The exception.
+ /// </param>
+ /// <param name="errorInformation">
+ /// The error information.
+ /// </param>
+ public ScanCompletedEventArgs(bool sucessful, Exception exception, string errorInformation)
+ {
+ this.Successful = sucessful;
+ this.Exception = exception;
+ this.ErrorInformation = errorInformation;
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether Successful.
+ /// </summary>
+ public bool Successful { get; set; }
+
+ /// <summary>
+ /// Gets or sets Exception.
+ /// </summary>
+ public Exception Exception { get; set; }
+
+ /// <summary>
+ /// Gets or sets ErrorInformation.
+ /// </summary>
+ public string ErrorInformation { get; set; }
+ }
+}
diff --git a/win/C#/HandBrake.ApplicationServices/EventArgs/ScanProgressEventArgs.cs b/win/C#/HandBrake.ApplicationServices/EventArgs/ScanProgressEventArgs.cs
new file mode 100644
index 000000000..1a6bdb0a1
--- /dev/null
+++ b/win/C#/HandBrake.ApplicationServices/EventArgs/ScanProgressEventArgs.cs
@@ -0,0 +1,25 @@
+/* ScanProgressEventArgs.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.ApplicationServices.EventArgs
+{
+ using System;
+
+ /// <summary>
+ /// Scan Progress Event Args
+ /// </summary>
+ public class ScanProgressEventArgs : EventArgs
+ {
+ /// <summary>
+ /// Gets or sets the title currently being scanned.
+ /// </summary>
+ public int CurrentTitle { get; set; }
+
+ /// <summary>
+ /// Gets or sets the total number of Titles.
+ /// </summary>
+ public int Titles { get; set; }
+ }
+}
diff --git a/win/C#/HandBrake.ApplicationServices/Functions/Converters.cs b/win/C#/HandBrake.ApplicationServices/Functions/Converters.cs
new file mode 100644
index 000000000..c4ba59f14
--- /dev/null
+++ b/win/C#/HandBrake.ApplicationServices/Functions/Converters.cs
@@ -0,0 +1,70 @@
+namespace HandBrake.ApplicationServices.Functions
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Text.RegularExpressions;
+
+ /// <summary>
+ /// A class to convert various things to native C# objects
+ /// </summary>
+ public class Converters
+ {
+ /// <summary>
+ /// Convert HandBrakes time remaining into a TimeSpan
+ /// </summary>
+ /// <param name="time">
+ /// The time remaining for the encode.
+ /// </param>
+ /// <returns>
+ /// A TimepSpan object
+ /// </returns>
+ public static TimeSpan EncodeToTimespan(string time)
+ {
+ TimeSpan converted = new TimeSpan(0, 0, 0, 0);
+
+ Match m = Regex.Match(time.Trim(), @"^([0-9]{2}:[0-9]{2}:[0-9]{2})");
+ if (m.Success)
+ {
+ TimeSpan.TryParse(m.Groups[0].Value, out converted);
+ }
+
+ return converted;
+ }
+
+ /// <summary>
+ /// Video Framerate Converter
+ /// </summary>
+ private static readonly Dictionary<double, int> vrates = new Dictionary<double, int>
+ {
+ {5, 5400000},
+ {10, 2700000},
+ {12, 2250000},
+ {15, 1800000},
+ {23.976, 1126125},
+ {24, 1125000},
+ {25, 1080000},
+ {29.97, 900900}
+ };
+
+ /// <summary>
+ /// Convert the desired framerate to the video rate.
+ /// </summary>
+ /// <param name="framerate">
+ /// The framerate.
+ /// </param>
+ /// <returns>
+ /// The Video Rate.
+ /// </returns>
+ /// <exception cref="ArgumentException">
+ /// </exception>
+ public static int FramerateToVrate(double framerate)
+ {
+ if (!vrates.ContainsKey(framerate))
+ {
+ throw new ArgumentException("Framerate not recognized.", "framerate");
+ }
+
+ return vrates[framerate];
+ }
+ }
+}
diff --git a/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
index 8b9d7e30b..38a49c1f4 100644
--- a/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
+++ b/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
@@ -76,7 +76,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
- <Compile Include="EncodeProgressEventArgs.cs" />
+ <Compile Include="EventArgs\EncodeCompletedEventArgs.cs" />
+ <Compile Include="EventArgs\EncodeProgressEventArgs.cs" />
+ <Compile Include="EventArgs\QueueProgressEventArgs.cs" />
+ <Compile Include="EventArgs\ScanCompletedEventArgs.cs" />
+ <Compile Include="EventArgs\ScanProgressEventArgs.cs" />
+ <Compile Include="Functions\Converters.cs" />
<Compile Include="Functions\EnumHelper.cs" />
<Compile Include="Functions\Logging.cs" />
<Compile Include="Functions\GrowlCommunicator.cs" />
diff --git a/win/C#/HandBrake.ApplicationServices/Services/Encode.cs b/win/C#/HandBrake.ApplicationServices/Services/Encode.cs
index fc620ac0d..ea336a245 100644
--- a/win/C#/HandBrake.ApplicationServices/Services/Encode.cs
+++ b/win/C#/HandBrake.ApplicationServices/Services/Encode.cs
@@ -12,6 +12,7 @@ namespace HandBrake.ApplicationServices.Services
using System.Threading;
using System.Windows.Forms;
+ using HandBrake.ApplicationServices.EventArgs;
using HandBrake.Framework.Services;
using HandBrake.Framework.Services.Interfaces;
using HandBrake.ApplicationServices.Functions;
@@ -535,7 +536,7 @@ namespace HandBrake.ApplicationServices.Services
{
AverageFrameRate = avg,
CurrentFrameRate = currentFps,
- EstimatedTimeLeft = timeRemaining,
+ EstimatedTimeLeft = Converters.EncodeToTimespan(timeRemaining),
PercentComplete = percentComplete,
Task = currentTask,
TaskCount = taskCount
diff --git a/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs b/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs
index b02b8b06f..b05390301 100644
--- a/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs
+++ b/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs
@@ -7,9 +7,32 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
{
using System;
+ using HandBrake.ApplicationServices.EventArgs;
using HandBrake.ApplicationServices.Parsing;
/// <summary>
+ /// Encode Progess Status
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The EncodeProgressEventArgs.
+ /// </param>
+ public delegate void ScanProgessStatus(object sender, ScanProgressEventArgs e);
+
+ /// <summary>
+ /// Encode Progess Status
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The ScanCompletedEventArgs.
+ /// </param>
+ public delegate void ScanCompletedStatus(object sender, ScanCompletedEventArgs e);
+
+ /// <summary>
/// The IScan Interface
/// </summary>
public interface IScan
@@ -22,12 +45,12 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
/// <summary>
/// Scan has completed
/// </summary>
- event EventHandler ScanCompleted;
+ event ScanCompletedStatus ScanCompleted;
/// <summary>
/// Scan process has changed to a new title
/// </summary>
- event EventHandler ScanStatusChanged;
+ event ScanProgessStatus ScanStatusChanged;
/// <summary>
/// Gets a value indicating whether IsScanning.
@@ -35,11 +58,6 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
bool IsScanning { get; }
/// <summary>
- /// Gets the Scan Status.
- /// </summary>
- string ScanStatus { get; }
-
- /// <summary>
/// Gets the Souce Data.
/// </summary>
DVD SouceData { get; }
diff --git a/win/C#/HandBrake.ApplicationServices/Services/Scan.cs b/win/C#/HandBrake.ApplicationServices/Services/Scan.cs
index 7bc74bc5c..d6925b304 100644
--- a/win/C#/HandBrake.ApplicationServices/Services/Scan.cs
+++ b/win/C#/HandBrake.ApplicationServices/Services/Scan.cs
@@ -12,8 +12,7 @@ namespace HandBrake.ApplicationServices.Services
using System.Threading;
using System.Windows.Forms;
- using HandBrake.Framework.Services;
- using HandBrake.Framework.Services.Interfaces;
+ using HandBrake.ApplicationServices.EventArgs;
using HandBrake.ApplicationServices.Functions;
using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Services.Interfaces;
@@ -23,12 +22,7 @@ namespace HandBrake.ApplicationServices.Services
/// </summary>
public class ScanService : IScan
{
- /* Private Variables */
-
- /// <summary>
- /// The Error Service
- /// </summary>
- private readonly IErrorService errorService;
+ #region Private Variables
/// <summary>
/// A Lock object
@@ -55,15 +49,16 @@ namespace HandBrake.ApplicationServices.Services
/// </summary>
private Process hbProc;
+ #endregion
+
/// <summary>
/// Initializes a new instance of the <see cref="ScanService"/> class.
/// </summary>
public ScanService()
{
- this.errorService = new ErrorService();
}
- /* Event Handlers */
+ #region Events
/// <summary>
/// Scan has Started
@@ -73,14 +68,16 @@ namespace HandBrake.ApplicationServices.Services
/// <summary>
/// Scan has completed
/// </summary>
- public event EventHandler ScanCompleted;
+ public event ScanCompletedStatus ScanCompleted;
/// <summary>
- /// Scan process has changed to a new title
+ /// Encode process has progressed
/// </summary>
- public event EventHandler ScanStatusChanged;
+ public event ScanProgessStatus ScanStatusChanged;
+
+ #endregion
- /* Properties */
+ #region Public Properties
/// <summary>
/// Gets a value indicating whether IsScanning.
@@ -88,11 +85,6 @@ namespace HandBrake.ApplicationServices.Services
public bool IsScanning { get; private set; }
/// <summary>
- /// Gets the Scan Status.
- /// </summary>
- public string ScanStatus { get; private set; }
-
- /// <summary>
/// Gets the Souce Data.
/// </summary>
public DVD SouceData { get; private set; }
@@ -117,7 +109,9 @@ namespace HandBrake.ApplicationServices.Services
}
}
- /* Public Methods */
+ #endregion
+
+ #region Public Methods
/// <summary>
/// Scan a Source Path.
@@ -138,20 +132,23 @@ namespace HandBrake.ApplicationServices.Services
{
try
{
- this.readData.OnScanProgress -= this.OnScanProgress;
+ // Try to clean things up as best as possible.
+ if (this.readData != null)
+ {
+ this.readData.OnScanProgress -= this.OnScanProgress;
+ }
if (hbProc != null && !hbProc.HasExited)
hbProc.Kill();
}
- catch (Exception ex)
+ catch
{
- errorService.ShowError("Unable to kill HandBrakeCLI.exe \n" +
- "You may need to manually kill HandBrakeCLI.exe using the Windows Task Manager if it does not close automatically" +
- " within the next few minutes. ", ex.ToString());
+ // We don't really need to notify the user of any errors here.
}
}
+ #endregion
- /* Private Methods */
+ #region Private Methods
/// <summary>
/// Start a scan for a given source path and title
@@ -164,52 +161,67 @@ namespace HandBrake.ApplicationServices.Services
{
IsScanning = true;
if (this.ScanStared != null)
+ {
this.ScanStared(this, new EventArgs());
+ }
ResetLogReader(true);
string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");
string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
"\\HandBrake\\logs";
- string dvdInfoPath = Path.Combine(logDir, string.Format("last_scan_log{0}.txt", Init.InstanceId == 0 ? string.Empty : Init.InstanceId.ToString()));
+ string dvdInfoPath = Path.Combine(
+ logDir,
+ string.Format("last_scan_log{0}.txt", Init.InstanceId == 0 ? string.Empty : Init.InstanceId.ToString()));
// Make we don't pick up a stale last_encode_log.txt (and that we have rights to the file)
if (File.Exists(dvdInfoPath))
+ {
File.Delete(dvdInfoPath);
+ }
string extraArguments = string.Empty;
if (Init.DisableDvdNav)
+ {
extraArguments = " --no-dvdnav";
+ }
if (title > 0)
+ {
extraArguments += " --scan ";
+ }
// Quick fix for "F:\\" style paths. Just get rid of the \\ so the CLI doesn't fall over.
// Sould probably clean up the escaping of the strings later.
- string source;
- if (sourcePath.ToString().EndsWith("\\"))
- {
- source = sourcePath.ToString();
- }
- else
- {
- source = "\"" + sourcePath + "\"";
- }
+ string source = sourcePath.ToString().EndsWith("\\") ? sourcePath.ToString() : "\"" + sourcePath + "\"";
+
+ this.hbProc = new Process
+ {
+ StartInfo =
+ {
+ FileName = handbrakeCLIPath,
+ Arguments = String.Format(@" -i ""{0}"" -t{1} {2} -v ", sourcePath, title, extraArguments),
+ RedirectStandardOutput = true,
+ RedirectStandardError = true,
+ UseShellExecute = false,
+ CreateNoWindow = true
+ }
+ };
string command = String.Format(@" -i {0} -t{1} {2} -v ", source, title, extraArguments);
this.hbProc = new Process
- {
- StartInfo =
- {
- FileName = handbrakeCLIPath,
- Arguments = command,
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- UseShellExecute = false,
- CreateNoWindow = true
- }
- };
+ {
+ StartInfo =
+ {
+ FileName = handbrakeCLIPath,
+ Arguments = command,
+ RedirectStandardOutput = true,
+ RedirectStandardError = true,
+ UseShellExecute = false,
+ CreateNoWindow = true
+ }
+ };
// Start the Scan
this.hbProc.Start();
@@ -225,10 +237,7 @@ namespace HandBrake.ApplicationServices.Services
if (this.readData.Buffer.Length < 100000000)
{
scanLog.WriteLine(Logging.CreateCliLogHeader(null));
- scanLog.WriteLine("Query: " + command);
scanLog.Write(this.readData.Buffer);
-
- logBuffer.AppendLine("Query: " + command);
logBuffer.AppendLine(this.readData.Buffer.ToString());
}
else
@@ -241,16 +250,16 @@ namespace HandBrake.ApplicationServices.Services
IsScanning = false;
if (this.ScanCompleted != null)
- this.ScanCompleted(this, new EventArgs());
+ {
+ this.ScanCompleted(this, new ScanCompletedEventArgs(true, null, string.Empty));
+ }
}
catch (Exception exc)
{
this.Stop();
- errorService.ShowError("An error has occured during the scan process.", exc.ToString());
-
if (this.ScanCompleted != null)
- this.ScanCompleted(this, new EventArgs());
+ this.ScanCompleted(this, new ScanCompletedEventArgs(false, exc, "An Error has occured in ScanService.ScanSource()"));
}
}
@@ -302,7 +311,6 @@ namespace HandBrake.ApplicationServices.Services
}
catch (Exception exc)
{
- Console.WriteLine(exc.ToString());
ResetLogReader(true);
}
}
@@ -330,9 +338,18 @@ namespace HandBrake.ApplicationServices.Services
/// <param name="titleCount">the total number of titles</param>
private void OnScanProgress(object sender, int currentTitle, int titleCount)
{
- this.ScanStatus = string.Format("Processing Title: {0} of {1}", currentTitle, titleCount);
+ ScanProgressEventArgs eventArgs = new ScanProgressEventArgs
+ {
+ CurrentTitle = currentTitle,
+ Titles = titleCount
+ };
+
if (this.ScanStatusChanged != null)
- this.ScanStatusChanged(this, new EventArgs());
+ {
+ this.ScanStatusChanged(this, eventArgs);
+ }
}
+
+ #endregion
}
} \ No newline at end of file
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs
index bc56731e9..9fd153e16 100644
--- a/win/C#/frmMain.cs
+++ b/win/C#/frmMain.cs
@@ -16,6 +16,7 @@ namespace Handbrake
using System.Windows.Forms;
using Functions;
+ using HandBrake.ApplicationServices.EventArgs;
using HandBrake.Framework.Model;
using HandBrake.Framework.Services;
using HandBrake.Framework.Views;
@@ -238,8 +239,8 @@ namespace Handbrake
encodeQueue.EncodeEnded += new EventHandler(encodeEnded);
// Scan Started and Completed Events
- SourceScan.ScanStatusChanged += new EventHandler(SourceScan_ScanStatusChanged);
- SourceScan.ScanCompleted += new EventHandler(SourceScan_ScanCompleted);
+ SourceScan.ScanStatusChanged += this.SourceScanScanStatusChanged;
+ SourceScan.ScanCompleted += this.SourceScanScanCompleted;
// Handle a file being draged onto the GUI.
this.DragEnter += new DragEventHandler(frmMain_DragEnter);
@@ -2133,9 +2134,15 @@ namespace Handbrake
/// <param name="e">
/// The e.
/// </param>
- private void SourceScan_ScanStatusChanged(object sender, EventArgs e)
+ private void SourceScanScanStatusChanged(object sender, ScanProgressEventArgs e)
{
- UpdateScanStatusLabel();
+ if (this.InvokeRequired)
+ {
+ this.BeginInvoke(new ScanProgessStatus(this.SourceScanScanStatusChanged), new[] { sender, e });
+ return;
+ }
+
+ labelSource.Text = string.Format("Processing Title: {0} of {1}", e.CurrentTitle, e.Titles);
}
/// <summary>
@@ -2147,32 +2154,11 @@ namespace Handbrake
/// <param name="e">
/// The e.
/// </param>
- private void SourceScan_ScanCompleted(object sender, EventArgs e)
- {
- UpdateGuiAfterScan();
- }
-
- /// <summary>
- /// Update the Scan Status Label
- /// </summary>
- private void UpdateScanStatusLabel()
+ private void SourceScanScanCompleted(object sender, EventArgs e)
{
- if (InvokeRequired)
- {
- BeginInvoke(new UpdateWindowHandler(UpdateScanStatusLabel));
- return;
- }
- labelSource.Text = SourceScan.ScanStatus;
- }
-
- /// <summary>
- /// Reset the GUI when the scan has completed
- /// </summary>
- private void UpdateGuiAfterScan()
- {
- if (InvokeRequired)
+ if (this.InvokeRequired)
{
- BeginInvoke(new UpdateWindowHandler(UpdateGuiAfterScan));
+ this.BeginInvoke(new ScanCompletedStatus(this.SourceScanScanCompleted), new[] { sender, e });
return;
}
@@ -2311,7 +2297,7 @@ namespace Handbrake
/// </summary>
private void KillScan()
{
- SourceScan.ScanCompleted -= new EventHandler(SourceScan_ScanCompleted);
+ SourceScan.ScanCompleted -= this.SourceScanScanCompleted;
EnableGUI();
ResetGUI();
@@ -2432,7 +2418,7 @@ namespace Handbrake
/// <param name="e">
/// The e.
/// </param>
- private void EncodeQueue_EncodeStatusChanged(object sender, HandBrake.ApplicationServices.EncodeProgressEventArgs e)
+ private void EncodeQueue_EncodeStatusChanged(object sender, EncodeProgressEventArgs e)
{
if (this.InvokeRequired)
{
@@ -2616,10 +2602,12 @@ namespace Handbrake
}
if (SourceScan.IsScanning)
- {
- SourceScan.ScanCompleted -= new EventHandler(SourceScan_ScanCompleted);
+ {
SourceScan.Stop();
}
+
+ SourceScan.ScanCompleted -= this.SourceScanScanCompleted;
+ SourceScan.ScanStatusChanged -= this.SourceScanScanStatusChanged;
}
catch (Exception exc)
{
diff --git a/win/C#/frmPreview.cs b/win/C#/frmPreview.cs
index 3a8a2207c..30a57c862 100644
--- a/win/C#/frmPreview.cs
+++ b/win/C#/frmPreview.cs
@@ -192,7 +192,7 @@ namespace Handbrake
/// <param name="e">
/// The e.
/// </param>
- private void EncodeQueueEncodeStatusChanged(object sender, HandBrake.ApplicationServices.EncodeProgressEventArgs e)
+ private void EncodeQueueEncodeStatusChanged(object sender, HandBrake.ApplicationServices.EventArgs.EncodeProgressEventArgs e)
{
if (this.InvokeRequired)
{
diff --git a/win/C#/frmQueue.cs b/win/C#/frmQueue.cs
index 2684772bb..7fd797170 100644
--- a/win/C#/frmQueue.cs
+++ b/win/C#/frmQueue.cs
@@ -119,7 +119,7 @@ namespace Handbrake
/// <param name="e">
/// The e.
/// </param>
- private void EncodeQueue_EncodeStatusChanged(object sender, HandBrake.ApplicationServices.EncodeProgressEventArgs e)
+ private void EncodeQueue_EncodeStatusChanged(object sender, HandBrake.ApplicationServices.EventArgs.EncodeProgressEventArgs e)
{
if (this.InvokeRequired)
{