diff options
author | sr55 <[email protected]> | 2017-01-07 18:50:57 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2017-01-07 18:50:57 +0000 |
commit | 5a68b81a051564097a03fb12373a593ce4f24fc0 (patch) | |
tree | a68ea31c54d3536d53510e04b08959d67796e8a3 /win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs | |
parent | 610d4b38d0c86ad36fd7a8d66a69ea64b01afdb3 (diff) |
WinGui: Adding Queue Start/Pause Context Menu options to the In-line queue and queue window. #489
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs')
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs | 86 |
1 files changed, 70 insertions, 16 deletions
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<QueueTask>();
this.DisplayName = "Queue";
-
+ this.IsQueueRunning = false;
+
this.WhenDoneAction = this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction);
}
@@ -81,19 +84,19 @@ namespace HandBrakeWPF.ViewModels #region Properties
/// <summary>
- /// Gets or sets a value indicating whether IsEncoding.
+ /// Gets or sets a value indicating whether the Queue is paused or not..
/// </summary>
- 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,28 +217,51 @@ 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();
}
/// <summary>
- /// Pause Encode
+ /// Can Pause the Queue.
+ /// Used by Caliburn Micro to enable/disable the context menu item.
+ /// </summary>
+ /// <returns>
+ /// True when we can pause the queue.
+ /// </returns>
+ public bool CanPauseQueue()
+ {
+ return this.IsQueueRunning;
+ }
+
+ /// <summary>
+ /// Pause the Queue
/// </summary>
- 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);
}
/// <summary>
+ /// Pause the Queue
+ /// </summary>
+ /// <remarks>
+ /// Prevents evaluation of CanPauseQueue
+ /// </remarks>
+ public void PauseQueueToolbar()
+ {
+ this.PauseQueue();
+ }
+
+ /// <summary>
/// The remove selected jobs.
/// </summary>
public void RemoveSelectedJobs()
@@ -308,9 +334,21 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
+ /// Can Start Encoding.
+ /// Used by Caliburn Micro to enable/disable the context menu item.
+ /// </summary>
+ /// <returns>
+ /// True when we can start encoding.
+ /// </returns>
+ public bool CanStartQueue()
+ {
+ return !this.IsQueueRunning;
+ }
+
+ /// <summary>
/// Start Encode
/// </summary>
- 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<bool>(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;
+ }
+
/// <summary>
/// Override the OnActive to run the Screen Loading code in the view model base.
/// </summary>
@@ -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;
}
/// <summary>
@@ -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
|