diff options
Diffstat (limited to 'win/CS/HandBrakeWPF/Services')
-rw-r--r-- | win/CS/HandBrakeWPF/Services/PrePostActionService.cs | 71 |
1 files changed, 50 insertions, 21 deletions
diff --git a/win/CS/HandBrakeWPF/Services/PrePostActionService.cs b/win/CS/HandBrakeWPF/Services/PrePostActionService.cs index 964e453ad..7cfceace3 100644 --- a/win/CS/HandBrakeWPF/Services/PrePostActionService.cs +++ b/win/CS/HandBrakeWPF/Services/PrePostActionService.cs @@ -19,6 +19,7 @@ namespace HandBrakeWPF.Services using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Services.Interfaces;
+ using HandBrakeWPF.ViewModels.Interfaces;
using Application = System.Windows.Application;
@@ -38,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">
@@ -46,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;
@@ -116,27 +126,46 @@ namespace HandBrakeWPF.Services return;
}
- // Do something whent he encode ends.
- switch (this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction))
+
+ 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;
+ }
}
}
|