]> granicus.if.org Git - handbrake/commitdiff
WinGui: Rectored some Encode/Queue service code. This restoes "Quit HandBrake" when...
authorsr55 <sr55.hb@outlook.com>
Sun, 19 May 2013 16:49:50 +0000 (16:49 +0000)
committersr55 <sr55.hb@outlook.com>
Sun, 19 May 2013 16:49:50 +0000 (16:49 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5485 b64f7644-9d1e-0410-96f1-a4d463321fa5

15 files changed:
win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs
win/CS/HandBrake.ApplicationServices/EventArgs/EncodeCompletedEventArgs.cs
win/CS/HandBrake.ApplicationServices/Services/Encode.cs
win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs
win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
win/CS/HandBrake.Server/Program.cs
win/CS/HandBrakeWPF/HandBrakeWPF.csproj
win/CS/HandBrakeWPF/Services/Interfaces/INotificationService.cs
win/CS/HandBrakeWPF/Services/Interfaces/IPrePostActionService.cs [new file with mode: 0644]
win/CS/HandBrakeWPF/Services/PrePostActionService.cs [new file with mode: 0644]
win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs
win/CS/HandBrakeWPF/UserSettingConstants.cs
win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs

index 7e3ee4583e47aa9b1c28f28febd79cdd066b07d9..78f5b18abd363509e64db922fc26270623bf9248 100644 (file)
@@ -19,21 +19,11 @@ namespace HandBrake.ApplicationServices
         /// </summary>\r
         public const string Verbosity = "Verbosity";\r
 \r
-        /// <summary>\r
-        /// When Complete Action\r
-        /// </summary>\r
-        public const string WhenCompleteAction = "WhenCompleteAction";\r
-\r
         /// <summary>\r
         /// Process Priority\r
         /// </summary>\r
         public const string ProcessPriority = "ProcessPriority";\r
 \r
-        /// <summary>\r
-        /// Prevent Sleep\r
-        /// </summary>\r
-        public const string PreventSleep = "PreventSleep";\r
-\r
         /// <summary>\r
         /// Save Log Directory\r
         /// </summary>\r
@@ -59,21 +49,6 @@ namespace HandBrake.ApplicationServices
         /// </summary>\r
         public const string DisableLibDvdNav = "DisableLibDvdNav";\r
 \r
-        /// <summary>\r
-        /// Send file enabled.\r
-        /// </summary>\r
-        public const string SendFile = "SendFile";\r
-\r
-        /// <summary>\r
-        /// Send file to application path\r
-        /// </summary>\r
-        public const string SendFileTo = "SendFileTo";\r
-\r
-        /// <summary>\r
-        /// Send file to arguments\r
-        /// </summary>\r
-        public const string SendFileToArgs = "SendFileToArgs";\r
-\r
         /// <summary>\r
         /// Min Title Scan Duration\r
         /// </summary>\r
index 44a66cac74c28bf93c726a6028cfa6a8c71f67f7..2bbb7ab976fa8b9e9d9bbe61defbb4590f55dbb8 100644 (file)
@@ -12,6 +12,8 @@ namespace HandBrake.ApplicationServices.EventArgs
     using System;\r
     using System.Runtime.Serialization;\r
 \r
+    using HandBrake.ApplicationServices.Model;\r
+\r
     /// <summary>\r
     /// Encode Progress Event Args\r
     /// </summary>\r
@@ -30,13 +32,23 @@ namespace HandBrake.ApplicationServices.EventArgs
         /// <param name="errorInformation">\r
         /// The error information.\r
         /// </param>\r
-        public EncodeCompletedEventArgs(bool sucessful, Exception exception, string errorInformation)\r
+        /// <param name="filename">\r
+        /// The filename.\r
+        /// </param>\r
+        public EncodeCompletedEventArgs(bool sucessful, Exception exception, string errorInformation, string filename)\r
         {\r
             this.Successful = sucessful;\r
             this.Exception = exception;\r
             this.ErrorInformation = errorInformation;\r
+            this.FileName = filename;\r
         }\r
 \r
+        /// <summary>\r
+        /// Gets or sets the file name.\r
+        /// </summary>\r
+        [DataMember]\r
+        public string FileName { get; set; }\r
+\r
         /// <summary>\r
         /// Gets or sets a value indicating whether Successful.\r
         /// </summary>\r
index b4f57252158e390be3cf545b4948775c8e7d23c0..4779d353ebe01598954175da213d881c1b07a8b4 100644 (file)
@@ -14,9 +14,8 @@ namespace HandBrake.ApplicationServices.Services
     using System.IO;\r
     using System.Windows.Forms;\r
 \r
-    using Caliburn.Micro;\r
-\r
     using HandBrake.ApplicationServices.EventArgs;\r
+    using HandBrake.ApplicationServices.Exceptions;\r
     using HandBrake.ApplicationServices.Model;\r
     using HandBrake.ApplicationServices.Services.Base;\r
     using HandBrake.ApplicationServices.Services.Interfaces;\r
@@ -95,11 +94,10 @@ namespace HandBrake.ApplicationServices.Services
             {\r
                 if (this.IsEncoding)\r
                 {\r
-                    throw new Exception("HandBrake is already encodeing.");\r
+                    throw new GeneralApplicationException("HandBrake is already encodeing.", "Please try again in a minute", null);\r
                 }\r
 \r
                 this.IsEncoding = true;\r
-\r
                 this.currentTask = encodeQueueTask;\r
 \r
                 if (enableLogging)\r
@@ -115,11 +113,6 @@ namespace HandBrake.ApplicationServices.Services
                     }\r
                 }\r
 \r
-                if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep))\r
-                {\r
-                    Win32.PreventSleep();\r
-                }\r
-\r
                 // Make sure the path exists, attempt to create it if it doesn't\r
                 this.VerifyEncodeDestinationPath(currentTask);\r
 \r
@@ -200,9 +193,10 @@ namespace HandBrake.ApplicationServices.Services
             catch (Exception exc)\r
             {\r
                 encodeQueueTask.Status = QueueItemStatus.Error;\r
+                this.IsEncoding = false;\r
                 this.InvokeEncodeCompleted(\r
                     new EncodeCompletedEventArgs(\r
-                        false, null, "An Error occured when trying to encode this source. "));\r
+                        false, exc, "An Error occured when trying to encode this source. ", this.currentTask.Task.Destination));\r
                 throw;\r
             }\r
         }\r
@@ -261,17 +255,9 @@ namespace HandBrake.ApplicationServices.Services
                 // This exception doesn't warrent user interaction, but it should be logged (TODO)\r
             }\r
 \r
-            Execute.OnUIThread(() =>\r
-            {\r
-                if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep))\r
-                {\r
-                    Win32.AllowSleep();\r
-                }\r
-            });\r
-\r
             this.currentTask.Status = QueueItemStatus.Completed;\r
             this.IsEncoding = false;\r
-            this.InvokeEncodeCompleted(new EncodeCompletedEventArgs(true, null, string.Empty));\r
+            this.InvokeEncodeCompleted(new EncodeCompletedEventArgs(true, null, string.Empty, this.currentTask.Task.Destination));\r
         }\r
 \r
         /// <summary>\r
index 33453dad877d6e4f9b6cbc541632a42fa49bd78a..f7247f6cf2e48223d1ec4bf12f3598a3b9c7f2e3 100644 (file)
@@ -11,7 +11,6 @@ namespace HandBrake.ApplicationServices.Services
 {\r
     using System;\r
     using System.Diagnostics;\r
-    using System.Globalization;\r
 \r
     using HandBrake.ApplicationServices.Model;\r
     using HandBrake.ApplicationServices.Services.Base;\r
@@ -57,6 +56,11 @@ namespace HandBrake.ApplicationServices.Services
         /// </summary>\r
         private bool loggingEnabled;\r
 \r
+        /// <summary>\r
+        /// The Current Task\r
+        /// </summary>\r
+        private QueueTask currentTask;\r
+\r
         #endregion\r
 \r
         /// <summary>\r
@@ -95,6 +99,7 @@ namespace HandBrake.ApplicationServices.Services
         {\r
             this.startTime = DateTime.Now;\r
             this.loggingEnabled = enableLogging;\r
+            this.currentTask = job;\r
 \r
             try\r
             {\r
@@ -123,12 +128,6 @@ namespace HandBrake.ApplicationServices.Services
                     }\r
                 }\r
 \r
-                // Prvent the system from sleeping if the user asks\r
-                if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep) )\r
-                {\r
-                    Win32.PreventSleep();\r
-                }\r
-\r
                 // Verify the Destination Path Exists, and if not, create it.\r
                 this.VerifyEncodeDestinationPath(job);\r
 \r
@@ -163,7 +162,7 @@ namespace HandBrake.ApplicationServices.Services
             }\r
             catch (Exception exc)\r
             {\r
-                this.InvokeEncodeCompleted(new EncodeCompletedEventArgs(false, exc, "An Error has occured."));\r
+                this.InvokeEncodeCompleted(new EncodeCompletedEventArgs(false, exc, "An Error has occured.", this.currentTask.Task.Destination));\r
             }\r
         }\r
 \r
@@ -271,13 +270,8 @@ namespace HandBrake.ApplicationServices.Services
 \r
             this.InvokeEncodeCompleted(\r
                 e.Error\r
-                    ? new EncodeCompletedEventArgs(false, null, string.Empty)\r
-                    : new EncodeCompletedEventArgs(true, null, string.Empty));\r
-\r
-            if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep))\r
-            {\r
-                Win32.AllowSleep();\r
-            }\r
+                    ? new EncodeCompletedEventArgs(false, null, string.Empty, this.currentTask.Task.Destination)\r
+                    : new EncodeCompletedEventArgs(true, null, string.Empty, this.currentTask.Task.Destination));\r
 \r
             this.ShutdownFileWriter();\r
         }\r
index 79b348ae42a2c7d2ad52a1e772da076fc174e8a1..92f69142c02dce908ebdbcb55871f36ef1f232b6 100644 (file)
@@ -12,10 +12,8 @@ namespace HandBrake.ApplicationServices.Services
     using System;\r
     using System.Collections.Generic;\r
     using System.ComponentModel;\r
-    using System.Diagnostics;\r
     using System.IO;\r
     using System.Linq;\r
-    using System.Windows.Forms;\r
     using System.Xml.Serialization;\r
 \r
     using Caliburn.Micro;\r
@@ -471,12 +469,6 @@ namespace HandBrake.ApplicationServices.Services
             // Handling Log Data \r
             this.EncodeService.ProcessLogs(this.LastProcessedJob.Task.Destination);\r
 \r
-            // Post-Processing\r
-            if (e.Successful)\r
-            {\r
-                this.SendToApplication(this.LastProcessedJob.Task.Destination);\r
-            }\r
-\r
             // Move onto the next job.\r
             if (this.IsProcessing)\r
             {\r
@@ -490,35 +482,6 @@ namespace HandBrake.ApplicationServices.Services
             }\r
         }\r
 \r
-        /// <summary>\r
-        /// Perform an action after an encode. e.g a shutdown, standby, restart etc.\r
-        /// </summary>\r
-        private void Finish()\r
-        {\r
-            // Do something whent he encode ends.\r
-            switch (this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.WhenCompleteAction))\r
-            {\r
-                case "Shutdown":\r
-                    Process.Start("Shutdown", "-s -t 60");\r
-                    break;\r
-                case "Log off":\r
-                    Win32.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
-                    Win32.LockWorkStation();\r
-                    break;\r
-                case "Quit HandBrake":\r
-                    Execute.OnUIThread(Application.Exit);\r
-                    break;\r
-            }\r
-        }\r
-\r
         /// <summary>\r
         /// Invoke the JobProcessingStarted event\r
         /// </summary>\r
@@ -608,31 +571,6 @@ namespace HandBrake.ApplicationServices.Services
 \r
                 // Fire the event to tell connected services.\r
                 this.InvokeQueueCompleted(EventArgs.Empty);\r
-\r
-                // Run the After encode completeion work\r
-                this.Finish();\r
-            }\r
-        }\r
-\r
-        /// <summary>\r
-        /// Send a file to a 3rd party application after encoding has completed.\r
-        /// </summary>\r
-        /// <param name="file">\r
-        /// The file path\r
-        /// </param>\r
-        private void SendToApplication(string file)\r
-        {\r
-            if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.SendFile) &&\r
-                !string.IsNullOrEmpty(this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileTo)))\r
-            {\r
-                string args = string.Format(\r
-                    "{0} \"{1}\"", \r
-                    this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileToArgs), \r
-                    file);\r
-                var vlc =\r
-                    new ProcessStartInfo(\r
-                        this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileTo), args);\r
-                Process.Start(vlc);\r
             }\r
         }\r
 \r
index b6fc92736621447796cd201618c39d09f7f3daf9..d5c21ac0cd0498de86727e6b6093426104b468d6 100644 (file)
@@ -1,6 +1,5 @@
 ï»¿namespace HandBrake.Server\r
 {\r
-    using System;\r
     using System.Linq;\r
 \r
     using HandBrake.ApplicationServices.Services;\r
@@ -21,9 +20,6 @@
         {\r
             if (args.Count() != 1)\r
             {\r
-                //Console.WriteLine("Invalid Arguments");\r
-                //Console.ReadLine();\r
-\r
                 IServerService server = new ServerService();\r
                 server.Start("8001");\r
             }\r
index d7c81d8611010f96799ef70bd7467a7cb1125eee..21de3a905357dd533bf9e1f2b3bd4f5d0374de6e 100644 (file)
     <Compile Include="Model\DownloadStatus.cs" />\r
     <Compile Include="Services\Interfaces\INotificationService.cs" />\r
     <Compile Include="Services\Interfaces\IUpdateService.cs" />\r
+    <Compile Include="Services\Interfaces\IPrePostActionService.cs" />\r
     <Compile Include="Services\NotificationService.cs" />\r
     <Compile Include="Services\ScanServiceWrapper.cs" />\r
     <Compile Include="Services\UpdateService.cs" />\r
+    <Compile Include="Services\PrePostActionService.cs" />\r
     <Compile Include="ViewModels\AdvancedViewModel.cs" />\r
     <Compile Include="ViewModels\EncoderOptionsViewModel.cs" />\r
     <Compile Include="ViewModels\Interfaces\IEncoderOptionsViewModel.cs" />\r
index d955bb55c7387532e33d40b03b6b962bdfc86475..8a20c274eace3082f25376d6059512c5475a7d1e 100644 (file)
@@ -1,5 +1,17 @@
-namespace HandBrakeWPF.Services.Interfaces\r
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="INotificationService.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
+//   Defines the INotificationService type.\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrakeWPF.Services.Interfaces\r
 {\r
+    /// <summary>\r
+    /// The NotificationService interface.\r
+    /// </summary>\r
     public interface INotificationService\r
     {\r
     }\r
diff --git a/win/CS/HandBrakeWPF/Services/Interfaces/IPrePostActionService.cs b/win/CS/HandBrakeWPF/Services/Interfaces/IPrePostActionService.cs
new file mode 100644 (file)
index 0000000..fcd164a
--- /dev/null
@@ -0,0 +1,18 @@
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="IPrePostActionService.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
+//   Defines the IPrePostActionService type.\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrakeWPF.Services.Interfaces\r
+{\r
+    /// <summary>\r
+    /// The WhenDoneService interface.\r
+    /// </summary>\r
+    public interface IPrePostActionService\r
+    {\r
+    }\r
+}\r
diff --git a/win/CS/HandBrakeWPF/Services/PrePostActionService.cs b/win/CS/HandBrakeWPF/Services/PrePostActionService.cs
new file mode 100644 (file)
index 0000000..ce4eee4
--- /dev/null
@@ -0,0 +1,159 @@
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="WhenDoneService.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
+//   Defines the WhenDoneService type.\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrakeWPF.Services\r
+{\r
+    using System.Diagnostics;\r
+    using System.Windows.Forms;\r
+\r
+    using Caliburn.Micro;\r
+\r
+    using HandBrake.ApplicationServices.Services.Interfaces;\r
+    using HandBrake.ApplicationServices.Utilities;\r
+\r
+    using HandBrakeWPF.Services.Interfaces;\r
+\r
+    using Application = System.Windows.Application;\r
+\r
+    /// <summary>\r
+    /// The when done service.\r
+    /// </summary>\r
+    public class PrePostActionService : IPrePostActionService\r
+    {\r
+        /// <summary>\r
+        /// The queue processor.\r
+        /// </summary>\r
+        private readonly IQueueProcessor queueProcessor;\r
+\r
+        /// <summary>\r
+        /// The user setting service.\r
+        /// </summary>\r
+        private readonly IUserSettingService userSettingService;\r
+\r
+        /// <summary>\r
+        /// Initializes a new instance of the <see cref="PrePostActionService"/> class.\r
+        /// </summary>\r
+        /// <param name="queueProcessor">\r
+        /// The queue processor.\r
+        /// </param>\r
+        /// <param name="userSettingService">\r
+        /// The user Setting Service.\r
+        /// </param>\r
+        public PrePostActionService(IQueueProcessor queueProcessor, IUserSettingService userSettingService)\r
+        {\r
+            this.queueProcessor = queueProcessor;\r
+            this.userSettingService = userSettingService;\r
+\r
+            this.queueProcessor.QueueCompleted += QueueProcessorQueueCompleted;\r
+            this.queueProcessor.EncodeService.EncodeCompleted += EncodeService_EncodeCompleted;\r
+            this.queueProcessor.EncodeService.EncodeStarted += EncodeService_EncodeStarted;\r
+        }\r
+\r
+        /// <summary>\r
+        /// The encode service_ encode started.\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
+        private void EncodeService_EncodeStarted(object sender, System.EventArgs e)\r
+        {\r
+            if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PreventSleep))\r
+            {\r
+                Win32.PreventSleep();\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// The encode service_ encode completed.\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The EncodeCompletedEventArgs.\r
+        /// </param>\r
+        private void EncodeService_EncodeCompleted(object sender, HandBrake.ApplicationServices.EventArgs.EncodeCompletedEventArgs e)\r
+        {\r
+            // Send the file to the users requested applicaiton\r
+            if (e.Successful)\r
+            {\r
+                this.SendToApplication(e.FileName);\r
+            }\r
+\r
+            // Allow the system to sleep again.\r
+            Execute.OnUIThread(() =>\r
+            {\r
+                if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PreventSleep))\r
+                {\r
+                    Win32.AllowSleep();\r
+                }\r
+            });\r
+        }\r
+\r
+        /// <summary>\r
+        /// The queue processor queue completed event handler.\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
+        private void QueueProcessorQueueCompleted(object sender, System.EventArgs e)\r
+        {\r
+            // Do something whent he encode ends.\r
+            switch (this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction))\r
+            {\r
+                case "Shutdown":\r
+                    Process.Start("Shutdown", "-s -t 60");\r
+                    break;\r
+                case "Log off":\r
+                    Win32.ExitWindowsEx(0, 0);\r
+                    break;\r
+                case "Suspend":\r
+                    System.Windows.Forms.Application.SetSuspendState(PowerState.Suspend, true, true);\r
+                    break;\r
+                case "Hibernate":\r
+                    System.Windows.Forms.Application.SetSuspendState(PowerState.Hibernate, true, true);\r
+                    break;\r
+                case "Lock System":\r
+                    Win32.LockWorkStation();\r
+                    break;\r
+                case "Quit HandBrake":\r
+                    Execute.OnUIThread(() => Application.Current.Shutdown());\r
+                    break;\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Send a file to a 3rd party application after encoding has completed.\r
+        /// </summary>\r
+        /// <param name="file">\r
+        /// The file path\r
+        /// </param>\r
+        private void SendToApplication(string file)\r
+        {\r
+            if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.SendFile) &&\r
+                !string.IsNullOrEmpty(this.userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileTo)))\r
+            {\r
+                string args = string.Format(\r
+                    "{0} \"{1}\"",\r
+                    this.userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileToArgs),\r
+                    file);\r
+                var vlc =\r
+                    new ProcessStartInfo(\r
+                        this.userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileTo), args);\r
+                Process.Start(vlc);\r
+            }\r
+        }\r
+    }\r
+}\r
index 6f3428de35cd8413399b0fe2cf8092ca7772f8a8..a384815ee7bacbb03d440a4b5d48d894c13348bd 100644 (file)
@@ -61,6 +61,7 @@ namespace HandBrakeWPF.Startup
             this.windsorContainer.Register(Component.For<IScanServiceWrapper>().ImplementedBy<ScanServiceWrapper>().LifeStyle.Is(LifestyleType.Singleton));\r
             this.windsorContainer.Register(Component.For<IEncodeServiceWrapper>().ImplementedBy<EncodeServiceWrapper>().LifeStyle.Is(LifestyleType.Singleton));\r
             this.windsorContainer.Register(Component.For<INotificationService>().ImplementedBy<NotificationService>().LifeStyle.Is(LifestyleType.Singleton));\r
+            this.windsorContainer.Register(Component.For<IPrePostActionService>().ImplementedBy<PrePostActionService>().LifeStyle.Is(LifestyleType.Singleton));\r
 \r
             // Commands\r
             this.windsorContainer.Register(Component.For<IAdvancedEncoderOptionsCommand>().ImplementedBy<AdvancedEncoderOptionsCommand>().LifeStyle.Is(LifestyleType.Singleton));\r
index 1f4c02fce386474cade09d6e1741b240d689aec7..b70d8865485e3cfa440b9e9921853085fc08ab5f 100644 (file)
@@ -200,6 +200,31 @@ namespace HandBrakeWPF
         /// Disable LibHb Features\r
         /// </summary>\r
         public const string DisableLibHbFeatures = "DisableLibHbFeatures";\r
+    \r
+        /// <summary>\r
+        /// When Complete Action\r
+        /// </summary>\r
+        public const string WhenCompleteAction = "WhenCompleteAction";\r
+\r
+        /// <summary>\r
+        /// Send file enabled.\r
+        /// </summary>\r
+        public const string SendFile = "SendFile";\r
+\r
+        /// <summary>\r
+        /// Send file to application path\r
+        /// </summary>\r
+        public const string SendFileTo = "SendFileTo";\r
+\r
+        /// <summary>\r
+        /// Send file to arguments\r
+        /// </summary>\r
+        public const string SendFileToArgs = "SendFileToArgs";\r
+\r
+        /// <summary>\r
+        /// Prevent Sleep\r
+        /// </summary>\r
+        public const string PreventSleep = "PreventSleep";\r
 \r
         #endregion\r
     }\r
index fd465d480d3998b397dd197d94b53e9a25863417..bbcd093c509ac6799a1b339f1ff649b7f0760968 100644 (file)
@@ -205,10 +205,15 @@ namespace HandBrakeWPF.ViewModels
         /// </param>\r
         /// <param name="notificationService">\r
         /// The notification Service.\r
-        /// *** Leave in Constructor. ***  TODO find out why?\r
+        /// *** Leave in Constructor. *** \r
+        /// </param>\r
+        /// <param name="whenDoneService">\r
+        /// The when Done Service.\r
+        /// *** Leave in Constructor. *** \r
         /// </param>\r
         public MainViewModel(IUserSettingService userSettingService, IScanServiceWrapper scanService, IEncodeServiceWrapper encodeService, IPresetService presetService,\r
-            IErrorService errorService, IShellViewModel shellViewModel, IUpdateService updateService, IDriveDetectService driveDetectService, INotificationService notificationService)\r
+            IErrorService errorService, IShellViewModel shellViewModel, IUpdateService updateService, IDriveDetectService driveDetectService, INotificationService notificationService,\r
+            IPrePostActionService whenDoneService)\r
         {\r
             this.scanService = scanService;\r
             this.encodeService = encodeService;\r
index bde7bc38c9bb9b57ca9908642a0feddad21238a3..4b61c4192800493f47778ed575184c515aa62db8 100644 (file)
@@ -19,6 +19,8 @@ namespace HandBrakeWPF.ViewModels
     using System.Linq;\r
     using System.Windows;\r
 \r
+    using Caliburn.Micro;\r
+\r
     using HandBrake.ApplicationServices;\r
     using HandBrake.ApplicationServices.Services.Interfaces;\r
     using HandBrake.ApplicationServices.Utilities;\r
@@ -1482,15 +1484,15 @@ namespace HandBrakeWPF.ViewModels
             this.whenDoneOptions.Add("Hibernate");\r
             this.whenDoneOptions.Add("Lock System");\r
             this.whenDoneOptions.Add("Log off");\r
-           // this.whenDoneOptions.Add("Quit HandBrake");\r
+            this.whenDoneOptions.Add("Quit HandBrake");\r
             this.WhenDone = userSettingService.GetUserSetting<string>("WhenCompleteAction");\r
 \r
             this.GrowlAfterEncode = userSettingService.GetUserSetting<bool>(UserSettingConstants.GrowlEncode);\r
             this.GrowlAfterQueue = userSettingService.GetUserSetting<bool>(UserSettingConstants.GrowlQueue);\r
-            this.SendFileAfterEncode = this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.SendFile);\r
-            this.SendFileTo = Path.GetFileNameWithoutExtension(this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileTo)) ?? string.Empty;\r
-            this.SendFileToPath = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileTo) ?? string.Empty;\r
-            this.Arguments = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileToArgs) ?? string.Empty;\r
+            this.SendFileAfterEncode = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.SendFile);\r
+            this.SendFileTo = Path.GetFileNameWithoutExtension(this.userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileTo)) ?? string.Empty;\r
+            this.SendFileToPath = this.userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileTo) ?? string.Empty;\r
+            this.Arguments = this.userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileToArgs) ?? string.Empty;\r
 \r
             // #############################\r
             // Output Settings\r
@@ -1597,7 +1599,7 @@ namespace HandBrakeWPF.ViewModels
             this.priorityLevelOptions.Add("Low");\r
             this.SelectedPriority = userSettingService.GetUserSetting<string>(ASUserSettingConstants.ProcessPriority);\r
 \r
-            this.PreventSleep = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep);\r
+            this.PreventSleep = userSettingService.GetUserSetting<bool>(UserSettingConstants.PreventSleep);\r
 \r
             // Log Verbosity Level\r
             this.logVerbosityOptions.Clear();\r
@@ -1820,12 +1822,12 @@ namespace HandBrakeWPF.ViewModels
             /* General */\r
             this.userSettingService.SetUserSetting(UserSettingConstants.UpdateStatus, this.CheckForUpdates);\r
             this.userSettingService.SetUserSetting(UserSettingConstants.DaysBetweenUpdateCheck, this.CheckForUpdatesFrequency);\r
-            this.userSettingService.SetUserSetting(ASUserSettingConstants.WhenCompleteAction, this.WhenDone);\r
+            this.userSettingService.SetUserSetting(UserSettingConstants.WhenCompleteAction, this.WhenDone);\r
             this.userSettingService.SetUserSetting(UserSettingConstants.GrowlQueue, this.GrowlAfterQueue);\r
             this.userSettingService.SetUserSetting(UserSettingConstants.GrowlEncode, this.GrowlAfterEncode);\r
-            this.userSettingService.SetUserSetting(ASUserSettingConstants.SendFileTo, this.SendFileToPath);\r
-            this.userSettingService.SetUserSetting(ASUserSettingConstants.SendFile, this.SendFileAfterEncode);\r
-            this.userSettingService.SetUserSetting(ASUserSettingConstants.SendFileToArgs, this.Arguments);\r
+            this.userSettingService.SetUserSetting(UserSettingConstants.SendFileTo, this.SendFileToPath);\r
+            this.userSettingService.SetUserSetting(UserSettingConstants.SendFile, this.SendFileAfterEncode);\r
+            this.userSettingService.SetUserSetting(UserSettingConstants.SendFileToArgs, this.Arguments);\r
 \r
             /* Output Files */\r
             this.userSettingService.SetUserSetting(UserSettingConstants.AutoNaming, this.AutomaticallyNameFiles);\r
@@ -1852,7 +1854,7 @@ namespace HandBrakeWPF.ViewModels
 \r
             /* System and Logging */\r
             userSettingService.SetUserSetting(ASUserSettingConstants.ProcessPriority, this.SelectedPriority);\r
-            userSettingService.SetUserSetting(ASUserSettingConstants.PreventSleep, this.PreventSleep);\r
+            userSettingService.SetUserSetting(UserSettingConstants.PreventSleep, this.PreventSleep);\r
             userSettingService.SetUserSetting(ASUserSettingConstants.Verbosity, this.SelectedVerbosity);\r
             userSettingService.SetUserSetting(ASUserSettingConstants.SaveLogWithVideo, this.CopyLogToEncodeDirectory);\r
             userSettingService.SetUserSetting(ASUserSettingConstants.SaveLogToCopyDirectory, this.CopyLogToSepcficedLocation);\r
@@ -1935,7 +1937,7 @@ namespace HandBrakeWPF.ViewModels
             this.UpdateMessage = info.WasSuccessful ? "Update Downloaded" : "Update Failed. You can try downloading the update from http://handbrake.fr";\r
 \r
             Process.Start(Path.Combine(Path.GetTempPath(), "handbrake-setup.exe"));\r
-            Application.Current.Shutdown();\r
+            Execute.OnUIThread(() => Application.Current.Shutdown());\r
         }\r
 \r
         /// <summary>\r
index 3b5bf33e8ec38470870723fadcea4d4fba247e66..bf7d46b3d02652e9ee6b88181c6da2d75e3df7cf 100644 (file)
 namespace HandBrakeWPF.ViewModels\r
 {\r
     using System;\r
-    using System.Collections.ObjectModel;\r
     using System.ComponentModel;\r
     using System.Windows;\r
 \r
     using Caliburn.Micro;\r
 \r
-    using HandBrake.ApplicationServices;\r
     using HandBrake.ApplicationServices.EventArgs;\r
     using HandBrake.ApplicationServices.Model;\r
     using HandBrake.ApplicationServices.Services.Interfaces;\r
@@ -31,13 +29,6 @@ namespace HandBrakeWPF.ViewModels
     /// </summary>\r
     public class QueueViewModel : ViewModelBase, IQueueViewModel\r
     {\r
-        /*\r
-         \r
-         * TODO FIX THE DRAP/DROP ADORNER!\r
-         */\r
-\r
-\r
-\r
         #region Constants and Fields\r
 \r
         /// <summary>\r
@@ -82,9 +73,6 @@ namespace HandBrakeWPF.ViewModels
         /// <summary>\r
         /// Initializes a new instance of the <see cref="QueueViewModel"/> class.\r
         /// </summary>\r
-        /// <param name="windowManager">\r
-        /// The window manager.\r
-        /// </param>\r
         /// <param name="userSettingService">\r
         /// The user Setting Service.\r
         /// </param>\r
@@ -94,7 +82,7 @@ namespace HandBrakeWPF.ViewModels
         /// <param name="errorService">\r
         /// The Error Service \r
         /// </param>\r
-        public QueueViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IQueueProcessor queueProcessor, IErrorService errorService)\r
+        public QueueViewModel(IUserSettingService userSettingService, IQueueProcessor queueProcessor, IErrorService errorService)\r
         {\r
             this.userSettingService = userSettingService;\r
             this.queueProcessor = queueProcessor;\r
@@ -199,7 +187,7 @@ namespace HandBrakeWPF.ViewModels
         public void WhenDone(string action)\r
         {\r
             this.WhenDoneAction = action;\r
-            this.userSettingService.SetUserSetting(ASUserSettingConstants.WhenCompleteAction, action);\r
+            this.userSettingService.SetUserSetting(UserSettingConstants.WhenCompleteAction, action);\r
         }\r
 \r
         /// <summary>\r
@@ -374,7 +362,7 @@ namespace HandBrakeWPF.ViewModels
         {\r
             this.Load();\r
 \r
-            this.WhenDoneAction = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.WhenCompleteAction);\r
+            this.WhenDoneAction = this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction);\r
 \r
             this.queueProcessor.JobProcessingStarted += this.queueProcessor_JobProcessingStarted;\r
             this.queueProcessor.QueueCompleted += this.queueProcessor_QueueCompleted;\r
@@ -429,7 +417,6 @@ namespace HandBrakeWPF.ViewModels
                             e.EstimatedTimeLeft,\r
                             e.ElapsedTime);\r
                 }\r
-\r
             });\r
         }\r
 \r