From eff231c2375c4056925c538332db44445de027e1 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 20 Feb 2016 17:28:42 +0000 Subject: [PATCH] WinGui: Adding a "Queue" Menu --- .../Commands/Menu/QueueCommandParams.cs | 23 ++++++ .../Commands/Menu/QueueCommands.cs | 81 +++++++++++++++++++ win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 2 + .../ViewModels/Interfaces/IQueueViewModel.cs | 25 ++++++ .../HandBrakeWPF/ViewModels/MainViewModel.cs | 11 +++ win/CS/HandBrakeWPF/Views/MainView.xaml | 13 +++ 6 files changed, 155 insertions(+) create mode 100644 win/CS/HandBrakeWPF/Commands/Menu/QueueCommandParams.cs create mode 100644 win/CS/HandBrakeWPF/Commands/Menu/QueueCommands.cs diff --git a/win/CS/HandBrakeWPF/Commands/Menu/QueueCommandParams.cs b/win/CS/HandBrakeWPF/Commands/Menu/QueueCommandParams.cs new file mode 100644 index 000000000..e68b17d09 --- /dev/null +++ b/win/CS/HandBrakeWPF/Commands/Menu/QueueCommandParams.cs @@ -0,0 +1,23 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the QueueCommandParams type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Commands.Menu +{ + /// + /// The queue command params. + /// + public enum QueueCommandParams + { + ClearCompleted, + ClearAll, + ClearSelected, + Import, + Export + } +} diff --git a/win/CS/HandBrakeWPF/Commands/Menu/QueueCommands.cs b/win/CS/HandBrakeWPF/Commands/Menu/QueueCommands.cs new file mode 100644 index 000000000..2f0bb009d --- /dev/null +++ b/win/CS/HandBrakeWPF/Commands/Menu/QueueCommands.cs @@ -0,0 +1,81 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The queue commands. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Commands.Menu +{ + using System; + using System.Windows.Input; + + using HandBrakeWPF.ViewModels.Interfaces; + + /// + /// The queue commands. + /// + public class QueueCommands : ICommand + { + /// + /// Gets or sets the queue view model. + /// + public IQueueViewModel QueueViewModel { get; set; } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The queue View Model. + /// + public QueueCommands(IQueueViewModel queueViewModel) + { + this.QueueViewModel = queueViewModel; + } + + /// + /// Defines the method that determines whether the command can execute in its current state. + /// + /// + /// true if this command can be executed; otherwise, false. + /// + /// Data used by the command. If the command does not require data to be passed, this object can be set to null. + public bool CanExecute(object parameter) + { + return true; + } + + /// + /// Defines the method to be called when the command is invoked. + /// + /// Data used by the command. If the command does not require data to be passed, this object can be set to null. + public void Execute(object parameter) + { + switch ((QueueCommandParams)parameter) + { + case QueueCommandParams.ClearAll: + this.QueueViewModel.Clear(); + break; + case QueueCommandParams.ClearCompleted: + this.QueueViewModel.ClearCompleted(); + break; + case QueueCommandParams.ClearSelected: + this.QueueViewModel.RemoveSelectedJobs(); + break; + case QueueCommandParams.Import: + this.QueueViewModel.Import(); + break; + case QueueCommandParams.Export: + this.QueueViewModel.Export(); + break; + } + } + + /// + /// The can execute changed. + /// + public event EventHandler CanExecuteChanged; + } +} diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 21b92b13e..4b4dd7b81 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -128,6 +128,8 @@ + + diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueViewModel.cs index 770869122..44d5d0f98 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueViewModel.cs @@ -21,5 +21,30 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// The action. /// void WhenDone(string action); + + /// + /// The import. + /// + void Import(); + + /// + /// The export. + /// + void Export(); + + /// + /// The clear completed. + /// + void ClearCompleted(); + + /// + /// The clear. + /// + void Clear(); + + /// + /// The remove selected jobs. + /// + void RemoveSelectedJobs(); } } \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 5eb792abb..0065bef6a 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -18,6 +18,7 @@ namespace HandBrakeWPF.ViewModels using System.Linq; using System.Threading; using System.Windows; + using System.Windows.Input; using Caliburn.Micro; @@ -25,6 +26,7 @@ namespace HandBrakeWPF.ViewModels using HandBrake.ApplicationServices.Utilities; using HandBrakeWPF.Commands; + using HandBrakeWPF.Commands.Menu; using HandBrakeWPF.EventArgs; using HandBrakeWPF.Factories; using HandBrakeWPF.Helpers; @@ -221,6 +223,9 @@ namespace HandBrakeWPF.ViewModels break; } + // Setup Commands + this.QueueCommand = new QueueCommands(this.QueueViewModel); + HandBrakeInstanceManager.Init(); } @@ -1176,6 +1181,12 @@ namespace HandBrakeWPF.ViewModels #endregion + #region Commands + + public ICommand QueueCommand { get; set; } + + #endregion + #region Load and Shutdown Handling /// diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index ae24fb286..3b86fdcb3 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -8,6 +8,7 @@ xmlns:Properties="clr-namespace:HandBrakeWPF.Properties" xmlns:cal="http://www.caliburnproject.org" xmlns:attachedProperties="clr-namespace:HandBrakeWPF.AttachedProperties" + xmlns:menu="clr-namespace:HandBrakeWPF.Commands.Menu" AllowDrop="True" FontSize="11" cal:Message.Attach="[Event Loaded] = [Action Load]" @@ -125,6 +126,18 @@ + + + + + + + + + + + + -- 2.40.0