summaryrefslogtreecommitdiffstats
path: root/win/C#
diff options
context:
space:
mode:
authorsr55 <[email protected]>2010-06-07 18:51:59 +0000
committersr55 <[email protected]>2010-06-07 18:51:59 +0000
commite18ddd6e3c103f936044cf3df3c5a94f30821bb2 (patch)
tree9b8fd5e8c36da5b4b8dcc7a83860ccba698a87b4 /win/C#
parent66cc9a71a58bc66a65b4f92bb736e7d1ca9313db (diff)
WinGui:
- Created interfaces for the Scan, Queue and Encode Services. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3367 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#')
-rw-r--r--win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj4
-rw-r--r--win/C#/HandBrake.ApplicationServices/Parsing/AudioTrack.cs1
-rw-r--r--win/C#/HandBrake.ApplicationServices/Parsing/Title.cs1
-rw-r--r--win/C#/HandBrake.ApplicationServices/Services/Encode.cs11
-rw-r--r--win/C#/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs61
-rw-r--r--win/C#/HandBrake.ApplicationServices/Services/Interfaces/IQueue.cs187
-rw-r--r--win/C#/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs65
-rw-r--r--win/C#/HandBrake.ApplicationServices/Services/Queue.cs3
-rw-r--r--win/C#/HandBrake.ApplicationServices/Services/Scan.cs3
-rw-r--r--win/C#/frmActivityWindow.cs8
-rw-r--r--win/C#/frmMain.cs5
-rw-r--r--win/C#/frmQueue.cs5
12 files changed, 337 insertions, 17 deletions
diff --git a/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
index c682f5711..ce6412ffa 100644
--- a/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
+++ b/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
@@ -94,6 +94,9 @@
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="Services\Encode.cs" />
+ <Compile Include="Services\Interfaces\IEncode.cs" />
+ <Compile Include="Services\Interfaces\IQueue.cs" />
+ <Compile Include="Services\Interfaces\IScan.cs" />
<Compile Include="Services\Queue.cs" />
<Compile Include="Services\Scan.cs" />
</ItemGroup>
@@ -125,6 +128,7 @@
<None Include="Resources\copy.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(ProgramFiles)\MSBuild\Microsoft\StyleCop\v4.3\Microsoft.StyleCop.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
diff --git a/win/C#/HandBrake.ApplicationServices/Parsing/AudioTrack.cs b/win/C#/HandBrake.ApplicationServices/Parsing/AudioTrack.cs
index f83660bb8..0272a96af 100644
--- a/win/C#/HandBrake.ApplicationServices/Parsing/AudioTrack.cs
+++ b/win/C#/HandBrake.ApplicationServices/Parsing/AudioTrack.cs
@@ -90,7 +90,6 @@ namespace HandBrake.ApplicationServices.Parsing
};
return newTrack;
-
}
/// <summary>
diff --git a/win/C#/HandBrake.ApplicationServices/Parsing/Title.cs b/win/C#/HandBrake.ApplicationServices/Parsing/Title.cs
index 0aad4d5f3..0e2d80f66 100644
--- a/win/C#/HandBrake.ApplicationServices/Parsing/Title.cs
+++ b/win/C#/HandBrake.ApplicationServices/Parsing/Title.cs
@@ -286,6 +286,5 @@ namespace HandBrake.ApplicationServices.Parsing
{
return string.Format("{0} ({1:00}:{2:00}:{3:00})", TitleNumber, Duration.Hours, Duration.Minutes, Duration.Seconds);
}
-
}
} \ No newline at end of file
diff --git a/win/C#/HandBrake.ApplicationServices/Services/Encode.cs b/win/C#/HandBrake.ApplicationServices/Services/Encode.cs
index 491668d22..38c9b8086 100644
--- a/win/C#/HandBrake.ApplicationServices/Services/Encode.cs
+++ b/win/C#/HandBrake.ApplicationServices/Services/Encode.cs
@@ -15,13 +15,14 @@ namespace HandBrake.ApplicationServices.Services
using HandBrake.ApplicationServices.Functions;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Properties;
+ using HandBrake.ApplicationServices.Services.Interfaces;
using Timer = System.Threading.Timer;
/// <summary>
/// Class which handles the CLI
/// </summary>
- public class Encode
+ public class Encode : IEncode
{
/* Private Variables */
@@ -150,10 +151,10 @@ namespace HandBrake.ApplicationServices.Services
/// <param name="encJob">
/// The enc Job.
/// </param>
- /// <param name="RequireStandardOuput">
+ /// <param name="requireStandardOuput">
/// Set to True to show no window and force standard output redirect
/// </param>
- protected void Run(Job encJob, bool RequireStandardOuput)
+ protected void Run(Job encJob, bool requireStandardOuput)
{
this.job = encJob;
try
@@ -166,11 +167,11 @@ namespace HandBrake.ApplicationServices.Services
string strCmdLine = String.Format(@" /C """"{0}"" {1} 2>""{2}"" """, handbrakeCLIPath, encJob.Query, logPath);
var cliStart = new ProcessStartInfo("CMD.exe", strCmdLine);
- if (Settings.Default.enocdeStatusInGui || RequireStandardOuput)
+ if (Settings.Default.enocdeStatusInGui || requireStandardOuput)
{
cliStart.RedirectStandardOutput = true;
cliStart.UseShellExecute = false;
- if (!Settings.Default.showCliForInGuiEncodeStatus || RequireStandardOuput)
+ if (!Settings.Default.showCliForInGuiEncodeStatus || requireStandardOuput)
cliStart.CreateNoWindow = true;
}
if (Settings.Default.cli_minimized)
diff --git a/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs b/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs
new file mode 100644
index 000000000..3b1a95dba
--- /dev/null
+++ b/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs
@@ -0,0 +1,61 @@
+/* IEncode.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.Services.Interfaces
+{
+ using System;
+ using System.Diagnostics;
+
+ /// <summary>
+ /// The IEncode Interface
+ /// </summary>
+ public interface IEncode
+ {
+ /// <summary>
+ /// Fires when a new CLI Job starts
+ /// </summary>
+ event EventHandler EncodeStarted;
+
+ /// <summary>
+ /// Fires when a CLI job finishes.
+ /// </summary>
+ event EventHandler EncodeEnded;
+
+ /// <summary>
+ /// Gets or sets The HB Process
+ /// </summary>
+ Process HbProcess { get; set; }
+
+ /// <summary>
+ /// Gets a value indicating whether IsEncoding.
+ /// </summary>
+ bool IsEncoding { get; }
+
+ /// <summary>
+ /// Gets ActivityLog.
+ /// </summary>
+ string ActivityLog { get; }
+
+ /// <summary>
+ /// Create a preview sample video
+ /// </summary>
+ /// <param name="query">
+ /// The CLI Query
+ /// </param>
+ void CreatePreviewSample(string query);
+
+ /// <summary>
+ /// Kill the CLI process
+ /// </summary>
+ void Stop();
+
+ /// <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>
+ void SafelyClose();
+ }
+} \ No newline at end of file
diff --git a/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IQueue.cs b/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IQueue.cs
new file mode 100644
index 000000000..a01f13a1e
--- /dev/null
+++ b/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IQueue.cs
@@ -0,0 +1,187 @@
+/* IQueue.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.Services.Interfaces
+{
+ using System;
+ using System.Collections.ObjectModel;
+ using System.Diagnostics;
+
+ using HandBrake.ApplicationServices.Model;
+
+ /// <summary>
+ /// The IQueue Interface
+ /// </summary>
+ public interface IQueue
+ {
+ /// <summary>
+ /// Fires when the Queue has started
+ /// </summary>
+ event EventHandler QueueStarted;
+
+ /// <summary>
+ /// Fires when a job is Added, Removed or Re-Ordered.
+ /// Should be used for triggering an update of the Queue Window.
+ /// </summary>
+ event EventHandler QueueListChanged;
+
+ /// <summary>
+ /// Fires when a pause to the encode queue has been requested.
+ /// </summary>
+ event EventHandler QueuePauseRequested;
+
+ /// <summary>
+ /// Fires when the entire encode queue has completed.
+ /// </summary>
+ event EventHandler QueueCompleted;
+
+ /// <summary>
+ /// Gets or sets the last encode that was processed.
+ /// </summary>
+ /// <returns></returns>
+ Job LastEncode { get; set; }
+
+ /// <summary>
+ /// Gets a value indicating whether Request Pause
+ /// </summary>
+ bool Paused { get; }
+
+ /// <summary>
+ /// Gets the current state of the encode queue.
+ /// </summary>
+ ReadOnlyCollection<Job> CurrentQueue { get; }
+
+ /// <summary>
+ /// Gets the number of items in the queue.
+ /// </summary>
+ int Count { get; }
+
+ /// <summary>
+ /// Gets or sets The HB Process
+ /// </summary>
+ Process HbProcess { get; set; }
+
+ /// <summary>
+ /// Gets a value indicating whether IsEncoding.
+ /// </summary>
+ bool IsEncoding { get; }
+
+ /// <summary>
+ /// Gets ActivityLog.
+ /// </summary>
+ string ActivityLog { get; }
+
+ /// <summary>
+ /// Adds an item to the queue.
+ /// </summary>
+ /// <param name="query">
+ /// The query that will be passed to the HandBrake CLI.
+ /// </param>
+ /// <param name="title">
+ /// The title.
+ /// </param>
+ /// <param name="source">
+ /// The location of the source video.
+ /// </param>
+ /// <param name="destination">
+ /// The location where the encoded video will be.
+ /// </param>
+ /// <param name="customJob">
+ /// Custom job
+ /// </param>
+ void Add(string query, int title, string source, string destination, bool customJob);
+
+ /// <summary>
+ /// Removes an item from the queue.
+ /// </summary>
+ /// <param name="index">The zero-based location of the job in the queue.</param>
+ void Remove(int index);
+
+ /// <summary>
+ /// Retrieve a job from the queue
+ /// </summary>
+ /// <param name="index">the job id</param>
+ /// <returns>A job for the given index or blank job object</returns>
+ Job GetJob(int index);
+
+ /// <summary>
+ /// Moves an item up one position in the queue.
+ /// </summary>
+ /// <param name="index">The zero-based location of the job in the queue.</param>
+ void MoveUp(int index);
+
+ /// <summary>
+ /// Moves an item down one position in the queue.
+ /// </summary>
+ /// <param name="index">The zero-based location of the job in the queue.</param>
+ void MoveDown(int index);
+
+ /// <summary>
+ /// Writes the current state of the queue to a file.
+ /// </summary>
+ /// <param name="file">The location of the file to write the queue to.</param>
+ void WriteQueueStateToFile(string file);
+
+ /// <summary>
+ /// Writes the current state of the queue in the form of a batch (.bat) file.
+ /// </summary>
+ /// <param name="file">The location of the file to write the batch file to.</param>
+ bool WriteBatchScriptToFile(string file);
+
+ /// <summary>
+ /// Reads a serialized XML file that represents a queue of encoding jobs.
+ /// </summary>
+ /// <param name="file">The location of the file to read the queue from.</param>
+ void LoadQueueFromFile(string file);
+
+ /// <summary>
+ /// Checks the current queue for an existing instance of the specified destination.
+ /// </summary>
+ /// <param name="destination">The destination of the encode.</param>
+ /// <returns>Whether or not the supplied destination is already in the queue.</returns>
+ bool CheckForDestinationDuplicate(string destination);
+
+ /// <summary>
+ /// Starts encoding the first job in the queue and continues encoding until all jobs
+ /// have been encoded.
+ /// </summary>
+ void Start();
+
+ /// <summary>
+ /// Requests a pause of the encode queue.
+ /// </summary>
+ void Pause();
+
+ /// <summary>
+ /// Fires when a new CLI Job starts
+ /// </summary>
+ event EventHandler EncodeStarted;
+
+ /// <summary>
+ /// Fires when a CLI job finishes.
+ /// </summary>
+ event EventHandler EncodeEnded;
+
+ /// <summary>
+ /// Create a preview sample video
+ /// </summary>
+ /// <param name="query">
+ /// The CLI Query
+ /// </param>
+ void CreatePreviewSample(string query);
+
+ /// <summary>
+ /// Kill the CLI process
+ /// </summary>
+ void Stop();
+
+ /// <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>
+ void SafelyClose();
+ }
+} \ No newline at end of file
diff --git a/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs b/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs
new file mode 100644
index 000000000..b02b8b06f
--- /dev/null
+++ b/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs
@@ -0,0 +1,65 @@
+/* IScan.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.Services.Interfaces
+{
+ using System;
+
+ using HandBrake.ApplicationServices.Parsing;
+
+ /// <summary>
+ /// The IScan Interface
+ /// </summary>
+ public interface IScan
+ {
+ /// <summary>
+ /// Scan has Started
+ /// </summary>
+ event EventHandler ScanStared;
+
+ /// <summary>
+ /// Scan has completed
+ /// </summary>
+ event EventHandler ScanCompleted;
+
+ /// <summary>
+ /// Scan process has changed to a new title
+ /// </summary>
+ event EventHandler ScanStatusChanged;
+
+ /// <summary>
+ /// Gets a value indicating whether IsScanning.
+ /// </summary>
+ bool IsScanning { get; }
+
+ /// <summary>
+ /// Gets the Scan Status.
+ /// </summary>
+ string ScanStatus { get; }
+
+ /// <summary>
+ /// Gets the Souce Data.
+ /// </summary>
+ DVD SouceData { get; }
+
+ /// <summary>
+ /// Gets ActivityLog.
+ /// </summary>
+ string ActivityLog { get; }
+
+ /// <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>
+ void Scan(string sourcePath, int title);
+
+ /// <summary>
+ /// Kill the scan
+ /// </summary>
+ void Stop();
+ }
+} \ No newline at end of file
diff --git a/win/C#/HandBrake.ApplicationServices/Services/Queue.cs b/win/C#/HandBrake.ApplicationServices/Services/Queue.cs
index f61bb6e29..226ea68b1 100644
--- a/win/C#/HandBrake.ApplicationServices/Services/Queue.cs
+++ b/win/C#/HandBrake.ApplicationServices/Services/Queue.cs
@@ -16,11 +16,12 @@ namespace HandBrake.ApplicationServices.Services
using HandBrake.ApplicationServices.Functions;
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Services.Interfaces;
/// <summary>
/// The HandBrake Queue
/// </summary>
- public class Queue : Encode
+ public class Queue : Encode, IQueue
{
/// <summary>
/// The Queue Job List
diff --git a/win/C#/HandBrake.ApplicationServices/Services/Scan.cs b/win/C#/HandBrake.ApplicationServices/Services/Scan.cs
index 1f54fa904..6aefa03fd 100644
--- a/win/C#/HandBrake.ApplicationServices/Services/Scan.cs
+++ b/win/C#/HandBrake.ApplicationServices/Services/Scan.cs
@@ -14,11 +14,12 @@ namespace HandBrake.ApplicationServices.Services
using HandBrake.ApplicationServices.Functions;
using HandBrake.ApplicationServices.Parsing;
+ using HandBrake.ApplicationServices.Services.Interfaces;
/// <summary>
/// Scan a Source
/// </summary>
- public class ScanService
+ public class ScanService : IScan
{
/* Private Variables */
diff --git a/win/C#/frmActivityWindow.cs b/win/C#/frmActivityWindow.cs
index b979e4b17..d890a7834 100644
--- a/win/C#/frmActivityWindow.cs
+++ b/win/C#/frmActivityWindow.cs
@@ -14,7 +14,7 @@ namespace Handbrake
using System.Windows.Forms;
using Functions;
- using HandBrake.ApplicationServices.Services;
+ using HandBrake.ApplicationServices.Services.Interfaces;
using Model;
using Timer = System.Threading.Timer;
@@ -39,12 +39,12 @@ namespace Handbrake
/// <summary>
/// The Encode Object
/// </summary>
- private Encode encode;
+ private IQueue encode;
/// <summary>
/// The Scan Object
/// </summary>
- private ScanService scan;
+ private IScan scan;
/// <summary>
/// The Type of log that the window is currently dealing with
@@ -62,7 +62,7 @@ namespace Handbrake
/// <param name="scan">
/// The scan.
/// </param>
- public frmActivityWindow(Encode encode, ScanService scan)
+ public frmActivityWindow(IQueue encode, IScan scan)
{
InitializeComponent();
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs
index b7fcef9ca..3a4358bf7 100644
--- a/win/C#/frmMain.cs
+++ b/win/C#/frmMain.cs
@@ -20,6 +20,7 @@ namespace Handbrake
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Services;
+ using HandBrake.ApplicationServices.Services.Interfaces;
using Model;
using Presets;
@@ -28,7 +29,7 @@ namespace Handbrake
public partial class frmMain : Form
{
// Objects which may be used by one or more other objects *************
- private Queue encodeQueue = new Queue();
+ private IQueue encodeQueue = new Queue();
private PresetsHandler presetHandler = new PresetsHandler();
// Windows ************************************************************
@@ -45,7 +46,7 @@ namespace Handbrake
private string dvdDriveLabel;
private Preset CurrentlySelectedPreset;
private DVD currentSource;
- private ScanService SourceScan = new ScanService();
+ private IScan SourceScan = new ScanService();
private List<DriveInformation> drives;
private Thread encodeMonitor;
diff --git a/win/C#/frmQueue.cs b/win/C#/frmQueue.cs
index dfc636e09..f45ed39bc 100644
--- a/win/C#/frmQueue.cs
+++ b/win/C#/frmQueue.cs
@@ -14,6 +14,7 @@ namespace Handbrake
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services;
+ using HandBrake.ApplicationServices.Services.Interfaces;
using Model;
@@ -30,7 +31,7 @@ namespace Handbrake
/// <summary>
/// An instance of the Queue service
/// </summary>
- private readonly Queue queue;
+ private readonly IQueue queue;
/// <summary>
/// A reference to the main application window
@@ -46,7 +47,7 @@ namespace Handbrake
/// <param name="mw">
/// The main window.
/// </param>
- public frmQueue(Queue q, frmMain mw)
+ public frmQueue(IQueue q, frmMain mw)
{
InitializeComponent();