diff options
author | sr55 <[email protected]> | 2015-04-18 15:36:25 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2015-04-18 15:36:25 +0000 |
commit | 6ba51b19f630f10180bda723638d2689061945f1 (patch) | |
tree | 816f446278f70fb0e071475064c06b613593d45f /win/CS/HandBrakeWPF/ViewModels | |
parent | a39cfcd93434dcc73a67c993fc5020c65b4ef099 (diff) |
WinGui: Add "Delete" key shortcut to the queue to delete selected items.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7097 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs index 52c51419b..a5d33aa42 100644 --- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs @@ -10,7 +10,9 @@ namespace HandBrakeWPF.ViewModels
{
using System;
+ using System.Collections.Generic;
using System.ComponentModel;
+ using System.Linq;
using System.Windows;
using Caliburn.Micro;
@@ -94,6 +96,7 @@ namespace HandBrakeWPF.ViewModels this.Title = "Queue";
this.JobsPending = "No encodes pending";
this.JobStatus = "There are no jobs currently encoding";
+ this.SelectedItems = new BindingList<QueueTask>();
}
#endregion
@@ -178,6 +181,11 @@ namespace HandBrakeWPF.ViewModels }
}
+ /// <summary>
+ /// Gets or sets the selected items.
+ /// </summary>
+ public BindingList<QueueTask> SelectedItems { get; set; }
+
#endregion
#region Public Methods
@@ -251,13 +259,43 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
+ /// The remove selected jobs.
+ /// </summary>
+ public void RemoveSelectedJobs()
+ {
+ MessageBoxResult result =
+ this.errorService.ShowMessageBox(
+ "Are you sure you want to delete the selected jobs?",
+ Resources.Question,
+ MessageBoxButton.YesNo,
+ MessageBoxImage.Question);
+
+ if (result == MessageBoxResult.No)
+ {
+ return;
+ }
+
+ List<QueueTask> tasksToRemove = this.SelectedItems.ToList();
+ foreach (QueueTask job in tasksToRemove)
+ {
+ this.RemoveJob(job);
+ }
+ }
+
+ /// <summary>
/// Remove a Job from the queue
/// </summary>
- /// <param name="task">
+ /// <param name="queueTask">
/// The Job to remove from the queue
/// </param>
- public void RemoveJob(QueueTask task)
+ public void RemoveJob(object queueTask)
{
+ QueueTask task = queueTask as QueueTask;
+ if (task == null)
+ {
+ return;
+ }
+
if (task.Status == QueueItemStatus.InProgress)
{
MessageBoxResult result =
|