<DependentUpon>Settings.settings</DependentUpon>\r
</Compile>\r
<Compile Include="Services\Encode.cs" />\r
+ <Compile Include="Services\Interfaces\IEncode.cs" />\r
+ <Compile Include="Services\Interfaces\IQueue.cs" />\r
+ <Compile Include="Services\Interfaces\IScan.cs" />\r
<Compile Include="Services\Queue.cs" />\r
<Compile Include="Services\Scan.cs" />\r
</ItemGroup>\r
<None Include="Resources\copy.png" />\r
</ItemGroup>\r
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
+ <Import Project="$(ProgramFiles)\MSBuild\Microsoft\StyleCop\v4.3\Microsoft.StyleCop.targets" />\r
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
Other similar extension points exist, see Microsoft.Common.targets.\r
<Target Name="BeforeBuild">\r
};\r
\r
return newTrack;\r
-\r
}\r
\r
/// <summary>\r
{\r
return string.Format("{0} ({1:00}:{2:00}:{3:00})", TitleNumber, Duration.Hours, Duration.Minutes, Duration.Seconds);\r
}\r
-\r
}\r
}
\ No newline at end of file
using HandBrake.ApplicationServices.Functions;\r
using HandBrake.ApplicationServices.Model;\r
using HandBrake.ApplicationServices.Properties;\r
+ using HandBrake.ApplicationServices.Services.Interfaces;\r
\r
using Timer = System.Threading.Timer;\r
\r
/// <summary>\r
/// Class which handles the CLI\r
/// </summary>\r
- public class Encode\r
+ public class Encode : IEncode\r
{\r
/* Private Variables */\r
\r
/// <param name="encJob">\r
/// The enc Job.\r
/// </param>\r
- /// <param name="RequireStandardOuput">\r
+ /// <param name="requireStandardOuput">\r
/// Set to True to show no window and force standard output redirect\r
/// </param>\r
- protected void Run(Job encJob, bool RequireStandardOuput)\r
+ protected void Run(Job encJob, bool requireStandardOuput)\r
{\r
this.job = encJob;\r
try\r
string strCmdLine = String.Format(@" /C """"{0}"" {1} 2>""{2}"" """, handbrakeCLIPath, encJob.Query, logPath);\r
var cliStart = new ProcessStartInfo("CMD.exe", strCmdLine);\r
\r
- if (Settings.Default.enocdeStatusInGui || RequireStandardOuput)\r
+ if (Settings.Default.enocdeStatusInGui || requireStandardOuput)\r
{\r
cliStart.RedirectStandardOutput = true;\r
cliStart.UseShellExecute = false;\r
- if (!Settings.Default.showCliForInGuiEncodeStatus || RequireStandardOuput)\r
+ if (!Settings.Default.showCliForInGuiEncodeStatus || requireStandardOuput)\r
cliStart.CreateNoWindow = true;\r
}\r
if (Settings.Default.cli_minimized)\r
--- /dev/null
+/* IEncode.cs $\r
+ This file is part of the HandBrake source code.\r
+ Homepage: <http://handbrake.fr/>.\r
+ It may be used under the terms of the GNU General Public License. */\r
+\r
+namespace HandBrake.ApplicationServices.Services.Interfaces\r
+{\r
+ using System;\r
+ using System.Diagnostics;\r
+\r
+ /// <summary>\r
+ /// The IEncode Interface\r
+ /// </summary>\r
+ public interface IEncode\r
+ {\r
+ /// <summary>\r
+ /// Fires when a new CLI Job starts\r
+ /// </summary>\r
+ event EventHandler EncodeStarted;\r
+\r
+ /// <summary>\r
+ /// Fires when a CLI job finishes.\r
+ /// </summary>\r
+ event EventHandler EncodeEnded;\r
+\r
+ /// <summary>\r
+ /// Gets or sets The HB Process\r
+ /// </summary>\r
+ Process HbProcess { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets a value indicating whether IsEncoding.\r
+ /// </summary>\r
+ bool IsEncoding { get; }\r
+\r
+ /// <summary>\r
+ /// Gets ActivityLog.\r
+ /// </summary>\r
+ string ActivityLog { get; }\r
+\r
+ /// <summary>\r
+ /// Create a preview sample video\r
+ /// </summary>\r
+ /// <param name="query">\r
+ /// The CLI Query\r
+ /// </param>\r
+ void CreatePreviewSample(string query);\r
+\r
+ /// <summary>\r
+ /// Kill the CLI process\r
+ /// </summary>\r
+ void Stop();\r
+\r
+ /// <summary>\r
+ /// Attempt to Safely kill a DirectRun() CLI\r
+ /// NOTE: This will not work with a MinGW CLI\r
+ /// Note: http://www.cygwin.com/ml/cygwin/2006-03/msg00330.html\r
+ /// </summary>\r
+ void SafelyClose();\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/* IQueue.cs $\r
+ This file is part of the HandBrake source code.\r
+ Homepage: <http://handbrake.fr/>.\r
+ It may be used under the terms of the GNU General Public License. */\r
+\r
+namespace HandBrake.ApplicationServices.Services.Interfaces\r
+{\r
+ using System;\r
+ using System.Collections.ObjectModel;\r
+ using System.Diagnostics;\r
+\r
+ using HandBrake.ApplicationServices.Model;\r
+\r
+ /// <summary>\r
+ /// The IQueue Interface\r
+ /// </summary>\r
+ public interface IQueue\r
+ {\r
+ /// <summary>\r
+ /// Fires when the Queue has started\r
+ /// </summary>\r
+ event EventHandler QueueStarted;\r
+\r
+ /// <summary>\r
+ /// Fires when a job is Added, Removed or Re-Ordered.\r
+ /// Should be used for triggering an update of the Queue Window.\r
+ /// </summary>\r
+ event EventHandler QueueListChanged;\r
+\r
+ /// <summary>\r
+ /// Fires when a pause to the encode queue has been requested.\r
+ /// </summary>\r
+ event EventHandler QueuePauseRequested;\r
+\r
+ /// <summary>\r
+ /// Fires when the entire encode queue has completed.\r
+ /// </summary>\r
+ event EventHandler QueueCompleted;\r
+\r
+ /// <summary>\r
+ /// Gets or sets the last encode that was processed.\r
+ /// </summary>\r
+ /// <returns></returns> \r
+ Job LastEncode { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets a value indicating whether Request Pause\r
+ /// </summary>\r
+ bool Paused { get; }\r
+\r
+ /// <summary>\r
+ /// Gets the current state of the encode queue.\r
+ /// </summary>\r
+ ReadOnlyCollection<Job> CurrentQueue { get; }\r
+\r
+ /// <summary>\r
+ /// Gets the number of items in the queue.\r
+ /// </summary>\r
+ int Count { get; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets The HB Process\r
+ /// </summary>\r
+ Process HbProcess { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets a value indicating whether IsEncoding.\r
+ /// </summary>\r
+ bool IsEncoding { get; }\r
+\r
+ /// <summary>\r
+ /// Gets ActivityLog.\r
+ /// </summary>\r
+ string ActivityLog { get; }\r
+\r
+ /// <summary>\r
+ /// Adds an item to the queue.\r
+ /// </summary>\r
+ /// <param name="query">\r
+ /// The query that will be passed to the HandBrake CLI.\r
+ /// </param>\r
+ /// <param name="title">\r
+ /// The title.\r
+ /// </param>\r
+ /// <param name="source">\r
+ /// The location of the source video.\r
+ /// </param>\r
+ /// <param name="destination">\r
+ /// The location where the encoded video will be.\r
+ /// </param>\r
+ /// <param name="customJob">\r
+ /// Custom job\r
+ /// </param>\r
+ void Add(string query, int title, string source, string destination, bool customJob);\r
+\r
+ /// <summary>\r
+ /// Removes an item from the queue.\r
+ /// </summary>\r
+ /// <param name="index">The zero-based location of the job in the queue.</param>\r
+ void Remove(int index);\r
+\r
+ /// <summary>\r
+ /// Retrieve a job from the queue\r
+ /// </summary>\r
+ /// <param name="index">the job id</param>\r
+ /// <returns>A job for the given index or blank job object</returns>\r
+ Job GetJob(int index);\r
+\r
+ /// <summary>\r
+ /// Moves an item up one position in the queue.\r
+ /// </summary>\r
+ /// <param name="index">The zero-based location of the job in the queue.</param>\r
+ void MoveUp(int index);\r
+\r
+ /// <summary>\r
+ /// Moves an item down one position in the queue.\r
+ /// </summary>\r
+ /// <param name="index">The zero-based location of the job in the queue.</param>\r
+ void MoveDown(int index);\r
+\r
+ /// <summary>\r
+ /// Writes the current state of the queue to a file.\r
+ /// </summary>\r
+ /// <param name="file">The location of the file to write the queue to.</param>\r
+ void WriteQueueStateToFile(string file);\r
+\r
+ /// <summary>\r
+ /// Writes the current state of the queue in the form of a batch (.bat) file.\r
+ /// </summary>\r
+ /// <param name="file">The location of the file to write the batch file to.</param>\r
+ bool WriteBatchScriptToFile(string file);\r
+\r
+ /// <summary>\r
+ /// Reads a serialized XML file that represents a queue of encoding jobs.\r
+ /// </summary>\r
+ /// <param name="file">The location of the file to read the queue from.</param>\r
+ void LoadQueueFromFile(string file);\r
+\r
+ /// <summary>\r
+ /// Checks the current queue for an existing instance of the specified destination.\r
+ /// </summary>\r
+ /// <param name="destination">The destination of the encode.</param>\r
+ /// <returns>Whether or not the supplied destination is already in the queue.</returns>\r
+ bool CheckForDestinationDuplicate(string destination);\r
+\r
+ /// <summary>\r
+ /// Starts encoding the first job in the queue and continues encoding until all jobs\r
+ /// have been encoded.\r
+ /// </summary>\r
+ void Start();\r
+\r
+ /// <summary>\r
+ /// Requests a pause of the encode queue.\r
+ /// </summary>\r
+ void Pause();\r
+\r
+ /// <summary>\r
+ /// Fires when a new CLI Job starts\r
+ /// </summary>\r
+ event EventHandler EncodeStarted;\r
+\r
+ /// <summary>\r
+ /// Fires when a CLI job finishes.\r
+ /// </summary>\r
+ event EventHandler EncodeEnded;\r
+\r
+ /// <summary>\r
+ /// Create a preview sample video\r
+ /// </summary>\r
+ /// <param name="query">\r
+ /// The CLI Query\r
+ /// </param>\r
+ void CreatePreviewSample(string query);\r
+\r
+ /// <summary>\r
+ /// Kill the CLI process\r
+ /// </summary>\r
+ void Stop();\r
+\r
+ /// <summary>\r
+ /// Attempt to Safely kill a DirectRun() CLI\r
+ /// NOTE: This will not work with a MinGW CLI\r
+ /// Note: http://www.cygwin.com/ml/cygwin/2006-03/msg00330.html\r
+ /// </summary>\r
+ void SafelyClose();\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/* IScan.cs $\r
+ This file is part of the HandBrake source code.\r
+ Homepage: <http://handbrake.fr/>.\r
+ It may be used under the terms of the GNU General Public License. */\r
+\r
+namespace HandBrake.ApplicationServices.Services.Interfaces\r
+{\r
+ using System;\r
+\r
+ using HandBrake.ApplicationServices.Parsing;\r
+\r
+ /// <summary>\r
+ /// The IScan Interface\r
+ /// </summary>\r
+ public interface IScan\r
+ {\r
+ /// <summary>\r
+ /// Scan has Started\r
+ /// </summary>\r
+ event EventHandler ScanStared;\r
+\r
+ /// <summary>\r
+ /// Scan has completed\r
+ /// </summary>\r
+ event EventHandler ScanCompleted;\r
+\r
+ /// <summary>\r
+ /// Scan process has changed to a new title\r
+ /// </summary>\r
+ event EventHandler ScanStatusChanged;\r
+\r
+ /// <summary>\r
+ /// Gets a value indicating whether IsScanning.\r
+ /// </summary>\r
+ bool IsScanning { get; }\r
+\r
+ /// <summary>\r
+ /// Gets the Scan Status.\r
+ /// </summary>\r
+ string ScanStatus { get; }\r
+\r
+ /// <summary>\r
+ /// Gets the Souce Data.\r
+ /// </summary>\r
+ DVD SouceData { get; }\r
+\r
+ /// <summary>\r
+ /// Gets ActivityLog.\r
+ /// </summary>\r
+ string ActivityLog { get; }\r
+\r
+ /// <summary>\r
+ /// Scan a Source Path.\r
+ /// Title 0: scan all\r
+ /// </summary>\r
+ /// <param name="sourcePath">Path to the file to scan</param>\r
+ /// <param name="title">int title number. 0 for scan all</param>\r
+ void Scan(string sourcePath, int title);\r
+\r
+ /// <summary>\r
+ /// Kill the scan\r
+ /// </summary>\r
+ void Stop();\r
+ }\r
+}
\ No newline at end of file
\r
using HandBrake.ApplicationServices.Functions;\r
using HandBrake.ApplicationServices.Model;\r
+ using HandBrake.ApplicationServices.Services.Interfaces;\r
\r
/// <summary>\r
/// The HandBrake Queue\r
/// </summary>\r
- public class Queue : Encode\r
+ public class Queue : Encode, IQueue\r
{\r
/// <summary>\r
/// The Queue Job List\r
\r
using HandBrake.ApplicationServices.Functions;\r
using HandBrake.ApplicationServices.Parsing;\r
+ using HandBrake.ApplicationServices.Services.Interfaces;\r
\r
/// <summary>\r
/// Scan a Source\r
/// </summary>\r
- public class ScanService\r
+ public class ScanService : IScan\r
{\r
/* Private Variables */\r
\r
using System.Windows.Forms;\r
using Functions;\r
\r
- using HandBrake.ApplicationServices.Services;\r
+ using HandBrake.ApplicationServices.Services.Interfaces;\r
\r
using Model;\r
using Timer = System.Threading.Timer;\r
/// <summary>\r
/// The Encode Object\r
/// </summary>\r
- private Encode encode;\r
+ private IQueue encode;\r
\r
/// <summary>\r
/// The Scan Object\r
/// </summary>\r
- private ScanService scan;\r
+ private IScan scan;\r
\r
/// <summary>\r
/// The Type of log that the window is currently dealing with\r
/// <param name="scan">\r
/// The scan.\r
/// </param>\r
- public frmActivityWindow(Encode encode, ScanService scan)\r
+ public frmActivityWindow(IQueue encode, IScan scan)\r
{\r
InitializeComponent();\r
\r
using HandBrake.ApplicationServices.Model;\r
using HandBrake.ApplicationServices.Parsing;\r
using HandBrake.ApplicationServices.Services;\r
+ using HandBrake.ApplicationServices.Services.Interfaces;\r
\r
using Model;\r
using Presets;\r
public partial class frmMain : Form\r
{\r
// Objects which may be used by one or more other objects *************\r
- private Queue encodeQueue = new Queue();\r
+ private IQueue encodeQueue = new Queue();\r
private PresetsHandler presetHandler = new PresetsHandler();\r
\r
// Windows ************************************************************\r
private string dvdDriveLabel;\r
private Preset CurrentlySelectedPreset;\r
private DVD currentSource;\r
- private ScanService SourceScan = new ScanService();\r
+ private IScan SourceScan = new ScanService();\r
private List<DriveInformation> drives;\r
private Thread encodeMonitor;\r
\r
\r
using HandBrake.ApplicationServices.Model;\r
using HandBrake.ApplicationServices.Services;\r
+ using HandBrake.ApplicationServices.Services.Interfaces;\r
\r
using Model;\r
\r
/// <summary>\r
/// An instance of the Queue service\r
/// </summary>\r
- private readonly Queue queue;\r
+ private readonly IQueue queue;\r
\r
/// <summary>\r
/// A reference to the main application window\r
/// <param name="mw">\r
/// The main window.\r
/// </param>\r
- public frmQueue(Queue q, frmMain mw)\r
+ public frmQueue(IQueue q, frmMain mw)\r
{\r
InitializeComponent();\r
\r