diff options
author | sr55 <[email protected]> | 2012-06-26 20:46:19 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2012-06-26 20:46:19 +0000 |
commit | a47da7b31e9150888bcd8a495841be00f97b1114 (patch) | |
tree | fdb3ef05132ce0c34891641a2ce498d70ed9da4f /win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs | |
parent | be14d23c567b88a857df6f91f5c8a95c8c8e17fa (diff) |
WinGui: Another set of assorted fixes and UI tweaks.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4781 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs')
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs index 349dc1200..ef3f1a53a 100644 --- a/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs @@ -10,8 +10,14 @@ namespace HandBrakeWPF.ViewModels
{
using System.ComponentModel.Composition;
+ using System.Windows;
+
+ using Caliburn.Micro;
+
+ using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrakeWPF.Model;
+ using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.ViewModels.Interfaces;
/// <summary>
@@ -20,6 +26,11 @@ namespace HandBrakeWPF.ViewModels [Export(typeof(IShellViewModel))]
public class ShellViewModel : ViewModelBase, IShellViewModel
{
+ /// <summary>
+ /// Backing field for the error service.
+ /// </summary>
+ private readonly IErrorService errorService;
+
#region Constants and Fields
/// <summary>
@@ -37,8 +48,12 @@ namespace HandBrakeWPF.ViewModels /// <summary>
/// Initializes a new instance of the <see cref="ShellViewModel"/> class.
/// </summary>
- public ShellViewModel()
+ /// <param name="errorService">
+ /// The error Service.
+ /// </param>
+ public ShellViewModel(IErrorService errorService)
{
+ this.errorService = errorService;
this.showMainWindow = true;
this.showOptions = false;
}
@@ -60,7 +75,7 @@ namespace HandBrakeWPF.ViewModels {
this.ShowOptions = true;
this.ShowMainWindow = false;
- }
+ }
else
{
this.ShowMainWindow = true;
@@ -124,5 +139,35 @@ namespace HandBrakeWPF.ViewModels }
#endregion
+
+ /// <summary>
+ /// Checks with the use if this window can be closed.
+ /// </summary>
+ /// <returns>
+ /// Returns true if the window can be closed.
+ /// </returns>
+ public bool CanClose()
+ {
+ IQueueProcessor processor = IoC.Get<IQueueProcessor>();
+ if (processor.EncodeService.IsEncoding)
+ {
+ MessageBoxResult result =
+ errorService.ShowMessageBox(
+ "An Encode is currently running. Exiting HandBrake will stop this encode.\nAre you sure you wish to continue?",
+ "Warning",
+ MessageBoxButton.YesNo,
+ MessageBoxImage.Warning);
+
+ if (result == MessageBoxResult.Yes)
+ {
+ processor.Pause();
+ processor.EncodeService.Stop();
+ return true;
+ }
+ return false;
+ }
+
+ return true;
+ }
}
}
\ No newline at end of file |