]> granicus.if.org Git - handbrake/commitdiff
WinGui:WinGui:
authorsr55 <sr55.hb@outlook.com>
Sat, 23 May 2009 14:57:00 +0000 (14:57 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 23 May 2009 14:57:00 +0000 (14:57 +0000)
- Stop button, now allows the CLI to cleanly exit by sending ctrl-c rather than killing the process.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2444 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/Controls/AudioPanel.cs
win/C#/Functions/Encode.cs [deleted file]
win/C#/Functions/Main.cs
win/C#/HandBrakeCS.csproj
win/C#/Queue/QueueHandler.cs [deleted file]
win/C#/Queue/QueueItem.cs [deleted file]
win/C#/frmActivityWindow.cs
win/C#/frmMain.cs
win/C#/frmPreview.cs
win/C#/frmQueue.cs

index 4b44cffed7da4c91b90602b4763c4876acb73aa4..f657106704ece23f80a8daf46d29dc88c6882f3f 100644 (file)
@@ -383,7 +383,5 @@ namespace Handbrake.Controls
                 AudioTrackGroup.Text = "Selected Track: None (Click \"Add Track\" to add)";\r
         }\r
 \r
-        \r
-\r
     }\r
 }\r
diff --git a/win/C#/Functions/Encode.cs b/win/C#/Functions/Encode.cs
deleted file mode 100644 (file)
index 8d93b78..0000000
+++ /dev/null
@@ -1,218 +0,0 @@
-/*  Encode.cs $\r
-       \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
-using System;\r
-using System.Diagnostics;\r
-using System.Windows.Forms;\r
-using System.IO;\r
-using System.Runtime.InteropServices;\r
-\r
-namespace Handbrake.Functions\r
-{\r
-    public class Encode\r
-    {\r
-        // DLL Imports\r
-        [DllImport("user32.dll")]\r
-        private static extern void LockWorkStation();\r
-        [DllImport("user32.dll")]\r
-        private static extern int ExitWindowsEx(int uFlags, int dwReason);\r
\r
-        /// <summary>\r
-        /// Execute a HandBrakeCLI process.\r
-        /// </summary>\r
-        /// <param name="query">The CLI Query</param>\r
-        public Process runCli(string query)\r
-        {\r
-            Process hbProc = new Process();\r
-            try\r
-            {\r
-                string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");\r
-                string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
-                string logPath = Path.Combine(logDir, "last_encode_log.txt");\r
-                string strCmdLine = String.Format(@" CMD /c """"{0}"" {1} 2>""{2}"" """, handbrakeCLIPath, query, logPath);\r
-\r
-                ProcessStartInfo cliStart = new ProcessStartInfo("CMD.exe", strCmdLine);\r
-                if (Properties.Settings.Default.enocdeStatusInGui == "Checked")\r
-                {\r
-                    cliStart.RedirectStandardOutput = true;\r
-                    cliStart.UseShellExecute = false;\r
-                }\r
-                if (Properties.Settings.Default.cli_minimized == "Checked")\r
-                    cliStart.WindowStyle = ProcessWindowStyle.Minimized;\r
-\r
-                Process[] before = Process.GetProcesses(); // Get a list of running processes before starting.\r
-                hbProc = Process.Start(cliStart);\r
-                processID = Main.getCliProcess(before);\r
-                isEncoding = true;\r
-                currentQuery = query;\r
-\r
-                // Set the process Priority\r
-                Process hbCliProcess = null;\r
-                if (processID != -1)\r
-                    hbCliProcess = Process.GetProcessById(processID);\r
-\r
-                if (hbCliProcess != null)\r
-                    switch (Properties.Settings.Default.processPriority)\r
-                    {\r
-                        case "Realtime":\r
-                            hbCliProcess.PriorityClass = ProcessPriorityClass.RealTime;\r
-                            break;\r
-                        case "High":\r
-                            hbCliProcess.PriorityClass = ProcessPriorityClass.High;\r
-                            break;\r
-                        case "Above Normal":\r
-                            hbCliProcess.PriorityClass = ProcessPriorityClass.AboveNormal;\r
-                            break;\r
-                        case "Normal":\r
-                            hbCliProcess.PriorityClass = ProcessPriorityClass.Normal;\r
-                            break;\r
-                        case "Low":\r
-                            hbCliProcess.PriorityClass = ProcessPriorityClass.Idle;\r
-                            break;\r
-                        default:\r
-                            hbCliProcess.PriorityClass = ProcessPriorityClass.BelowNormal;\r
-                            break;\r
-                    }\r
-            }\r
-            catch (Exception exc)\r
-            {\r
-                MessageBox.Show("An error occured in runCli()\n Error Information: \n\n" + exc);\r
-            }\r
-\r
-            return hbProc;\r
-        }\r
-\r
-        /// <summary>\r
-        /// Kill the CLI process\r
-        /// </summary>\r
-        public void closeCLI()\r
-        {\r
-            Process[] prs = Process.GetProcesses();\r
-            foreach (Process process in prs)\r
-            {\r
-                if (process.Id == processID)\r
-                {\r
-                    process.Refresh();\r
-                    if (!process.HasExited)\r
-                        process.Kill();\r
-\r
-                    process.WaitForExit();\r
-                }\r
-            } \r
-        }\r
-\r
-        /// <summary>\r
-        /// Perform an action after an encode. e.g a shutdown, standby, restart etc.\r
-        /// </summary>\r
-        public void afterEncodeAction()\r
-        {\r
-            isEncoding = false;\r
-            currentQuery = String.Empty;\r
-            // Do something whent he encode ends.\r
-            switch (Properties.Settings.Default.CompletionOption)\r
-            {\r
-                case "Shutdown":\r
-                    Process.Start("Shutdown", "-s -t 60");\r
-                    break;\r
-                case "Log Off":\r
-                    ExitWindowsEx(0, 0);\r
-                    break;\r
-                case "Suspend":\r
-                    Application.SetSuspendState(PowerState.Suspend, true, true);\r
-                    break;\r
-                case "Hibernate":\r
-                    Application.SetSuspendState(PowerState.Hibernate, true, true);\r
-                    break;\r
-                case "Lock System":\r
-                    LockWorkStation();\r
-                    break;\r
-                case "Quit HandBrake":\r
-                    Application.Exit();\r
-                    break;\r
-                default:\r
-                    break;\r
-            }\r
-        }\r
-\r
-        /// <summary>\r
-        /// Append the CLI query to the start of the log file.\r
-        /// </summary>\r
-        /// <param name="query"></param>\r
-        public void addCLIQueryToLog(string query)\r
-        {\r
-            string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
-            string logPath = Path.Combine(logDir, "last_encode_log.txt");\r
-\r
-            StreamReader reader = new StreamReader(File.Open(logPath, FileMode.Open, FileAccess.Read));\r
-            String log = reader.ReadToEnd();\r
-            reader.Close();\r
-\r
-            StreamWriter writer = new StreamWriter(File.Create(logPath));\r
-\r
-            writer.Write("### CLI Query: " + query + "\n\n");\r
-            writer.Write("#########################################\n\n");\r
-            writer.WriteLine(log);\r
-            writer.Flush();\r
-            writer.Close();\r
-        }\r
-\r
-        /// <summary>\r
-        /// Save a copy of the log to the users desired location or a default location\r
-        /// if this feature is enabled in options.\r
-        /// </summary>\r
-        /// <param name="destination"></param>\r
-        public void copyLog(string destination)\r
-        {\r
-            try\r
-            {\r
-                string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
-                string tempLogFile = Path.Combine(logDir, "last_encode_log.txt");\r
-\r
-                string encodeDestinationPath = Path.GetDirectoryName(destination);\r
-                String[] destName = destination.Split('\\');\r
-                string destinationFile = destName[destName.Length - 1];\r
-                string encodeLogFile = DateTime.Now.ToString().Replace("/", "-").Replace(":", "-") + " " + destinationFile + ".txt";\r
-\r
-                // Make sure the log directory exists.\r
-                if (!Directory.Exists(logDir))\r
-                    Directory.CreateDirectory(logDir);\r
-\r
-                // Copy the Log to HandBrakes log folder in the users applciation data folder.\r
-                File.Copy(tempLogFile, Path.Combine(logDir, encodeLogFile));\r
-\r
-                // Save a copy of the log file in the same location as the enocde.\r
-                if (Properties.Settings.Default.saveLogWithVideo == "Checked")\r
-                    File.Copy(tempLogFile, Path.Combine(encodeDestinationPath, encodeLogFile));\r
-\r
-                // Save a copy of the log file to a user specified location\r
-                if (Directory.Exists(Properties.Settings.Default.saveLogPath))\r
-                    if (Properties.Settings.Default.saveLogPath != String.Empty && Properties.Settings.Default.saveLogToSpecifiedPath == "Checked")\r
-                        File.Copy(tempLogFile, Path.Combine(Properties.Settings.Default.saveLogPath, encodeLogFile));\r
-            }\r
-            catch (Exception exc)\r
-            {\r
-                MessageBox.Show("Something went a bit wrong trying to copy your log file.\nError Information:\n\n" + exc, "Error",\r
-                                MessageBoxButtons.OK, MessageBoxIcon.Error);\r
-            }\r
-        }\r
-\r
-        /// <summary>\r
-        /// Returns whether HandBrake is currently encoding or not.\r
-        /// </summary>\r
-        public Boolean isEncoding { get; set; }\r
-\r
-        /// <summary>\r
-        /// Returns the currently encoding query string\r
-        /// </summary>\r
-        public String currentQuery { get; set; }\r
-\r
-        /// <summary>\r
-        /// Get the process ID of the current encode.\r
-        /// </summary>\r
-        public int processID { get; set; }\r
-\r
-    }\r
-}\r
index a95f5e144a210c2c3e67dc5f673e5200734f9168..be46465d4daa166289ba50e76e494c0a20be9d3c 100644 (file)
@@ -12,13 +12,14 @@ using System.Text.RegularExpressions;
 using System.Collections.Generic;\r
 using System.Xml.Serialization;\r
 using System.Threading;\r
+using Handbrake.EncodeQueue;\r
 \r
 namespace Handbrake.Functions\r
 {\r
     static class Main\r
     {\r
         // Private Variables\r
-        private static readonly XmlSerializer ser = new XmlSerializer(typeof(List<Queue.QueueItem>));\r
+        private static readonly XmlSerializer ser = new XmlSerializer(typeof(List<QueueItem>));\r
 \r
         /// <summary>\r
         /// Calculate the duration of the selected title and chapters\r
@@ -358,7 +359,7 @@ namespace Handbrake.Functions
                 {\r
                     using (FileStream strm = new FileStream(tempPath, FileMode.Open, FileAccess.Read))\r
                     {\r
-                        List<Queue.QueueItem> list = ser.Deserialize(strm) as List<Queue.QueueItem>;\r
+                        List<QueueItem> list = ser.Deserialize(strm) as List<QueueItem>;\r
                         if (list != null)\r
                             if (list.Count != 0)\r
                                 return true;\r
index 7155e3114d5402bd988710a2293320dc4c8aeead..b082ce6ab0fcd374d83ce71cd314036a3beb44be 100644 (file)
     <Compile Include="frmTestWindow.Designer.cs">\r
       <DependentUpon>frmTestWindow.cs</DependentUpon>\r
     </Compile>\r
+    <Compile Include="Functions\Win32.cs" />\r
     <Compile Include="Presets\preset.cs" />\r
     <Compile Include="Presets\PresetsHandler.cs" />\r
-    <Compile Include="Queue\QueueHandler.cs" />\r
+    <Compile Include="EncodeQueue\EncodeProcess.cs" />\r
+    <Compile Include="EncodeQueue\QueueHandler.cs" />\r
     <Compile Include="Functions\AppcastReader.cs" />\r
-    <Compile Include="Functions\Encode.cs" />\r
+    <Compile Include="EncodeQueue\Encode.cs" />\r
     <Compile Include="Functions\QueryParser.cs" />\r
     <Compile Include="Parsing\AudioTrack.cs" />\r
     <Compile Include="Parsing\Chapter.cs" />\r
     <Compile Include="frmSplashScreen.Designer.cs">\r
       <DependentUpon>frmSplashScreen.cs</DependentUpon>\r
     </Compile>\r
-    <Compile Include="Queue\QueueItem.cs" />\r
+    <Compile Include="EncodeQueue\QueueItem.cs" />\r
   </ItemGroup>\r
   <ItemGroup>\r
     <Content Include="handbrakepineapple.ico" />\r
diff --git a/win/C#/Queue/QueueHandler.cs b/win/C#/Queue/QueueHandler.cs
deleted file mode 100644 (file)
index 2473b38..0000000
+++ /dev/null
@@ -1,333 +0,0 @@
-/*  QueueHandler.cs $\r
-       \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
-using System;\r
-using System.Collections.Generic;\r
-using System.IO;\r
-using System.Windows.Forms;\r
-using System.Xml.Serialization;\r
-using System.Threading;\r
-using System.Diagnostics;\r
-using Handbrake.Functions;\r
-\r
-namespace Handbrake.Queue\r
-{\r
-    public class QueueHandler\r
-    {\r
-        Encode encodeHandler = new Encode();\r
-        private static XmlSerializer ser = new XmlSerializer(typeof(List<QueueItem>));\r
-        List<QueueItem> queue = new List<QueueItem>();\r
-        int id; // Unique identifer number for each job\r
-\r
-        #region Queue Handling\r
-        public List<QueueItem> getQueue()\r
-        {\r
-            return queue;\r
-        }\r
-\r
-        /// <summary>\r
-        /// Get's the next CLI query for encoding\r
-        /// </summary>\r
-        /// <returns>String</returns>\r
-        private string getNextItemForEncoding()\r
-        {\r
-            QueueItem job = queue[0];\r
-            String query = job.Query;\r
-            lastQueueItem = job;\r
-            remove(0);    // Remove the item which we are about to pass out.\r
-            return query;\r
-        }\r
-\r
-        /// <summary>\r
-        /// Get the last query that was returned by getNextItemForEncoding()\r
-        /// </summary>\r
-        /// <returns></returns>\r
-        public QueueItem lastQueueItem { get; set; }\r
-\r
-        /// <summary>\r
-        /// Add's a new item to the queue\r
-        /// </summary>\r
-        /// <param name="query">String</param>\r
-        /// <param name="source"></param>\r
-        /// <param name="destination"></param>\r
-        public void add(string query, string source, string destination)\r
-        {\r
-            QueueItem newJob = new QueueItem { Id = id, Query = query, Source = source, Destination = destination };\r
-            id++;\r
-\r
-            queue.Add(newJob);\r
-        }\r
-\r
-        /// <summary>\r
-        /// Check to see if a destination path is already on the queue\r
-        /// </summary>\r
-        /// <param name="destination">Destination path</param>\r
-        /// <returns>Boolean True/False. True = Path Exists</returns>\r
-        public Boolean checkDestinationPath(string destination)\r
-        {\r
-            foreach (QueueItem checkItem in queue)\r
-            {\r
-                if (checkItem.Destination.Contains(destination.Replace("\\\\", "\\")))\r
-                    return true;\r
-            }\r
-            return false;\r
-        }\r
-\r
-        /// <summary>\r
-        /// Removes an item from the queue.\r
-        /// </summary>\r
-        /// <param name="index">Index</param>\r
-        /// <returns>Bolean true if successful</returns>\r
-        public void remove(int index)\r
-        {\r
-            queue.RemoveAt(index);\r
-        }\r
-\r
-        /// <summary>\r
-        /// Returns how many items are in the queue\r
-        /// </summary>\r
-        /// <returns>Int</returns>\r
-        public int count()\r
-        {\r
-            return queue.Count;\r
-        }\r
-\r
-        /// <summary>\r
-        /// Move an item with an index x, up in the queue\r
-        /// </summary>\r
-        /// <param name="index">Int</param>\r
-        public void moveUp(int index)\r
-        {\r
-            if (index > 0)\r
-            {\r
-                QueueItem item = queue[index];\r
-\r
-                queue.RemoveAt(index);\r
-                queue.Insert((index - 1), item);\r
-            }\r
-        }\r
-\r
-        /// <summary>\r
-        /// Move an item with an index x, down in the queue\r
-        /// </summary>\r
-        /// <param name="index">Int</param>\r
-        public void moveDown(int index)\r
-        {\r
-            if (index < queue.Count - 1)\r
-            {\r
-                QueueItem item = queue[index];\r
-\r
-                queue.RemoveAt(index);\r
-                queue.Insert((index + 1), item);\r
-            }\r
-        }\r
-\r
-        /// <summary>\r
-        /// Writes the current queue to disk. hb_queue_recovery.xml\r
-        /// This function is called after getNextItemForEncoding()\r
-        /// </summary>\r
-        public void write2disk(string file)\r
-        {\r
-            string tempPath = file == "hb_queue_recovery.xml" ? Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml") : file;\r
-\r
-            try\r
-            {\r
-                using (FileStream strm = new FileStream(tempPath, FileMode.Create, FileAccess.Write))\r
-                {\r
-                    ser.Serialize(strm, queue);\r
-                    strm.Close();\r
-                    strm.Dispose();\r
-                }\r
-            }\r
-            catch (Exception)\r
-            {\r
-                // Any Errors will be out of diskspace/permissions problems. \r
-                // Don't report them as they'll annoy the user.\r
-            }\r
-        }\r
-\r
-        /// <summary>\r
-        /// Writes the current queue to disk to the location specified in file\r
-        /// </summary>\r
-        /// <param name="file"></param>\r
-        public void writeBatchScript(string file)\r
-        {\r
-            string queries = "";\r
-            foreach (QueueItem queue_item in queue)\r
-            {\r
-                string q_item = queue_item.Query;\r
-                string fullQuery = '"' + Application.StartupPath + "\\HandBrakeCLI.exe" + '"' + q_item;\r
-\r
-                if (queries == string.Empty)\r
-                    queries = queries + fullQuery;\r
-                else\r
-                    queries = queries + " && " + fullQuery;\r
-            }\r
-            string strCmdLine = queries;\r
-\r
-            if (file != "")\r
-            {\r
-                try\r
-                {\r
-                    // Create a StreamWriter and open the file, Write the batch file query to the file and \r
-                    // Close the stream\r
-                    StreamWriter line = new StreamWriter(file);\r
-                    line.WriteLine(strCmdLine);\r
-                    line.Close();\r
-\r
-                    MessageBox.Show("Your batch script has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
-                }\r
-                catch (Exception)\r
-                {\r
-                    MessageBox.Show("Unable to write to the file. Please make sure that the location has the correct permissions for file writing.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
-                }\r
-\r
-            }\r
-        }\r
-\r
-        /// <summary>\r
-        /// Recover the queue from hb_queue_recovery.xml\r
-        /// </summary>\r
-        public void recoverQueue(string file)\r
-        {\r
-            string tempPath;\r
-            if (file == "hb_queue_recovery.xml")\r
-                tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml");\r
-            else\r
-                tempPath = file;\r
-\r
-            if (File.Exists(tempPath))\r
-            {\r
-                using (FileStream strm = new FileStream(tempPath, FileMode.Open, FileAccess.Read))\r
-                {\r
-                    if (strm.Length != 0)\r
-                    {\r
-                        List<QueueItem> list = ser.Deserialize(strm) as List<QueueItem>;\r
-\r
-                        if (list != null)\r
-                            foreach (QueueItem item in list)\r
-                                queue.Add(item);\r
-\r
-                        if (file != "hb_queue_recovery.xml")\r
-                            write2disk("hb_queue_recovery.xml");\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        #endregion\r
-\r
-        #region Encoding\r
-\r
-        public Boolean isEncodeStarted { get; private set; }\r
-        public Boolean isPaused { get; private set; }\r
-        public Boolean isEncoding { get; private set; }\r
-        public Process hbProc { get; set; }\r
-\r
-        public void startEncode()\r
-        {\r
-            Thread theQueue;\r
-            if (this.count() != 0)\r
-            {\r
-                if (isPaused)\r
-                    isPaused = false;\r
-                else\r
-                {\r
-                    isPaused = false;\r
-                    try\r
-                    {\r
-                        theQueue = new Thread(startProc) { IsBackground = true };\r
-                        theQueue.Start();\r
-                    }\r
-                    catch (Exception exc)\r
-                    {\r
-                        MessageBox.Show(exc.ToString());\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        public void pauseEncode()\r
-        {\r
-            isPaused = true;\r
-            EncodePaused(null);\r
-        }\r
-        public void endEncode()\r
-        {\r
-            encodeHandler.closeCLI();\r
-        }\r
-\r
-        private void startProc(object state)\r
-        {\r
-            try\r
-            {\r
-                // Run through each item on the queue\r
-                while (this.count() != 0)\r
-                {\r
-                    string query = getNextItemForEncoding();\r
-                    write2disk("hb_queue_recovery.xml"); // Update the queue recovery file\r
-\r
-                    hbProc = encodeHandler.runCli(query);\r
-                    EncodeStarted(null);\r
-                    hbProc.WaitForExit();\r
-\r
-                    encodeHandler.addCLIQueryToLog(query);\r
-                    encodeHandler.copyLog(lastQueueItem.Destination);\r
-\r
-                    hbProc.Close();\r
-                    hbProc.Dispose();\r
-                    EncodeFinished(null);\r
-\r
-                    while (isPaused) // Need to find a better way of doing this.\r
-                    {\r
-                        Thread.Sleep(10000);\r
-                    }\r
-                }\r
-                EncodeQueueFinished(null);\r
-\r
-                // After the encode is done, we may want to shutdown, suspend etc.\r
-                encodeHandler.afterEncodeAction();\r
-            }\r
-            catch (Exception exc)\r
-            {\r
-                throw new Exception(exc.ToString());\r
-            }\r
-        }\r
-        #endregion\r
-\r
-        #region Events\r
-        public event EventHandler OnEncodeStart;\r
-        public event EventHandler OnPaused;\r
-        public event EventHandler OnEncodeEnded;\r
-        public event EventHandler OnQueueFinished;\r
-\r
-        // Invoke the Changed event; called whenever encodestatus changes:\r
-        protected virtual void EncodeStarted(EventArgs e)\r
-        {\r
-            if (OnEncodeStart != null)\r
-                OnEncodeStart(this, e);\r
-\r
-            isEncoding = true;\r
-        }\r
-        protected virtual void EncodePaused(EventArgs e)\r
-        {\r
-            if (OnPaused != null)\r
-                OnPaused(this, e);\r
-        }\r
-        protected virtual void EncodeFinished(EventArgs e)\r
-        {\r
-            if (OnEncodeEnded != null)\r
-                OnEncodeEnded(this, e);\r
-\r
-            isEncoding = false;\r
-        }\r
-        protected virtual void EncodeQueueFinished(EventArgs e)\r
-        {\r
-            if (OnQueueFinished != null)\r
-                OnQueueFinished(this, e);\r
-        }\r
-        #endregion\r
-\r
-    }\r
-}\r
diff --git a/win/C#/Queue/QueueItem.cs b/win/C#/Queue/QueueItem.cs
deleted file mode 100644 (file)
index 386fef2..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*  QueueItem.cs $\r
-       \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.Queue\r
-{\r
-    public class QueueItem\r
-    {\r
-        /// <summary>\r
-        /// Get or Set the job id.\r
-        /// </summary>\r
-        public int Id { get; set; }\r
-\r
-        /// <summary>\r
-        /// Get or Set the query string.\r
-        /// </summary>\r
-        public string Query { get; set; }\r
-\r
-        /// <summary>\r
-        /// Get or set the source file of encoding\r
-        /// </summary>\r
-        public string Source { get; set; }\r
-\r
-        /// <summary>\r
-        /// Get or set the destination for the file to be encoded.\r
-        /// </summary>\r
-        public string Destination { get; set; }\r
-    }\r
-}
\ No newline at end of file
index dc979f28e8f548a424adde94ebe37b1bbeeb8e96..981ed2f34fc6adcef6422ffec62c613c0215339a 100644 (file)
@@ -9,6 +9,7 @@ using System.Windows.Forms;
 using System.IO;\r
 using System.Threading;\r
 using System.Runtime.InteropServices;\r
+using Handbrake.EncodeQueue;\r
 using Microsoft.Win32;\r
 \r
 \r
@@ -19,7 +20,7 @@ namespace Handbrake
         delegate void SetTextCallback(string text);\r
         String read_file;\r
         Thread monitor;\r
-        Queue.QueueHandler encodeQueue;\r
+        QueueHandler encodeQueue;\r
         int position;  // Position in the arraylist reached by the current log output in the rtf box.\r
         string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
         private frmMain mainWin;\r
@@ -27,7 +28,7 @@ namespace Handbrake
         /// <summary>\r
         /// This window should be used to display the RAW output of the handbrake CLI which is produced during an encode.\r
         /// </summary>\r
-        public frmActivityWindow(string file, Queue.QueueHandler eh, frmMain mw)\r
+        public frmActivityWindow(string file, QueueHandler eh, frmMain mw)\r
         {\r
             InitializeComponent();\r
 \r
index cc28130acbef52f72131daf390d15502ee34d036..15c3e5588519e9169526bbb2b86dd78967d32066 100644 (file)
@@ -11,9 +11,9 @@ using System.Windows.Forms;
 using System.IO;\r
 using System.Diagnostics;\r
 using System.Threading;\r
+using Handbrake.EncodeQueue;\r
 using Handbrake.Functions;\r
 using Handbrake.Presets;\r
-using Handbrake.Queue;\r
 using Handbrake.Parsing;\r
 \r
 namespace Handbrake\r
@@ -218,7 +218,7 @@ namespace Handbrake
             // Experimental HBProc Process Monitoring.\r
             if (Properties.Settings.Default.enocdeStatusInGui == "Checked")\r
             {\r
-                HBProcess = encodeQueue.hbProc;\r
+                HBProcess = encodeQueue.encodeProcess.hbProcProcess;\r
                 Thread EncodeMon = new Thread(encodeMonitorThread);\r
                 EncodeMon.Start();\r
             }\r
@@ -584,13 +584,16 @@ namespace Handbrake
         {\r
             if (btn_start.Text == "Stop")\r
             {\r
-                DialogResult result = MessageBox.Show("Are you sure you wish to cancel the encode? Please note that this may break the encoded file. \nTo safely cancel your encode, press ctrl-c on your keyboard in the CLI window. This *may* allow you to preview your encoded content.", "Cancel Encode?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+                DialogResult result = MessageBox.Show("Are you sure you wish to cancel the encode?", "Cancel Encode?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
 \r
                 if (result == DialogResult.Yes)\r
                 {\r
                     // Pause The Queue\r
-                    encodeQueue.pauseEncode();\r
-                    encodeQueue.endEncode();\r
+                    encodeQueue.pauseEncodeQueue();\r
+\r
+                    // Allow the CLI to exit cleanly\r
+                    Win32.SetForegroundWindow(encodeQueue.encodeProcess.processHandle);\r
+                    SendKeys.Send("^C");\r
 \r
                     // Update the GUI\r
                     setEncodeFinished();\r
index 946f04947d691a288dbf4d7f3865bd5f364c49ec..7ea4727726685efe4d9597c235a433bf697112e1 100644 (file)
@@ -5,6 +5,7 @@ using System.Diagnostics;
 using System.Runtime.InteropServices;\r
 using System.IO;\r
 using AxQTOControlLib;\r
+using Handbrake.EncodeQueue;\r
 using Handbrake.Functions;\r
 using QTOControlLib;\r
 using QTOLibrary;\r
@@ -88,7 +89,7 @@ namespace Handbrake
                 MessageBox.Show(this, "Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
             else\r
             {\r
-                hbProc = process.runCli((string)state);\r
+                hbProc = process.runCli((string)state).hbProcProcess;\r
                 hbProc.WaitForExit();\r
                 hbProc = null;\r
                 encodeCompleted();\r
index 39f54823671b0eb8eb366356f4de756ae2901171..88da988ba35ba06aeedc0a653d05fcbb5e5460a0 100644 (file)
@@ -8,15 +8,16 @@ using System;
 using System.Collections.Generic;\r
 using System.ComponentModel;\r
 using System.Windows.Forms;\r
+using Handbrake.EncodeQueue;\r
 \r
 namespace Handbrake\r
 {\r
     public partial class frmQueue : Form\r
     {\r
         private delegate void UpdateHandler();\r
-        Queue.QueueHandler queue;\r
+        QueueHandler queue;\r
 \r
-        public frmQueue(Queue.QueueHandler q)\r
+        public frmQueue(QueueHandler q)\r
         {\r
             InitializeComponent();\r
 \r
@@ -84,7 +85,7 @@ namespace Handbrake
         }\r
         private void btn_pause_Click(object sender, EventArgs e)\r
         {\r
-            queue.pauseEncode();\r
+            queue.pauseEncodeQueue();\r
             setUIEncodeFinished();\r
             resetQueue();\r
             MessageBox.Show("No further items on the queue will start. The current encode process will continue until it is finished. \nClick 'Encode' when you wish to continue encoding the queue.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
@@ -139,8 +140,8 @@ namespace Handbrake
             }\r
 \r
             list_queue.Items.Clear();\r
-            List<Queue.QueueItem> theQueue = queue.getQueue();\r
-            foreach (Queue.QueueItem queue_item in theQueue)\r
+            List<QueueItem> theQueue = queue.getQueue();\r
+            foreach (QueueItem queue_item in theQueue)\r
             {\r
                 string q_item = queue_item.Query;\r
                 Functions.QueryParser parsed = Functions.QueryParser.Parse(q_item);\r