--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="InputBindingTrigger.cs" company="HandBrake Project (http://handbrake.fr)">\r
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
+// </copyright>\r
+// <summary>\r
+// The input binding trigger.\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrakeWPF.Commands\r
+{\r
+ using System;\r
+ using System.Diagnostics;\r
+ using System.Windows;\r
+ using System.Windows.Input;\r
+ using System.Windows.Interactivity;\r
+\r
+ /// <summary>\r
+ /// The input binding trigger.\r
+ /// </summary>\r
+ public class InputBindingTrigger : TriggerBase<FrameworkElement>, ICommand\r
+ {\r
+ public static readonly DependencyProperty InputBindingProperty = DependencyProperty.Register("InputBinding", typeof(InputBinding), typeof(InputBindingTrigger), new UIPropertyMetadata(null));\r
+\r
+ /// <summary>\r
+ /// Gets or sets the input binding.\r
+ /// </summary>\r
+ public InputBinding InputBinding\r
+ {\r
+ get { return (InputBinding)GetValue(InputBindingProperty); }\r
+ set { SetValue(InputBindingProperty, value); }\r
+ }\r
+\r
+ /// <summary>\r
+ /// The can execute changed.\r
+ /// </summary>\r
+ public event EventHandler CanExecuteChanged = delegate { };\r
+\r
+ /// <summary>\r
+ /// The can execute.\r
+ /// </summary>\r
+ /// <param name="parameter">\r
+ /// The parameter.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The <see cref="bool"/>.\r
+ /// </returns>\r
+ public bool CanExecute(object parameter)\r
+ {\r
+ // action is anyway blocked by Caliburn at the invoke level\r
+ return true;\r
+ }\r
+\r
+ /// <summary>\r
+ /// The execute.\r
+ /// </summary>\r
+ /// <param name="parameter">\r
+ /// The parameter.\r
+ /// </param>\r
+ public void Execute(object parameter)\r
+ {\r
+ InvokeActions(parameter);\r
+ }\r
+\r
+ /// <summary>\r
+ /// The on attached.\r
+ /// </summary>\r
+ protected override void OnAttached()\r
+ {\r
+ if (InputBinding != null)\r
+ {\r
+ InputBinding.Command = this;\r
+ AssociatedObject.Loaded += delegate\r
+ {\r
+ var window = GetWindow(AssociatedObject);\r
+ window.InputBindings.Add(InputBinding);\r
+ };\r
+ }\r
+ base.OnAttached();\r
+ }\r
+\r
+ /// <summary>\r
+ /// The get window.\r
+ /// </summary>\r
+ /// <param name="frameworkElement">\r
+ /// The framework element.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The <see cref="Window"/>.\r
+ /// </returns>\r
+ private Window GetWindow(FrameworkElement frameworkElement)\r
+ {\r
+ if (frameworkElement is Window)\r
+ return frameworkElement as Window;\r
+\r
+ var parent = frameworkElement.Parent as FrameworkElement;\r
+ Debug.Assert(parent != null);\r
+\r
+ return GetWindow(parent);\r
+ }\r
+ }\r
+}\r
<Compile Include="AttachedProperties\MenuItemExtensions.cs" />\r
<Compile Include="Collections\SerializableDictionary.cs" />\r
<Compile Include="Commands\CancelScanCommand.cs" />\r
+ <Compile Include="Commands\InputBindingTrigger.cs" />\r
<Compile Include="Commands\Interfaces\IAdvancedEncoderOptionsCommand.cs" />\r
<Compile Include="Commands\OpenOptionsScreenCommand.cs" />\r
<Compile Include="Commands\CloseOverlayPanelCommand.cs" />\r
namespace HandBrakeWPF.ViewModels\r
{\r
using System;\r
+ using System.Collections.Generic;\r
using System.ComponentModel;\r
+ using System.Linq;\r
using System.Windows;\r
\r
using Caliburn.Micro;\r
this.Title = "Queue";\r
this.JobsPending = "No encodes pending";\r
this.JobStatus = "There are no jobs currently encoding";\r
+ this.SelectedItems = new BindingList<QueueTask>();\r
}\r
\r
#endregion\r
}\r
}\r
\r
+ /// <summary>\r
+ /// Gets or sets the selected items.\r
+ /// </summary>\r
+ public BindingList<QueueTask> SelectedItems { get; set; } \r
+\r
#endregion\r
\r
#region Public Methods\r
MessageBoxButton.OK, MessageBoxImage.Information);\r
}\r
\r
+ /// <summary>\r
+ /// The remove selected jobs.\r
+ /// </summary>\r
+ public void RemoveSelectedJobs()\r
+ {\r
+ MessageBoxResult result =\r
+ this.errorService.ShowMessageBox(\r
+ "Are you sure you want to delete the selected jobs?",\r
+ Resources.Question,\r
+ MessageBoxButton.YesNo,\r
+ MessageBoxImage.Question);\r
+\r
+ if (result == MessageBoxResult.No)\r
+ {\r
+ return;\r
+ }\r
+\r
+ List<QueueTask> tasksToRemove = this.SelectedItems.ToList();\r
+ foreach (QueueTask job in tasksToRemove)\r
+ {\r
+ this.RemoveJob(job);\r
+ }\r
+ }\r
+\r
/// <summary>\r
/// Remove a Job from the queue\r
/// </summary>\r
- /// <param name="task">\r
+ /// <param name="queueTask">\r
/// The Job to remove from the queue\r
/// </param>\r
- public void RemoveJob(QueueTask task)\r
+ public void RemoveJob(object queueTask)\r
{\r
+ QueueTask task = queueTask as QueueTask;\r
+ if (task == null)\r
+ {\r
+ return;\r
+ }\r
+\r
if (task.Status == QueueItemStatus.InProgress)\r
{\r
MessageBoxResult result =\r
xmlns:Audio="clr-namespace:HandBrakeWPF.Converters.Audio"\r
xmlns:Subtitles="clr-namespace:HandBrakeWPF.Converters.Subtitles"\r
xmlns:video="clr-namespace:HandBrakeWPF.Converters.Video"\r
+ xmlns:commands="clr-namespace:HandBrakeWPF.Commands"\r
+ xmlns:helpers="clr-namespace:HandBrakeWPF.Helpers"\r
Title="{Binding Title}"\r
Width="700"\r
Height="500"\r
dd:DragDrop.IsDragSource="True"\r
dd:DragDrop.IsDropTarget="True"\r
ItemsSource="{Binding QueueTasks, Mode=OneWay}"\r
+ helpers:ListBoxHelper.SelectedItems="{Binding SelectedItems}" \r
SelectionMode="Extended">\r
\r
+ <i:Interaction.Triggers>\r
+ <commands:InputBindingTrigger>\r
+ <commands:InputBindingTrigger.InputBinding>\r
+ <KeyBinding Key="Delete"/>\r
+ </commands:InputBindingTrigger.InputBinding>\r
+ <cal:ActionMessage MethodName="RemoveSelectedJobs" />\r
+ </commands:InputBindingTrigger>\r
+ </i:Interaction.Triggers>\r
+\r
<ListBox.Style>\r
<Style TargetType="ListBox">\r
<Style.Triggers>\r
<ListBox.ContextMenu>\r
<ContextMenu>\r
<MenuItem cal:Message.Attach="[Event Click] = [Action ClearCompleted]" Header="Clear Completed" />\r
- <MenuItem cal:Message.Attach="[Event Click] = [Action Clear]" Header="Clear" />\r
+ <MenuItem cal:Message.Attach="[Event Click] = [Action Clear]" Header="Clear All" />\r
+ <MenuItem cal:Message.Attach="[Event Click] = [Action RemoveSelectedJobs]" Header="Clear Selected" /> \r
<Separator />\r
<MenuItem cal:Message.Attach="[Event Click] = [Action Import]" Header="Import Queue" />\r
<MenuItem cal:Message.Attach="[Event Click] = [Action Export]" Header="Export Queue" />\r
\r
<DockPanel Background="Black" Opacity="0.60" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Panel.ZIndex="1"\r
Visibility="{Binding ShowOverlayPanel, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" />\r
- \r
- <!--<ContentControl x:Name="OverlayPanelViewModel" Visibility="{Binding ShowOverlayPanel, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" \r
- VerticalAlignment="Center" HorizontalAlignment="Center" Panel.ZIndex="2" MinWidth="900" MinHeight="675" />-->\r
-\r
\r
</Grid>\r
</Window>\r