OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 7 Jun 2010 18:51:59 +0000 (18:51 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 7 Jun 2010 18:51:59 +0000 (18:51 +0000)
- Created interfaces for the Scan, Queue and Encode Services.

git-svn-id: svn://localhost/HandBrake/trunk@3367 b64f7644-9d1e-0410-96f1-a4d463321fa5

12 files changed:
win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
win/C#/HandBrake.ApplicationServices/Parsing/AudioTrack.cs
win/C#/HandBrake.ApplicationServices/Parsing/Title.cs
win/C#/HandBrake.ApplicationServices/Services/Encode.cs
win/C#/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs [new file with mode: 0644]
win/C#/HandBrake.ApplicationServices/Services/Interfaces/IQueue.cs [new file with mode: 0644]
win/C#/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs [new file with mode: 0644]
win/C#/HandBrake.ApplicationServices/Services/Queue.cs
win/C#/HandBrake.ApplicationServices/Services/Scan.cs
win/C#/frmActivityWindow.cs
win/C#/frmMain.cs
win/C#/frmQueue.cs

index c682f57..ce6412f 100644 (file)
@@ -94,6 +94,9 @@
       <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
index f83660b..0272a96 100644 (file)
@@ -90,7 +90,6 @@ namespace HandBrake.ApplicationServices.Parsing
                 };\r
 \r
             return newTrack;\r
-\r
         }\r
 \r
         /// <summary>\r
index 0aad4d5..0e2d80f 100644 (file)
@@ -286,6 +286,5 @@ namespace HandBrake.ApplicationServices.Parsing
         {\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
index 491668d..38c9b80 100644 (file)
@@ -15,13 +15,14 @@ namespace HandBrake.ApplicationServices.Services
     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
@@ -150,10 +151,10 @@ namespace HandBrake.ApplicationServices.Services
         /// <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
@@ -166,11 +167,11 @@ namespace HandBrake.ApplicationServices.Services
                 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
diff --git a/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs b/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs
new file mode 100644 (file)
index 0000000..3b1a95d
--- /dev/null
@@ -0,0 +1,61 @@
+/*  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
diff --git a/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IQueue.cs b/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IQueue.cs
new file mode 100644 (file)
index 0000000..a01f13a
--- /dev/null
@@ -0,0 +1,187 @@
+/*  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
diff --git a/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs b/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs
new file mode 100644 (file)
index 0000000..b02b8b0
--- /dev/null
@@ -0,0 +1,65 @@
+/*  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
index f61bb6e..226ea68 100644 (file)
@@ -16,11 +16,12 @@ namespace HandBrake.ApplicationServices.Services
 \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
index 1f54fa9..6aefa03 100644 (file)
@@ -14,11 +14,12 @@ namespace HandBrake.ApplicationServices.Services
 \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
index b979e4b..d890a78 100644 (file)
@@ -14,7 +14,7 @@ namespace Handbrake
     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
@@ -39,12 +39,12 @@ namespace Handbrake
         /// <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
@@ -62,7 +62,7 @@ namespace Handbrake
         /// <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
index b7fcef9..3a4358b 100644 (file)
@@ -20,6 +20,7 @@ namespace Handbrake
     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
@@ -28,7 +29,7 @@ namespace Handbrake
     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
@@ -45,7 +46,7 @@ namespace Handbrake
         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
index dfc636e..f45ed39 100644 (file)
@@ -14,6 +14,7 @@ namespace Handbrake
 \r
     using HandBrake.ApplicationServices.Model;\r
     using HandBrake.ApplicationServices.Services;\r
+    using HandBrake.ApplicationServices.Services.Interfaces;\r
 \r
     using Model;\r
 \r
@@ -30,7 +31,7 @@ namespace Handbrake
         /// <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
@@ -46,7 +47,7 @@ namespace Handbrake
         /// <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