From 5a68b81a051564097a03fb12373a593ce4f24fc0 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 7 Jan 2017 18:50:57 +0000 Subject: WinGui: Adding Queue Start/Pause Context Menu options to the In-line queue and queue window. #489 --- .../Properties/ResourcesUI.Designer.cs | 4 +- win/CS/HandBrakeWPF/Properties/ResourcesUI.resx | 4 +- .../ViewModels/Interfaces/IQueueViewModel.cs | 10 +++ win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 8 ++ win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs | 86 ++++++++++++++++++---- win/CS/HandBrakeWPF/Views/Queue/Embedded.xaml | 9 ++- win/CS/HandBrakeWPF/Views/QueueView.xaml | 15 ++-- 7 files changed, 107 insertions(+), 29 deletions(-) (limited to 'win/CS') diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs index 28dd1e6b0..c822e1e00 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs @@ -1845,7 +1845,7 @@ namespace HandBrakeWPF.Properties { } /// - /// Looks up a localized string similar to Pause. + /// Looks up a localized string similar to Pause Queue. /// public static string QueueView_Pause { get { @@ -1890,7 +1890,7 @@ namespace HandBrakeWPF.Properties { } /// - /// Looks up a localized string similar to Start. + /// Looks up a localized string similar to Start Queue. /// public static string QueueView_Start { get { diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx index fa9231625..30e783a93 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx +++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx @@ -526,7 +526,7 @@ Options - Pause + Pause Queue Picture Settings: @@ -541,7 +541,7 @@ Source: - Start + Start Queue Subtitles: diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueViewModel.cs index 44d5d0f98..51c8e462e 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueViewModel.cs @@ -46,5 +46,15 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// The remove selected jobs. /// void RemoveSelectedJobs(); + + /// + /// Activate this panel + /// + void Activate(); + + /// + /// Deactivate this panel + /// + void Deactivate(); } } \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 36e65d2e5..15b959867 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1330,6 +1330,14 @@ namespace HandBrakeWPF.ViewModels if (this.userSettingService.GetUserSetting(UserSettingConstants.ShowQueueInline)) { this.IsQueueShowingInLine = !this.IsQueueShowingInLine; + if (this.IsQueueShowingInLine) + { + this.QueueViewModel.Activate(); + } + else + { + this.QueueViewModel.Deactivate(); + } this.NotifyOfPropertyChange(() => this.IsQueueShowingInLine); } else diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs index eed3a1a79..f56e6f4fc 100644 --- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs @@ -46,6 +46,8 @@ namespace HandBrakeWPF.ViewModels private string jobsPending; private string whenDoneAction; + private bool isQueueRunning; + #endregion #region Constructors and Destructors @@ -72,7 +74,8 @@ namespace HandBrakeWPF.ViewModels this.JobStatus = Resources.QueueViewModel_NoJobsPending; this.SelectedItems = new BindingList(); this.DisplayName = "Queue"; - + this.IsQueueRunning = false; + this.WhenDoneAction = this.userSettingService.GetUserSetting(UserSettingConstants.WhenCompleteAction); } @@ -81,19 +84,19 @@ namespace HandBrakeWPF.ViewModels #region Properties /// - /// Gets or sets a value indicating whether IsEncoding. + /// Gets or sets a value indicating whether the Queue is paused or not.. /// - public bool IsEncoding + public bool IsQueueRunning { get { - return this.isEncoding; + return this.isQueueRunning; } - set { - this.isEncoding = value; - this.NotifyOfPropertyChange(() => IsEncoding); + if (value == this.isQueueRunning) return; + this.isQueueRunning = value; + this.NotifyOfPropertyChange(() => this.IsQueueRunning); } } @@ -214,27 +217,50 @@ namespace HandBrakeWPF.ViewModels public override void OnLoad() { // Setup the window to the correct state. - this.IsEncoding = this.queueProcessor.EncodeService.IsEncoding; + this.IsQueueRunning = this.queueProcessor.EncodeService.IsEncoding; this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count); base.OnLoad(); } /// - /// Pause Encode + /// Can Pause the Queue. + /// Used by Caliburn Micro to enable/disable the context menu item. + /// + /// + /// True when we can pause the queue. + /// + public bool CanPauseQueue() + { + return this.IsQueueRunning; + } + + /// + /// Pause the Queue /// - public void PauseEncode() + public void PauseQueue() { this.queueProcessor.Pause(); this.JobStatus = Resources.QueueViewModel_QueuePending; this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count); - this.IsEncoding = false; + this.IsQueueRunning = false; MessageBox.Show(Resources.QueueViewModel_QueuePauseNotice, Resources.QueueViewModel_Queue, MessageBoxButton.OK, MessageBoxImage.Information); } + /// + /// Pause the Queue + /// + /// + /// Prevents evaluation of CanPauseQueue + /// + public void PauseQueueToolbar() + { + this.PauseQueue(); + } + /// /// The remove selected jobs. /// @@ -307,10 +333,22 @@ namespace HandBrakeWPF.ViewModels this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count); } + /// + /// Can Start Encoding. + /// Used by Caliburn Micro to enable/disable the context menu item. + /// + /// + /// True when we can start encoding. + /// + public bool CanStartQueue() + { + return !this.IsQueueRunning; + } + /// /// Start Encode /// - public void StartEncode() + public void StartQueue() { if (this.queueProcessor.Count == 0) { @@ -321,7 +359,7 @@ namespace HandBrakeWPF.ViewModels this.JobStatus = Resources.QueueViewModel_QueueStarted; this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count); - this.IsEncoding = true; + this.IsQueueRunning = true; this.queueProcessor.Start(userSettingService.GetUserSetting(UserSettingConstants.ClearCompletedFromQueue)); } @@ -395,6 +433,21 @@ namespace HandBrakeWPF.ViewModels #region Methods + public void Activate() + { + this.queueProcessor.QueueCompleted += this.queueProcessor_QueueCompleted; + this.queueProcessor.QueueChanged += this.QueueManager_QueueChanged; + this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted; + + } + + public void Deactivate() + { + this.queueProcessor.QueueCompleted -= this.queueProcessor_QueueCompleted; + this.queueProcessor.QueueChanged -= this.QueueManager_QueueChanged; + this.queueProcessor.JobProcessingStarted -= this.QueueProcessorJobProcessingStarted; + } + /// /// Override the OnActive to run the Screen Loading code in the view model base. /// @@ -472,7 +525,7 @@ namespace HandBrakeWPF.ViewModels this.queueProcessor.Pause(); this.JobStatus = Resources.QueueViewModel_QueuePending; this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count); - this.IsEncoding = false; + this.IsQueueRunning = false; this.errorService.ShowMessageBox( Resources.MainViewModel_LowDiskSpaceWarning, @@ -498,6 +551,7 @@ namespace HandBrakeWPF.ViewModels if (!queueProcessor.IsProcessing) { this.JobStatus = Resources.QueueViewModel_QueueNotRunning; + this.IsQueueRunning = false; } } @@ -514,7 +568,7 @@ namespace HandBrakeWPF.ViewModels { this.JobStatus = Resources.QueueViewModel_QueueCompleted; this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count); - this.IsEncoding = false; + this.IsQueueRunning = false; } /// @@ -547,7 +601,7 @@ namespace HandBrakeWPF.ViewModels { this.JobStatus = Resources.QueueViewModel_QueueStarted; this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count); - this.IsEncoding = true; + this.IsQueueRunning = true; } #endregion diff --git a/win/CS/HandBrakeWPF/Views/Queue/Embedded.xaml b/win/CS/HandBrakeWPF/Views/Queue/Embedded.xaml index 6d86bd7c8..114556c43 100644 --- a/win/CS/HandBrakeWPF/Views/Queue/Embedded.xaml +++ b/win/CS/HandBrakeWPF/Views/Queue/Embedded.xaml @@ -44,8 +44,8 @@ - - - + + + + diff --git a/win/CS/HandBrakeWPF/Views/QueueView.xaml b/win/CS/HandBrakeWPF/Views/QueueView.xaml index c1c00bb39..414c29e30 100644 --- a/win/CS/HandBrakeWPF/Views/QueueView.xaml +++ b/win/CS/HandBrakeWPF/Views/QueueView.xaml @@ -66,8 +66,8 @@