diff options
Diffstat (limited to 'win/CS/HandBrakeWPF/Services')
-rw-r--r-- | win/CS/HandBrakeWPF/Services/PrePostActionService.cs | 81 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/ScanServiceWrapper.cs | 56 |
2 files changed, 60 insertions, 77 deletions
diff --git a/win/CS/HandBrakeWPF/Services/PrePostActionService.cs b/win/CS/HandBrakeWPF/Services/PrePostActionService.cs index ce4eee423..7cfceace3 100644 --- a/win/CS/HandBrakeWPF/Services/PrePostActionService.cs +++ b/win/CS/HandBrakeWPF/Services/PrePostActionService.cs @@ -1,5 +1,5 @@ // --------------------------------------------------------------------------------------------------------------------
-// <copyright file="WhenDoneService.cs" company="HandBrake Project (http://handbrake.fr)">
+// <copyright file="PrePostActionService.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>
@@ -14,10 +14,12 @@ namespace HandBrakeWPF.Services using Caliburn.Micro;
+ using HandBrake.ApplicationServices.EventArgs;
using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Services.Interfaces;
+ using HandBrakeWPF.ViewModels.Interfaces;
using Application = System.Windows.Application;
@@ -37,6 +39,11 @@ namespace HandBrakeWPF.Services private readonly IUserSettingService userSettingService;
/// <summary>
+ /// The window manager.
+ /// </summary>
+ private readonly IWindowManager windowManager;
+
+ /// <summary>
/// Initializes a new instance of the <see cref="PrePostActionService"/> class.
/// </summary>
/// <param name="queueProcessor">
@@ -45,10 +52,14 @@ namespace HandBrakeWPF.Services /// <param name="userSettingService">
/// The user Setting Service.
/// </param>
- public PrePostActionService(IQueueProcessor queueProcessor, IUserSettingService userSettingService)
+ /// <param name="windowManager">
+ /// The window Manager.
+ /// </param>
+ public PrePostActionService(IQueueProcessor queueProcessor, IUserSettingService userSettingService, IWindowManager windowManager)
{
this.queueProcessor = queueProcessor;
this.userSettingService = userSettingService;
+ this.windowManager = windowManager;
this.queueProcessor.QueueCompleted += QueueProcessorQueueCompleted;
this.queueProcessor.EncodeService.EncodeCompleted += EncodeService_EncodeCompleted;
@@ -108,29 +119,53 @@ namespace HandBrakeWPF.Services /// <param name="e">
/// The e.
/// </param>
- private void QueueProcessorQueueCompleted(object sender, System.EventArgs e)
+ private void QueueProcessorQueueCompleted(object sender, QueueCompletedEventArgs e)
{
- // Do something whent he encode ends.
- switch (this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction))
+ if (e.WasManuallyStopped)
+ {
+ return;
+ }
+
+
+ if (this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction) == "Do nothing")
{
- 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;
+ return;
+ }
+
+ // Give the user the ability to cancel the shutdown. Default 60 second timer.
+ ICountdownAlertViewModel titleSpecificView = IoC.Get<ICountdownAlertViewModel>();
+ Caliburn.Micro.Execute.OnUIThread(
+ () =>
+ {
+ titleSpecificView.SetAction(this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction));
+ this.windowManager.ShowDialog(titleSpecificView);
+ });
+
+
+ if (!titleSpecificView.IsCancelled)
+ {
+ // 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;
+ }
}
}
diff --git a/win/CS/HandBrakeWPF/Services/ScanServiceWrapper.cs b/win/CS/HandBrakeWPF/Services/ScanServiceWrapper.cs index f66aff538..8180ac070 100644 --- a/win/CS/HandBrakeWPF/Services/ScanServiceWrapper.cs +++ b/win/CS/HandBrakeWPF/Services/ScanServiceWrapper.cs @@ -13,12 +13,9 @@ namespace HandBrakeWPF.Services {
using System;
- using HandBrake.ApplicationServices.Exceptions;
- using HandBrake.ApplicationServices.Isolation;
using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Services;
using HandBrake.ApplicationServices.Services.Interfaces;
- using HandBrake.Interop;
using HandBrake.Interop.Interfaces;
/// <summary>
@@ -48,41 +45,11 @@ namespace HandBrakeWPF.Services /// Initializes a new instance of the <see cref="ScanServiceWrapper"/> class.
/// </summary>
/// <param name="userSettingService">
- /// The user setting service.
+ /// The user Setting Service.
/// </param>
public ScanServiceWrapper(IUserSettingService userSettingService)
{
- var useLibHb = userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableLibHb);
- var useProcessIsolation =
- userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableProcessIsolation);
- string port = userSettingService.GetUserSetting<string>(UserSettingConstants.ServerPort);
-
- if (useLibHb)
- {
- try
- {
- if (useProcessIsolation)
- {
- this.scanService = new IsolatedScanService(port);
- }
- else
- {
- HandbrakeInstance = new HandBrakeInstance();
- this.scanService = new LibScan(HandbrakeInstance);
- }
- }
- catch(Exception exc)
- {
- // Try to recover from errors.
- userSettingService.SetUserSetting(UserSettingConstants.EnableLibHb, false);
- throw new GeneralApplicationException("Unable to initialise LibHB or Background worker service", "Falling back to using HandBrakeCLI.exe. Setting has been reset", exc);
- }
- }
- else
- {
- this.scanService = new ScanService(userSettingService);
- }
-
+ this.scanService = new LibScan(userSettingService);
this.scanService.ScanCompleted += this.ScanServiceScanCompleted;
this.scanService.ScanStared += this.ScanServiceScanStared;
this.scanService.ScanStatusChanged += this.ScanServiceScanStatusChanged;
@@ -193,25 +160,6 @@ namespace HandBrakeWPF.Services #region IScan
/// <summary>
- /// Take a Scan Log file, and process it as if it were from the CLI.
- /// </summary>
- /// <param name="path">
- /// The path to the log file.
- /// </param>
- public void DebugScanLog(string path)
- {
- this.scanService.DebugScanLog(path);
- }
-
- /// <summary>
- /// Shutdown the service.
- /// </summary>
- public void Shutdown()
- {
- this.scanService.Shutdown();
- }
-
- /// <summary>
/// Scan a Source Path.
/// Title 0: scan all
/// </summary>
|