]> granicus.if.org Git - handbrake/commitdiff
App Services Cleanup Contd
authorScott <sr55.hb@outlook.com>
Sat, 26 Sep 2015 20:09:05 +0000 (21:09 +0100)
committerScott <sr55.hb@outlook.com>
Sat, 26 Sep 2015 20:30:32 +0000 (21:30 +0100)
Moving Exceptions and more utilities to the GUI project.

12 files changed:
win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
win/CS/HandBrakeWPF/App.xaml.cs
win/CS/HandBrakeWPF/Exceptions/GeneralApplicationException.cs [moved from win/CS/HandBrake.ApplicationServices/Exceptions/GeneralApplicationException.cs with 94% similarity]
win/CS/HandBrakeWPF/HandBrakeWPF.csproj
win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs
win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs
win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs
win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
win/CS/HandBrakeWPF/Services/UserSettingService.cs
win/CS/HandBrakeWPF/Utilities/GeneralUtilities.cs [moved from win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs with 96% similarity]
win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs

index 334414f1f6998794ef8d0065e88675750a9922a9..89562540f06fb20ca64c2df06f27b6e32cd55217 100644 (file)
@@ -80,7 +80,6 @@
     <Reference Include="WindowsBase" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <Compile Include="Exceptions\GeneralApplicationException.cs" />\r
     <Compile Include="Attributes\ShortName.cs" />\r
     <Compile Include="Interop\EventArgs\EncodeCompletedEventArgs.cs" />\r
     <Compile Include="Interop\EventArgs\EncodeProgressEventArgs.cs" />\r
       <DependentUpon>Resources.resx</DependentUpon>\r
     </Compile>\r
     <Compile Include="Utilities\CharCodesUtilities.cs" />\r
-    <Compile Include="Utilities\GeneralUtilities.cs" />\r
     <Compile Include="Utilities\LanguageUtilities.cs" />\r
   </ItemGroup>\r
   <ItemGroup>\r
index 7899f4520fd1d947bddb11bbf8becd17b1a7e20d..eea8feb02e6a53a07cbe3ad78bc4e02b92fa30bf 100644 (file)
@@ -16,12 +16,12 @@ namespace HandBrakeWPF
 \r
     using Caliburn.Micro;\r
 \r
-    using HandBrake.ApplicationServices.Exceptions;\r
-\r
     using HandBrakeWPF.Utilities;\r
     using HandBrakeWPF.ViewModels;\r
     using HandBrakeWPF.ViewModels.Interfaces;\r
 \r
+    using GeneralApplicationException = HandBrakeWPF.Exceptions.GeneralApplicationException;\r
+\r
     /// <summary>\r
     /// Interaction logic for App.xaml\r
     /// </summary>\r
similarity index 94%
rename from win/CS/HandBrake.ApplicationServices/Exceptions/GeneralApplicationException.cs
rename to win/CS/HandBrakeWPF/Exceptions/GeneralApplicationException.cs
index 59c952a90e2d9798e8d290c19e17b1223a1f5206..10c5192aff40c4251b1822e50b3099dabc3e4824 100644 (file)
@@ -1,53 +1,53 @@
-// --------------------------------------------------------------------------------------------------------------------\r
-// <copyright file="GeneralApplicationException.cs" company="HandBrake Project (http://handbrake.fr)">\r
-//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
-// </copyright>\r
-// <summary>\r
-//   The Encode Failure Exception\r
-// </summary>\r
-// --------------------------------------------------------------------------------------------------------------------\r
-\r
-namespace HandBrake.ApplicationServices.Exceptions\r
-{\r
-    using System;\r
-\r
-    /// <summary>\r
-    /// The Encode Failure Exception\r
-    /// </summary>\r
-    public class GeneralApplicationException : Exception\r
-    {\r
-        /// <summary>\r
-        /// Initializes a new instance of the <see cref="GeneralApplicationException"/> class. \r
-        /// </summary>\r
-        /// <param name="error">\r
-        /// The error.\r
-        /// </param>\r
-        /// <param name="solution">\r
-        /// The solution.\r
-        /// </param>\r
-        /// <param name="innerException">\r
-        /// The inner Exception.\r
-        /// </param>\r
-        public GeneralApplicationException(string error, string solution, Exception innerException)\r
-        {\r
-            this.Error = error;\r
-            this.Solution = solution;\r
-            this.ActualException = innerException;\r
-        }\r
-\r
-        /// <summary>\r
-        /// Gets or sets FailureReason.\r
-        /// </summary>\r
-        public string Error { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets Solution.\r
-        /// </summary>\r
-        public string Solution { get; set; }\r
-\r
-        /// <summary>\r
-        /// Gets or sets InnerException.\r
-        /// </summary>\r
-        public Exception ActualException { get; set; }\r
-    }\r
-}\r
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="GeneralApplicationException.cs" company="HandBrake Project (http://handbrake.fr)">
+//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+//   The Encode Failure Exception
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Exceptions
+{
+    using System;
+
+    /// <summary>
+    /// The Encode Failure Exception
+    /// </summary>
+    public class GeneralApplicationException : Exception
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="GeneralApplicationException"/> class. 
+        /// </summary>
+        /// <param name="error">
+        /// The error.
+        /// </param>
+        /// <param name="solution">
+        /// The solution.
+        /// </param>
+        /// <param name="innerException">
+        /// The inner Exception.
+        /// </param>
+        public GeneralApplicationException(string error, string solution, Exception innerException)
+        {
+            this.Error = error;
+            this.Solution = solution;
+            this.ActualException = innerException;
+        }
+
+        /// <summary>
+        /// Gets or sets FailureReason.
+        /// </summary>
+        public string Error { get; set; }
+
+        /// <summary>
+        /// Gets or sets Solution.
+        /// </summary>
+        public string Solution { get; set; }
+
+        /// <summary>
+        /// Gets or sets InnerException.
+        /// </summary>
+        public Exception ActualException { get; set; }
+    }
+}
index d47736b6cbda998a63d16ac422b528872f8b9c83..808b3d01533a272206984903ccd75d214197434c 100644 (file)
     <Compile Include="EventArgs\QueueCompletedEventArgs.cs" />\r
     <Compile Include="EventArgs\QueueProgressEventArgs.cs" />\r
     <Compile Include="EventArgs\SettingChangedEventArgs.cs" />\r
+    <Compile Include="Exceptions\GeneralApplicationException.cs" />\r
     <Compile Include="Extensions\StringExtensions.cs" />\r
     <Compile Include="Model\Audio\AudioTrackDefaultsMode.cs" />\r
     <Compile Include="Model\Audio\AudioBehaviourModes.cs" />\r
     <Compile Include="Utilities\EnumHelper.cs" />\r
     <Compile Include="Utilities\Execute.cs" />\r
     <Compile Include="Utilities\ExtensionMethods.cs" />\r
+    <Compile Include="Utilities\GeneralUtilities.cs" />\r
     <Compile Include="Utilities\HandBrakeApp.cs" />\r
     <Compile Include="Utilities\Interfaces\INotifyPropertyChangedEx.cs" />\r
     <Compile Include="Utilities\PropertyChangedBase.cs" />\r
index c73ad26055405283a0803805ca1e4f53099860c9..195e6620038f76a23cfbe3b4cf05975dc6ecf2a7 100644 (file)
@@ -23,6 +23,7 @@ namespace HandBrakeWPF.Helpers
 \r
     using HandBrakeWPF.Services.Interfaces;\r
     using HandBrakeWPF.Services.Queue.Model;\r
+    using HandBrakeWPF.Utilities;\r
 \r
     using IQueueProcessor = HandBrakeWPF.Services.Queue.Interfaces.IQueueProcessor;\r
 \r
index 83ac7a083b14c7196852a440a603f2cdf9537148..4179ed3c7bbdb13dd42713a0e83da596af98c6ea 100644 (file)
@@ -14,15 +14,16 @@ namespace HandBrakeWPF.Services.Encode
     using System.IO;
     using System.Text;
 
-    using HandBrake.ApplicationServices.Exceptions;
     using HandBrake.ApplicationServices.Model;
-    using HandBrake.ApplicationServices.Utilities;
+
+    using HandBrakeWPF.Utilities;
 
     using EncodeCompletedEventArgs = HandBrakeWPF.Services.Encode.EventArgs.EncodeCompletedEventArgs;
     using EncodeCompletedStatus = HandBrakeWPF.Services.Encode.Interfaces.EncodeCompletedStatus;
     using EncodeProgessStatus = HandBrakeWPF.Services.Encode.Interfaces.EncodeProgessStatus;
     using EncodeProgressEventArgs = HandBrakeWPF.Services.Encode.EventArgs.EncodeProgressEventArgs;
     using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
+    using GeneralApplicationException = HandBrakeWPF.Exceptions.GeneralApplicationException;
 
     /// <summary>
     /// A Base Class for the Encode Services.
index ce666f8aa6ea4253393e7c46e1769e382482157a..38299e5b1f4dcc67e40c2215000de80c08043efa 100644 (file)
@@ -18,7 +18,6 @@ namespace HandBrakeWPF.Services.Presets
     using System.Windows;\r
     using System.Xml.Serialization;\r
 \r
-    using HandBrake.ApplicationServices.Exceptions;\r
     using HandBrake.ApplicationServices.Interop;\r
     using HandBrake.ApplicationServices.Interop.Json.Presets;\r
     using HandBrake.ApplicationServices.Model;\r
@@ -31,9 +30,12 @@ namespace HandBrakeWPF.Services.Presets
     using HandBrakeWPF.Services.Presets.Factories;\r
     using HandBrakeWPF.Services.Presets.Interfaces;\r
     using HandBrakeWPF.Services.Presets.Model;\r
+    using HandBrakeWPF.Utilities;\r
 \r
     using Newtonsoft.Json;\r
 \r
+    using GeneralApplicationException = HandBrakeWPF.Exceptions.GeneralApplicationException;\r
+\r
     /// <summary>\r
     /// The preset service manages HandBrake's presets\r
     /// </summary>\r
index 4056633bbce2c58a109adc0af3597813197e5fd2..94d9775d499410f45ba8d4346643cd04154663e3 100644 (file)
@@ -16,14 +16,12 @@ namespace HandBrakeWPF.Services.Queue
     using System.Linq;\r
     using System.Xml.Serialization;\r
 \r
-    using HandBrake.ApplicationServices.Exceptions;\r
-    using HandBrake.ApplicationServices.Model;\r
-    using HandBrake.ApplicationServices.Utilities;\r
-\r
     using HandBrakeWPF.Services.Queue.Model;\r
+    using HandBrakeWPF.Utilities;\r
 \r
     using EncodeCompletedEventArgs = HandBrakeWPF.Services.Encode.EventArgs.EncodeCompletedEventArgs;\r
     using Execute = Caliburn.Micro.Execute;\r
+    using GeneralApplicationException = HandBrakeWPF.Exceptions.GeneralApplicationException;\r
     using IEncode = HandBrakeWPF.Services.Encode.Interfaces.IEncode;\r
     using QueueCompletedEventArgs = HandBrakeWPF.EventArgs.QueueCompletedEventArgs;\r
     using QueueProgressEventArgs = HandBrakeWPF.EventArgs.QueueProgressEventArgs;\r
index 2aae331d6346a6c9a7dd776de02c3b39e55d02fe..b43ec3ce3364588d0437d8841316dd3a0b532277 100644 (file)
@@ -31,6 +31,7 @@ namespace HandBrakeWPF.Services.Scan
     using HandBrakeWPF.Services.Scan.EventArgs;
     using HandBrakeWPF.Services.Scan.Interfaces;
     using HandBrakeWPF.Services.Scan.Model;
+    using HandBrakeWPF.Utilities;
 
     using Chapter = HandBrakeWPF.Services.Scan.Model.Chapter;
     using ScanProgressEventArgs = HandBrake.ApplicationServices.Interop.EventArgs.ScanProgressEventArgs;
index 6c5c6629b690bb0bb049700112980f3ad4694fa1..8f0093009c0b06a5ef3c292a9c69de862add0def 100644 (file)
@@ -16,10 +16,9 @@ namespace HandBrakeWPF.Services
     using System.Reflection;\r
     using System.Xml.Serialization;\r
 \r
-    using HandBrake.ApplicationServices.Exceptions;\r
-\r
     using HandBrakeWPF.Services.Interfaces;\r
 \r
+    using GeneralApplicationException = HandBrakeWPF.Exceptions.GeneralApplicationException;\r
     using SettingChangedEventArgs = HandBrakeWPF.EventArgs.SettingChangedEventArgs;\r
 \r
     /// <summary>\r
similarity index 96%
rename from win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs
rename to win/CS/HandBrakeWPF/Utilities/GeneralUtilities.cs
index f92332c614e4d4d8cecc3d390b43601e635e5a02..18583acd86b2f667a4578e787b7660e42965a516 100644 (file)
-// --------------------------------------------------------------------------------------------------------------------\r
-// <copyright file="GeneralUtilities.cs" company="HandBrake Project (http://handbrake.fr)">\r
-//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
-// </copyright>\r
-// <summary>\r
-//   A Set of Static Utilites\r
-// </summary>\r
-// --------------------------------------------------------------------------------------------------------------------\r
-\r
-namespace HandBrake.ApplicationServices.Utilities\r
-{\r
-    using System;\r
-    using System.Collections.Generic;\r
-    using System.Diagnostics;\r
-    using System.IO;\r
-    using System.Linq;\r
-    using System.Text;\r
-    using System.Windows.Forms;\r
-\r
-    /// <summary>\r
-    /// A Set of Static Utilites\r
-    /// </summary>\r
-    public class GeneralUtilities\r
-    {\r
-        #region Constants and Fields\r
-\r
-        /// <summary>\r
-        /// The Default Log Directory\r
-        /// </summary>\r
-        private static readonly string LogDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
-\r
-        #endregion\r
-\r
-        #region Properties\r
-\r
-        /// <summary>\r
-        /// Gets the number of HandBrake instances running.\r
-        /// </summary>\r
-        public static int ProcessId\r
-        {\r
-            get\r
-            {\r
-                return Process.GetCurrentProcess().Id;\r
-            }\r
-        }\r
-\r
-        #endregion\r
-\r
-        #region Public Methods\r
-\r
-        /// <summary>\r
-        /// Clear all the log files older than 30 Days\r
-        /// </summary>\r
-        /// <param name="daysToKeep">\r
-        /// The Number of Days to Keep\r
-        /// </param>\r
-        public static void ClearLogFiles(int daysToKeep)\r
-        {\r
-            if (Directory.Exists(LogDir))\r
-            {\r
-                // Get all the log files\r
-                var info = new DirectoryInfo(LogDir);\r
-                FileInfo[] logFiles = info.GetFiles("*.txt");\r
-\r
-                // Delete old and excessivly large files (> ~50MB).\r
-                foreach (FileInfo file in logFiles)\r
-                {\r
-                    try\r
-                    {\r
-                        if (file.LastWriteTime < DateTime.Now.AddDays(-daysToKeep))\r
-                        {\r
-                            File.Delete(file.FullName);\r
-                        }\r
-                        else if (file.Length > 50000000)\r
-                        {\r
-                            File.Delete(file.FullName);\r
-                        }\r
-                    }\r
-                    catch (Exception)\r
-                    {\r
-                        // Silently ignore files we can't delete. They are probably being used by the app right now.\r
-                    }\r
-                }\r
-            }\r
-        }\r
-\r
-        /// <summary>\r
-        /// Generate the header for the log file.\r
-        /// </summary>\r
-        /// <returns>\r
-        /// The generatedlog header.\r
-        /// </returns>\r
-        public static StringBuilder CreateLogHeader()\r
-        {\r
-            var logHeader = new StringBuilder();\r
-\r
-            StringBuilder gpuBuilder = new StringBuilder();\r
-            foreach (var item in SystemInfo.GetGPUInfo)\r
-            {\r
-                gpuBuilder.AppendLine(string.Format("  {0}", item));\r
-            }\r
-\r
-            if (string.IsNullOrEmpty(gpuBuilder.ToString().Trim()))\r
-            {\r
-                gpuBuilder.Append("GPU Information is unavailable");\r
-            }\r
-\r
-            logHeader.AppendLine(String.Format("HandBrake {0} - {1}", VersionHelper.GetVersion(), VersionHelper.GetPlatformBitnessVersion()));\r
-            logHeader.AppendLine(String.Format("OS: {0} - {1}", Environment.OSVersion, Environment.Is64BitOperatingSystem ? "64bit" : "32bit"));\r
-            logHeader.AppendLine(String.Format("CPU: {0}", SystemInfo.GetCpuCount));\r
-            logHeader.AppendLine(String.Format("Ram: {0} MB, ", SystemInfo.TotalPhysicalMemory));\r
-            logHeader.AppendLine(String.Format("GPU Information:{0}{1}", Environment.NewLine, gpuBuilder.ToString().TrimEnd()));\r
-            logHeader.AppendLine(String.Format("Screen: {0}x{1}", SystemInfo.ScreenBounds.Bounds.Width, SystemInfo.ScreenBounds.Bounds.Height));\r
-            logHeader.AppendLine(String.Format("Temp Dir: {0}", Path.GetTempPath()));\r
-            logHeader.AppendLine(String.Format("Install Dir: {0}", Application.StartupPath));\r
-            logHeader.AppendLine(String.Format("Data Dir: {0}\n", Application.UserAppDataPath));\r
-\r
-            logHeader.AppendLine("-------------------------------------------");\r
-\r
-            return logHeader;\r
-        }\r
-\r
-        /// <summary>\r
-        /// Return the standard log format line of text for a given log message\r
-        /// </summary>\r
-        /// <param name="message">\r
-        /// The Log Message\r
-        /// </param>\r
-        /// <returns>\r
-        /// A Log Message in the format: "[hh:mm:ss] message"\r
-        /// </returns>\r
-        public static string LogLine(string message)\r
-        {\r
-            return string.Format("[{0}] {1}", DateTime.Now.TimeOfDay, message);\r
-        }\r
-\r
-        /// <summary>\r
-        /// The find hand brake instance ids.\r
-        /// </summary>\r
-        /// <param name="id">\r
-        /// The id.\r
-        /// </param>\r
-        /// <returns>\r
-        /// The <see cref="bool"/>. True if it's a running HandBrake instance.\r
-        /// </returns>\r
-        public static bool IsPidACurrentHandBrakeInstance(int id)\r
-        {\r
-            List<int> ids = Process.GetProcessesByName("HandBrake").Select(process => process.Id).ToList();\r
-            return ids.Contains(id);\r
-        }\r
-\r
-        #endregion\r
-    }\r
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="GeneralUtilities.cs" company="HandBrake Project (http://handbrake.fr)">
+//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+//   A Set of Static Utilites
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Utilities
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using System.IO;
+    using System.Linq;
+    using System.Text;
+    using System.Windows.Forms;
+
+    using HandBrake.ApplicationServices.Utilities;
+
+    /// <summary>
+    /// A Set of Static Utilites
+    /// </summary>
+    public class GeneralUtilities
+    {
+        #region Constants and Fields
+
+        /// <summary>
+        /// The Default Log Directory
+        /// </summary>
+        private static readonly string LogDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
+
+        #endregion
+
+        #region Properties
+
+        /// <summary>
+        /// Gets the number of HandBrake instances running.
+        /// </summary>
+        public static int ProcessId
+        {
+            get
+            {
+                return Process.GetCurrentProcess().Id;
+            }
+        }
+
+        #endregion
+
+        #region Public Methods
+
+        /// <summary>
+        /// Clear all the log files older than 30 Days
+        /// </summary>
+        /// <param name="daysToKeep">
+        /// The Number of Days to Keep
+        /// </param>
+        public static void ClearLogFiles(int daysToKeep)
+        {
+            if (Directory.Exists(LogDir))
+            {
+                // Get all the log files
+                var info = new DirectoryInfo(LogDir);
+                FileInfo[] logFiles = info.GetFiles("*.txt");
+
+                // Delete old and excessivly large files (> ~50MB).
+                foreach (FileInfo file in logFiles)
+                {
+                    try
+                    {
+                        if (file.LastWriteTime < DateTime.Now.AddDays(-daysToKeep))
+                        {
+                            File.Delete(file.FullName);
+                        }
+                        else if (file.Length > 50000000)
+                        {
+                            File.Delete(file.FullName);
+                        }
+                    }
+                    catch (Exception)
+                    {
+                        // Silently ignore files we can't delete. They are probably being used by the app right now.
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// Generate the header for the log file.
+        /// </summary>
+        /// <returns>
+        /// The generatedlog header.
+        /// </returns>
+        public static StringBuilder CreateLogHeader()
+        {
+            var logHeader = new StringBuilder();
+
+            StringBuilder gpuBuilder = new StringBuilder();
+            foreach (var item in SystemInfo.GetGPUInfo)
+            {
+                gpuBuilder.AppendLine(string.Format("  {0}", item));
+            }
+
+            if (string.IsNullOrEmpty(gpuBuilder.ToString().Trim()))
+            {
+                gpuBuilder.Append("GPU Information is unavailable");
+            }
+
+            logHeader.AppendLine(String.Format("HandBrake {0} - {1}", VersionHelper.GetVersion(), VersionHelper.GetPlatformBitnessVersion()));
+            logHeader.AppendLine(String.Format("OS: {0} - {1}", Environment.OSVersion, Environment.Is64BitOperatingSystem ? "64bit" : "32bit"));
+            logHeader.AppendLine(String.Format("CPU: {0}", SystemInfo.GetCpuCount));
+            logHeader.AppendLine(String.Format("Ram: {0} MB, ", SystemInfo.TotalPhysicalMemory));
+            logHeader.AppendLine(String.Format("GPU Information:{0}{1}", Environment.NewLine, gpuBuilder.ToString().TrimEnd()));
+            logHeader.AppendLine(String.Format("Screen: {0}x{1}", SystemInfo.ScreenBounds.Bounds.Width, SystemInfo.ScreenBounds.Bounds.Height));
+            logHeader.AppendLine(String.Format("Temp Dir: {0}", Path.GetTempPath()));
+            logHeader.AppendLine(String.Format("Install Dir: {0}", Application.StartupPath));
+            logHeader.AppendLine(String.Format("Data Dir: {0}\n", Application.UserAppDataPath));
+
+            logHeader.AppendLine("-------------------------------------------");
+
+            return logHeader;
+        }
+
+        /// <summary>
+        /// Return the standard log format line of text for a given log message
+        /// </summary>
+        /// <param name="message">
+        /// The Log Message
+        /// </param>
+        /// <returns>
+        /// A Log Message in the format: "[hh:mm:ss] message"
+        /// </returns>
+        public static string LogLine(string message)
+        {
+            return string.Format("[{0}] {1}", DateTime.Now.TimeOfDay, message);
+        }
+
+        /// <summary>
+        /// The find hand brake instance ids.
+        /// </summary>
+        /// <param name="id">
+        /// The id.
+        /// </param>
+        /// <returns>
+        /// The <see cref="bool"/>. True if it's a running HandBrake instance.
+        /// </returns>
+        public static bool IsPidACurrentHandBrakeInstance(int id)
+        {
+            List<int> ids = Process.GetProcessesByName("HandBrake").Select(process => process.Id).ToList();
+            return ids.Contains(id);
+        }
+
+        #endregion
+    }
 }
\ No newline at end of file
index 7971357fda3a3af811d31002865243268f64f140..a76d24547deeb3073603cbb99046a0dac0fa9a20 100644 (file)
@@ -16,8 +16,6 @@ namespace HandBrakeWPF.ViewModels
 \r
     using Caliburn.Micro;\r
 \r
-    using HandBrake.ApplicationServices.Exceptions;\r
-\r
     using HandBrakeWPF.Properties;\r
     using HandBrakeWPF.Services.Interfaces;\r
     using HandBrakeWPF.Services.Presets.Model;\r
@@ -30,6 +28,7 @@ namespace HandBrakeWPF.ViewModels
 \r
     using ChapterMarker = HandBrakeWPF.Services.Encode.Model.Models.ChapterMarker;\r
     using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;\r
+    using GeneralApplicationException = HandBrakeWPF.Exceptions.GeneralApplicationException;\r
 \r
     /// <summary>\r
     /// The Chapters View Model\r