summaryrefslogtreecommitdiffstats
path: root/win/CS
diff options
context:
space:
mode:
authorsr55 <[email protected]>2013-05-19 16:49:50 +0000
committersr55 <[email protected]>2013-05-19 16:49:50 +0000
commit39d5addd4f0772fe45811be4a3b1e3305785866e (patch)
treef9a07819ae96f76af0f5bdfc9c3019256b99ada3 /win/CS
parent67a224af55647590e886808285132d5955ed9333 (diff)
WinGui: Rectored some Encode/Queue service code. This restoes "Quit HandBrake" when done option.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5485 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS')
-rw-r--r--win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs25
-rw-r--r--win/CS/HandBrake.ApplicationServices/EventArgs/EncodeCompletedEventArgs.cs14
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode.cs24
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs24
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs62
-rw-r--r--win/CS/HandBrake.Server/Program.cs4
-rw-r--r--win/CS/HandBrakeWPF/HandBrakeWPF.csproj2
-rw-r--r--win/CS/HandBrakeWPF/Services/Interfaces/INotificationService.cs14
-rw-r--r--win/CS/HandBrakeWPF/Services/Interfaces/IPrePostActionService.cs18
-rw-r--r--win/CS/HandBrakeWPF/Services/PrePostActionService.cs159
-rw-r--r--win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs1
-rw-r--r--win/CS/HandBrakeWPF/UserSettingConstants.cs25
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs9
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs26
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs19
15 files changed, 269 insertions, 157 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs b/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs
index 7e3ee4583..78f5b18ab 100644
--- a/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs
+++ b/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs
@@ -20,21 +20,11 @@ namespace HandBrake.ApplicationServices
public const string Verbosity = "Verbosity";
/// <summary>
- /// When Complete Action
- /// </summary>
- public const string WhenCompleteAction = "WhenCompleteAction";
-
- /// <summary>
/// Process Priority
/// </summary>
public const string ProcessPriority = "ProcessPriority";
/// <summary>
- /// Prevent Sleep
- /// </summary>
- public const string PreventSleep = "PreventSleep";
-
- /// <summary>
/// Save Log Directory
/// </summary>
public const string SaveLogToCopyDirectory = "SaveLogToCopyDirectory";
@@ -60,21 +50,6 @@ namespace HandBrake.ApplicationServices
public const string DisableLibDvdNav = "DisableLibDvdNav";
/// <summary>
- /// Send file enabled.
- /// </summary>
- public const string SendFile = "SendFile";
-
- /// <summary>
- /// Send file to application path
- /// </summary>
- public const string SendFileTo = "SendFileTo";
-
- /// <summary>
- /// Send file to arguments
- /// </summary>
- public const string SendFileToArgs = "SendFileToArgs";
-
- /// <summary>
/// Min Title Scan Duration
/// </summary>
public const string MinScanDuration = "MinTitleScanDuration";
diff --git a/win/CS/HandBrake.ApplicationServices/EventArgs/EncodeCompletedEventArgs.cs b/win/CS/HandBrake.ApplicationServices/EventArgs/EncodeCompletedEventArgs.cs
index 44a66cac7..2bbb7ab97 100644
--- a/win/CS/HandBrake.ApplicationServices/EventArgs/EncodeCompletedEventArgs.cs
+++ b/win/CS/HandBrake.ApplicationServices/EventArgs/EncodeCompletedEventArgs.cs
@@ -12,6 +12,8 @@ namespace HandBrake.ApplicationServices.EventArgs
using System;
using System.Runtime.Serialization;
+ using HandBrake.ApplicationServices.Model;
+
/// <summary>
/// Encode Progress Event Args
/// </summary>
@@ -30,14 +32,24 @@ namespace HandBrake.ApplicationServices.EventArgs
/// <param name="errorInformation">
/// The error information.
/// </param>
- public EncodeCompletedEventArgs(bool sucessful, Exception exception, string errorInformation)
+ /// <param name="filename">
+ /// The filename.
+ /// </param>
+ public EncodeCompletedEventArgs(bool sucessful, Exception exception, string errorInformation, string filename)
{
this.Successful = sucessful;
this.Exception = exception;
this.ErrorInformation = errorInformation;
+ this.FileName = filename;
}
/// <summary>
+ /// Gets or sets the file name.
+ /// </summary>
+ [DataMember]
+ public string FileName { get; set; }
+
+ /// <summary>
/// Gets or sets a value indicating whether Successful.
/// </summary>
[DataMember]
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs
index b4f572521..4779d353e 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs
@@ -14,9 +14,8 @@ namespace HandBrake.ApplicationServices.Services
using System.IO;
using System.Windows.Forms;
- using Caliburn.Micro;
-
using HandBrake.ApplicationServices.EventArgs;
+ using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Base;
using HandBrake.ApplicationServices.Services.Interfaces;
@@ -95,11 +94,10 @@ namespace HandBrake.ApplicationServices.Services
{
if (this.IsEncoding)
{
- throw new Exception("HandBrake is already encodeing.");
+ throw new GeneralApplicationException("HandBrake is already encodeing.", "Please try again in a minute", null);
}
this.IsEncoding = true;
-
this.currentTask = encodeQueueTask;
if (enableLogging)
@@ -115,11 +113,6 @@ namespace HandBrake.ApplicationServices.Services
}
}
- if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep))
- {
- Win32.PreventSleep();
- }
-
// Make sure the path exists, attempt to create it if it doesn't
this.VerifyEncodeDestinationPath(currentTask);
@@ -200,9 +193,10 @@ namespace HandBrake.ApplicationServices.Services
catch (Exception exc)
{
encodeQueueTask.Status = QueueItemStatus.Error;
+ this.IsEncoding = false;
this.InvokeEncodeCompleted(
new EncodeCompletedEventArgs(
- false, null, "An Error occured when trying to encode this source. "));
+ false, exc, "An Error occured when trying to encode this source. ", this.currentTask.Task.Destination));
throw;
}
}
@@ -261,17 +255,9 @@ namespace HandBrake.ApplicationServices.Services
// This exception doesn't warrent user interaction, but it should be logged (TODO)
}
- Execute.OnUIThread(() =>
- {
- if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep))
- {
- Win32.AllowSleep();
- }
- });
-
this.currentTask.Status = QueueItemStatus.Completed;
this.IsEncoding = false;
- this.InvokeEncodeCompleted(new EncodeCompletedEventArgs(true, null, string.Empty));
+ this.InvokeEncodeCompleted(new EncodeCompletedEventArgs(true, null, string.Empty, this.currentTask.Task.Destination));
}
/// <summary>
diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs
index 33453dad8..f7247f6cf 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs
@@ -11,7 +11,6 @@ namespace HandBrake.ApplicationServices.Services
{
using System;
using System.Diagnostics;
- using System.Globalization;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Base;
@@ -57,6 +56,11 @@ namespace HandBrake.ApplicationServices.Services
/// </summary>
private bool loggingEnabled;
+ /// <summary>
+ /// The Current Task
+ /// </summary>
+ private QueueTask currentTask;
+
#endregion
/// <summary>
@@ -95,6 +99,7 @@ namespace HandBrake.ApplicationServices.Services
{
this.startTime = DateTime.Now;
this.loggingEnabled = enableLogging;
+ this.currentTask = job;
try
{
@@ -123,12 +128,6 @@ namespace HandBrake.ApplicationServices.Services
}
}
- // Prvent the system from sleeping if the user asks
- if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep) )
- {
- Win32.PreventSleep();
- }
-
// Verify the Destination Path Exists, and if not, create it.
this.VerifyEncodeDestinationPath(job);
@@ -163,7 +162,7 @@ namespace HandBrake.ApplicationServices.Services
}
catch (Exception exc)
{
- this.InvokeEncodeCompleted(new EncodeCompletedEventArgs(false, exc, "An Error has occured."));
+ this.InvokeEncodeCompleted(new EncodeCompletedEventArgs(false, exc, "An Error has occured.", this.currentTask.Task.Destination));
}
}
@@ -271,13 +270,8 @@ namespace HandBrake.ApplicationServices.Services
this.InvokeEncodeCompleted(
e.Error
- ? new EncodeCompletedEventArgs(false, null, string.Empty)
- : new EncodeCompletedEventArgs(true, null, string.Empty));
-
- if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep))
- {
- Win32.AllowSleep();
- }
+ ? new EncodeCompletedEventArgs(false, null, string.Empty, this.currentTask.Task.Destination)
+ : new EncodeCompletedEventArgs(true, null, string.Empty, this.currentTask.Task.Destination));
this.ShutdownFileWriter();
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
index 79b348ae4..92f69142c 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
@@ -12,10 +12,8 @@ namespace HandBrake.ApplicationServices.Services
using System;
using System.Collections.Generic;
using System.ComponentModel;
- using System.Diagnostics;
using System.IO;
using System.Linq;
- using System.Windows.Forms;
using System.Xml.Serialization;
using Caliburn.Micro;
@@ -471,12 +469,6 @@ namespace HandBrake.ApplicationServices.Services
// Handling Log Data
this.EncodeService.ProcessLogs(this.LastProcessedJob.Task.Destination);
- // Post-Processing
- if (e.Successful)
- {
- this.SendToApplication(this.LastProcessedJob.Task.Destination);
- }
-
// Move onto the next job.
if (this.IsProcessing)
{
@@ -491,35 +483,6 @@ namespace HandBrake.ApplicationServices.Services
}
/// <summary>
- /// Perform an action after an encode. e.g a shutdown, standby, restart etc.
- /// </summary>
- private void Finish()
- {
- // Do something whent he encode ends.
- switch (this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.WhenCompleteAction))
- {
- case "Shutdown":
- Process.Start("Shutdown", "-s -t 60");
- break;
- case "Log off":
- Win32.ExitWindowsEx(0, 0);
- break;
- case "Suspend":
- Application.SetSuspendState(PowerState.Suspend, true, true);
- break;
- case "Hibernate":
- Application.SetSuspendState(PowerState.Hibernate, true, true);
- break;
- case "Lock System":
- Win32.LockWorkStation();
- break;
- case "Quit HandBrake":
- Execute.OnUIThread(Application.Exit);
- break;
- }
- }
-
- /// <summary>
/// Invoke the JobProcessingStarted event
/// </summary>
/// <param name="e">
@@ -608,31 +571,6 @@ namespace HandBrake.ApplicationServices.Services
// Fire the event to tell connected services.
this.InvokeQueueCompleted(EventArgs.Empty);
-
- // Run the After encode completeion work
- this.Finish();
- }
- }
-
- /// <summary>
- /// Send a file to a 3rd party application after encoding has completed.
- /// </summary>
- /// <param name="file">
- /// The file path
- /// </param>
- private void SendToApplication(string file)
- {
- if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.SendFile) &&
- !string.IsNullOrEmpty(this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileTo)))
- {
- string args = string.Format(
- "{0} \"{1}\"",
- this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileToArgs),
- file);
- var vlc =
- new ProcessStartInfo(
- this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileTo), args);
- Process.Start(vlc);
}
}
diff --git a/win/CS/HandBrake.Server/Program.cs b/win/CS/HandBrake.Server/Program.cs
index b6fc92736..d5c21ac0c 100644
--- a/win/CS/HandBrake.Server/Program.cs
+++ b/win/CS/HandBrake.Server/Program.cs
@@ -1,6 +1,5 @@
namespace HandBrake.Server
{
- using System;
using System.Linq;
using HandBrake.ApplicationServices.Services;
@@ -21,9 +20,6 @@
{
if (args.Count() != 1)
{
- //Console.WriteLine("Invalid Arguments");
- //Console.ReadLine();
-
IServerService server = new ServerService();
server.Start("8001");
}
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
index d7c81d861..21de3a905 100644
--- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
+++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
@@ -166,9 +166,11 @@
<Compile Include="Model\DownloadStatus.cs" />
<Compile Include="Services\Interfaces\INotificationService.cs" />
<Compile Include="Services\Interfaces\IUpdateService.cs" />
+ <Compile Include="Services\Interfaces\IPrePostActionService.cs" />
<Compile Include="Services\NotificationService.cs" />
<Compile Include="Services\ScanServiceWrapper.cs" />
<Compile Include="Services\UpdateService.cs" />
+ <Compile Include="Services\PrePostActionService.cs" />
<Compile Include="ViewModels\AdvancedViewModel.cs" />
<Compile Include="ViewModels\EncoderOptionsViewModel.cs" />
<Compile Include="ViewModels\Interfaces\IEncoderOptionsViewModel.cs" />
diff --git a/win/CS/HandBrakeWPF/Services/Interfaces/INotificationService.cs b/win/CS/HandBrakeWPF/Services/Interfaces/INotificationService.cs
index d955bb55c..8a20c274e 100644
--- a/win/CS/HandBrakeWPF/Services/Interfaces/INotificationService.cs
+++ b/win/CS/HandBrakeWPF/Services/Interfaces/INotificationService.cs
@@ -1,5 +1,17 @@
-namespace HandBrakeWPF.Services.Interfaces
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="INotificationService.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>
+// Defines the INotificationService type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Services.Interfaces
{
+ /// <summary>
+ /// The NotificationService interface.
+ /// </summary>
public interface INotificationService
{
}
diff --git a/win/CS/HandBrakeWPF/Services/Interfaces/IPrePostActionService.cs b/win/CS/HandBrakeWPF/Services/Interfaces/IPrePostActionService.cs
new file mode 100644
index 000000000..fcd164a69
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Services/Interfaces/IPrePostActionService.cs
@@ -0,0 +1,18 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="IPrePostActionService.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>
+// Defines the IPrePostActionService type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Services.Interfaces
+{
+ /// <summary>
+ /// The WhenDoneService interface.
+ /// </summary>
+ public interface IPrePostActionService
+ {
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Services/PrePostActionService.cs b/win/CS/HandBrakeWPF/Services/PrePostActionService.cs
new file mode 100644
index 000000000..ce4eee423
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Services/PrePostActionService.cs
@@ -0,0 +1,159 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="WhenDoneService.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>
+// Defines the WhenDoneService type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Services
+{
+ using System.Diagnostics;
+ using System.Windows.Forms;
+
+ using Caliburn.Micro;
+
+ using HandBrake.ApplicationServices.Services.Interfaces;
+ using HandBrake.ApplicationServices.Utilities;
+
+ using HandBrakeWPF.Services.Interfaces;
+
+ using Application = System.Windows.Application;
+
+ /// <summary>
+ /// The when done service.
+ /// </summary>
+ public class PrePostActionService : IPrePostActionService
+ {
+ /// <summary>
+ /// The queue processor.
+ /// </summary>
+ private readonly IQueueProcessor queueProcessor;
+
+ /// <summary>
+ /// The user setting service.
+ /// </summary>
+ private readonly IUserSettingService userSettingService;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PrePostActionService"/> class.
+ /// </summary>
+ /// <param name="queueProcessor">
+ /// The queue processor.
+ /// </param>
+ /// <param name="userSettingService">
+ /// The user Setting Service.
+ /// </param>
+ public PrePostActionService(IQueueProcessor queueProcessor, IUserSettingService userSettingService)
+ {
+ this.queueProcessor = queueProcessor;
+ this.userSettingService = userSettingService;
+
+ this.queueProcessor.QueueCompleted += QueueProcessorQueueCompleted;
+ this.queueProcessor.EncodeService.EncodeCompleted += EncodeService_EncodeCompleted;
+ this.queueProcessor.EncodeService.EncodeStarted += EncodeService_EncodeStarted;
+ }
+
+ /// <summary>
+ /// The encode service_ encode started.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The e.
+ /// </param>
+ private void EncodeService_EncodeStarted(object sender, System.EventArgs e)
+ {
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PreventSleep))
+ {
+ Win32.PreventSleep();
+ }
+ }
+
+ /// <summary>
+ /// The encode service_ encode completed.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The EncodeCompletedEventArgs.
+ /// </param>
+ private void EncodeService_EncodeCompleted(object sender, HandBrake.ApplicationServices.EventArgs.EncodeCompletedEventArgs e)
+ {
+ // Send the file to the users requested applicaiton
+ if (e.Successful)
+ {
+ this.SendToApplication(e.FileName);
+ }
+
+ // Allow the system to sleep again.
+ Execute.OnUIThread(() =>
+ {
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PreventSleep))
+ {
+ Win32.AllowSleep();
+ }
+ });
+ }
+
+ /// <summary>
+ /// The queue processor queue completed event handler.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The e.
+ /// </param>
+ private void QueueProcessorQueueCompleted(object sender, System.EventArgs e)
+ {
+ // Do something whent he encode ends.
+ switch (this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction))
+ {
+ case "Shutdown":
+ Process.Start("Shutdown", "-s -t 60");
+ break;
+ case "Log off":
+ Win32.ExitWindowsEx(0, 0);
+ break;
+ case "Suspend":
+ System.Windows.Forms.Application.SetSuspendState(PowerState.Suspend, true, true);
+ break;
+ case "Hibernate":
+ System.Windows.Forms.Application.SetSuspendState(PowerState.Hibernate, true, true);
+ break;
+ case "Lock System":
+ Win32.LockWorkStation();
+ break;
+ case "Quit HandBrake":
+ Execute.OnUIThread(() => Application.Current.Shutdown());
+ break;
+ }
+ }
+
+ /// <summary>
+ /// Send a file to a 3rd party application after encoding has completed.
+ /// </summary>
+ /// <param name="file">
+ /// The file path
+ /// </param>
+ private void SendToApplication(string file)
+ {
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.SendFile) &&
+ !string.IsNullOrEmpty(this.userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileTo)))
+ {
+ string args = string.Format(
+ "{0} \"{1}\"",
+ this.userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileToArgs),
+ file);
+ var vlc =
+ new ProcessStartInfo(
+ this.userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileTo), args);
+ Process.Start(vlc);
+ }
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs b/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs
index 6f3428de3..a384815ee 100644
--- a/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs
+++ b/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs
@@ -61,6 +61,7 @@ namespace HandBrakeWPF.Startup
this.windsorContainer.Register(Component.For<IScanServiceWrapper>().ImplementedBy<ScanServiceWrapper>().LifeStyle.Is(LifestyleType.Singleton));
this.windsorContainer.Register(Component.For<IEncodeServiceWrapper>().ImplementedBy<EncodeServiceWrapper>().LifeStyle.Is(LifestyleType.Singleton));
this.windsorContainer.Register(Component.For<INotificationService>().ImplementedBy<NotificationService>().LifeStyle.Is(LifestyleType.Singleton));
+ this.windsorContainer.Register(Component.For<IPrePostActionService>().ImplementedBy<PrePostActionService>().LifeStyle.Is(LifestyleType.Singleton));
// Commands
this.windsorContainer.Register(Component.For<IAdvancedEncoderOptionsCommand>().ImplementedBy<AdvancedEncoderOptionsCommand>().LifeStyle.Is(LifestyleType.Singleton));
diff --git a/win/CS/HandBrakeWPF/UserSettingConstants.cs b/win/CS/HandBrakeWPF/UserSettingConstants.cs
index 1f4c02fce..b70d88654 100644
--- a/win/CS/HandBrakeWPF/UserSettingConstants.cs
+++ b/win/CS/HandBrakeWPF/UserSettingConstants.cs
@@ -200,6 +200,31 @@ namespace HandBrakeWPF
/// Disable LibHb Features
/// </summary>
public const string DisableLibHbFeatures = "DisableLibHbFeatures";
+
+ /// <summary>
+ /// When Complete Action
+ /// </summary>
+ public const string WhenCompleteAction = "WhenCompleteAction";
+
+ /// <summary>
+ /// Send file enabled.
+ /// </summary>
+ public const string SendFile = "SendFile";
+
+ /// <summary>
+ /// Send file to application path
+ /// </summary>
+ public const string SendFileTo = "SendFileTo";
+
+ /// <summary>
+ /// Send file to arguments
+ /// </summary>
+ public const string SendFileToArgs = "SendFileToArgs";
+
+ /// <summary>
+ /// Prevent Sleep
+ /// </summary>
+ public const string PreventSleep = "PreventSleep";
#endregion
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index fd465d480..bbcd093c5 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -205,10 +205,15 @@ namespace HandBrakeWPF.ViewModels
/// </param>
/// <param name="notificationService">
/// The notification Service.
- /// *** Leave in Constructor. *** TODO find out why?
+ /// *** Leave in Constructor. ***
+ /// </param>
+ /// <param name="whenDoneService">
+ /// The when Done Service.
+ /// *** Leave in Constructor. ***
/// </param>
public MainViewModel(IUserSettingService userSettingService, IScanServiceWrapper scanService, IEncodeServiceWrapper encodeService, IPresetService presetService,
- IErrorService errorService, IShellViewModel shellViewModel, IUpdateService updateService, IDriveDetectService driveDetectService, INotificationService notificationService)
+ IErrorService errorService, IShellViewModel shellViewModel, IUpdateService updateService, IDriveDetectService driveDetectService, INotificationService notificationService,
+ IPrePostActionService whenDoneService)
{
this.scanService = scanService;
this.encodeService = encodeService;
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
index bde7bc38c..4b61c4192 100644
--- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
@@ -19,6 +19,8 @@ namespace HandBrakeWPF.ViewModels
using System.Linq;
using System.Windows;
+ using Caliburn.Micro;
+
using HandBrake.ApplicationServices;
using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.ApplicationServices.Utilities;
@@ -1482,15 +1484,15 @@ namespace HandBrakeWPF.ViewModels
this.whenDoneOptions.Add("Hibernate");
this.whenDoneOptions.Add("Lock System");
this.whenDoneOptions.Add("Log off");
- // this.whenDoneOptions.Add("Quit HandBrake");
+ this.whenDoneOptions.Add("Quit HandBrake");
this.WhenDone = userSettingService.GetUserSetting<string>("WhenCompleteAction");
this.GrowlAfterEncode = userSettingService.GetUserSetting<bool>(UserSettingConstants.GrowlEncode);
this.GrowlAfterQueue = userSettingService.GetUserSetting<bool>(UserSettingConstants.GrowlQueue);
- this.SendFileAfterEncode = this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.SendFile);
- this.SendFileTo = Path.GetFileNameWithoutExtension(this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileTo)) ?? string.Empty;
- this.SendFileToPath = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileTo) ?? string.Empty;
- this.Arguments = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileToArgs) ?? string.Empty;
+ this.SendFileAfterEncode = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.SendFile);
+ this.SendFileTo = Path.GetFileNameWithoutExtension(this.userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileTo)) ?? string.Empty;
+ this.SendFileToPath = this.userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileTo) ?? string.Empty;
+ this.Arguments = this.userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileToArgs) ?? string.Empty;
// #############################
// Output Settings
@@ -1597,7 +1599,7 @@ namespace HandBrakeWPF.ViewModels
this.priorityLevelOptions.Add("Low");
this.SelectedPriority = userSettingService.GetUserSetting<string>(ASUserSettingConstants.ProcessPriority);
- this.PreventSleep = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep);
+ this.PreventSleep = userSettingService.GetUserSetting<bool>(UserSettingConstants.PreventSleep);
// Log Verbosity Level
this.logVerbosityOptions.Clear();
@@ -1820,12 +1822,12 @@ namespace HandBrakeWPF.ViewModels
/* General */
this.userSettingService.SetUserSetting(UserSettingConstants.UpdateStatus, this.CheckForUpdates);
this.userSettingService.SetUserSetting(UserSettingConstants.DaysBetweenUpdateCheck, this.CheckForUpdatesFrequency);
- this.userSettingService.SetUserSetting(ASUserSettingConstants.WhenCompleteAction, this.WhenDone);
+ this.userSettingService.SetUserSetting(UserSettingConstants.WhenCompleteAction, this.WhenDone);
this.userSettingService.SetUserSetting(UserSettingConstants.GrowlQueue, this.GrowlAfterQueue);
this.userSettingService.SetUserSetting(UserSettingConstants.GrowlEncode, this.GrowlAfterEncode);
- this.userSettingService.SetUserSetting(ASUserSettingConstants.SendFileTo, this.SendFileToPath);
- this.userSettingService.SetUserSetting(ASUserSettingConstants.SendFile, this.SendFileAfterEncode);
- this.userSettingService.SetUserSetting(ASUserSettingConstants.SendFileToArgs, this.Arguments);
+ this.userSettingService.SetUserSetting(UserSettingConstants.SendFileTo, this.SendFileToPath);
+ this.userSettingService.SetUserSetting(UserSettingConstants.SendFile, this.SendFileAfterEncode);
+ this.userSettingService.SetUserSetting(UserSettingConstants.SendFileToArgs, this.Arguments);
/* Output Files */
this.userSettingService.SetUserSetting(UserSettingConstants.AutoNaming, this.AutomaticallyNameFiles);
@@ -1852,7 +1854,7 @@ namespace HandBrakeWPF.ViewModels
/* System and Logging */
userSettingService.SetUserSetting(ASUserSettingConstants.ProcessPriority, this.SelectedPriority);
- userSettingService.SetUserSetting(ASUserSettingConstants.PreventSleep, this.PreventSleep);
+ userSettingService.SetUserSetting(UserSettingConstants.PreventSleep, this.PreventSleep);
userSettingService.SetUserSetting(ASUserSettingConstants.Verbosity, this.SelectedVerbosity);
userSettingService.SetUserSetting(ASUserSettingConstants.SaveLogWithVideo, this.CopyLogToEncodeDirectory);
userSettingService.SetUserSetting(ASUserSettingConstants.SaveLogToCopyDirectory, this.CopyLogToSepcficedLocation);
@@ -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";
Process.Start(Path.Combine(Path.GetTempPath(), "handbrake-setup.exe"));
- Application.Current.Shutdown();
+ Execute.OnUIThread(() => Application.Current.Shutdown());
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
index 3b5bf33e8..bf7d46b3d 100644
--- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
@@ -10,13 +10,11 @@
namespace HandBrakeWPF.ViewModels
{
using System;
- using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows;
using Caliburn.Micro;
- using HandBrake.ApplicationServices;
using HandBrake.ApplicationServices.EventArgs;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Interfaces;
@@ -31,13 +29,6 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public class QueueViewModel : ViewModelBase, IQueueViewModel
{
- /*
-
- * TODO FIX THE DRAP/DROP ADORNER!
- */
-
-
-
#region Constants and Fields
/// <summary>
@@ -82,9 +73,6 @@ namespace HandBrakeWPF.ViewModels
/// <summary>
/// Initializes a new instance of the <see cref="QueueViewModel"/> class.
/// </summary>
- /// <param name="windowManager">
- /// The window manager.
- /// </param>
/// <param name="userSettingService">
/// The user Setting Service.
/// </param>
@@ -94,7 +82,7 @@ namespace HandBrakeWPF.ViewModels
/// <param name="errorService">
/// The Error Service
/// </param>
- public QueueViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IQueueProcessor queueProcessor, IErrorService errorService)
+ public QueueViewModel(IUserSettingService userSettingService, IQueueProcessor queueProcessor, IErrorService errorService)
{
this.userSettingService = userSettingService;
this.queueProcessor = queueProcessor;
@@ -199,7 +187,7 @@ namespace HandBrakeWPF.ViewModels
public void WhenDone(string action)
{
this.WhenDoneAction = action;
- this.userSettingService.SetUserSetting(ASUserSettingConstants.WhenCompleteAction, action);
+ this.userSettingService.SetUserSetting(UserSettingConstants.WhenCompleteAction, action);
}
/// <summary>
@@ -374,7 +362,7 @@ namespace HandBrakeWPF.ViewModels
{
this.Load();
- this.WhenDoneAction = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.WhenCompleteAction);
+ this.WhenDoneAction = this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction);
this.queueProcessor.JobProcessingStarted += this.queueProcessor_JobProcessingStarted;
this.queueProcessor.QueueCompleted += this.queueProcessor_QueueCompleted;
@@ -429,7 +417,6 @@ namespace HandBrakeWPF.ViewModels
e.EstimatedTimeLeft,
e.ElapsedTime);
}
-
});
}