summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2017-08-30 20:26:45 +0100
committersr55 <[email protected]>2017-08-30 20:26:45 +0100
commit6336b87579ad3cb913488a2dd1cbacb0af862966 (patch)
treefbe930e8816bd5d3fe3b11dcdc71df0f9861d3a2 /win
parentec19d8520ea39761053cccb2744931f0195b7bba (diff)
WinGui: Some consistency fixes and UI tweaks around queue start/pause/stop.
Diffstat (limited to 'win')
-rw-r--r--win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs20
-rw-r--r--win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs25
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs35
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs5
4 files changed, 60 insertions, 25 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs b/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs
index ead10cbf3..c907f3758 100644
--- a/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs
+++ b/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs
@@ -155,11 +155,6 @@ namespace HandBrakeWPF.Services.Queue.Interfaces
void MoveUp(int index);
/// <summary>
- /// Requests a pause of the encode queue.
- /// </summary>
- void Pause();
-
- /// <summary>
/// Remove a job from the Queue.
/// This method is Thread Safe
/// </summary>
@@ -193,6 +188,21 @@ namespace HandBrakeWPF.Services.Queue.Interfaces
/// </param>
void Start(bool clearCompleted);
+ /// <summary>
+ /// Stop the current encode and pause the queue.
+ /// </summary>
+ void Stop();
+
+ /// <summary>
+ /// Pause the queue but allow the current encode to complete.
+ /// </summary>
+ void Pause();
+
+ /// <summary>
+ /// Pause and Encode and the Queue.
+ /// </summary>
+ void PauseEncode();
+
#endregion
}
} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs b/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs
index c7aee8131..614d36eb3 100644
--- a/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs
+++ b/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs
@@ -462,7 +462,17 @@ namespace HandBrakeWPF.Services.Queue
public void Pause()
{
this.IsProcessing = false;
- this.InvokeQueuePaused(EventArgs.Empty);
+ this.InvokeQueuePaused(EventArgs.Empty);
+ }
+
+ public void PauseEncode()
+ {
+ if (this.EncodeService.IsEncoding && !this.EncodeService.IsPasued)
+ {
+ this.EncodeService.Pause();
+ }
+
+ this.Pause();
}
/// <summary>
@@ -488,6 +498,7 @@ namespace HandBrakeWPF.Services.Queue
{
this.EncodeService.Resume();
this.IsProcessing = true;
+ this.InvokeJobProcessingStarted(new QueueProgressEventArgs(this.LastProcessedJob));
}
if (!this.EncodeService.IsEncoding)
@@ -496,6 +507,16 @@ namespace HandBrakeWPF.Services.Queue
}
}
+ public void Stop()
+ {
+ if (this.EncodeService.IsEncoding)
+ {
+ this.EncodeService.Stop();
+ }
+ this.IsProcessing = false;
+ this.InvokeQueuePaused(EventArgs.Empty);
+ }
+
#endregion
#region Methods
@@ -612,7 +633,7 @@ namespace HandBrakeWPF.Services.Queue
handler(this, e);
}
}
-
+
/// <summary>
/// Run through all the jobs on the queue.
/// </summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index 32241d53a..21b323aff 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -34,7 +34,6 @@ namespace HandBrakeWPF.ViewModels
using HandBrakeWPF.Model.Subtitles;
using HandBrakeWPF.Properties;
using HandBrakeWPF.Services.Encode.EventArgs;
- using HandBrakeWPF.Services.Encode.Interfaces;
using HandBrakeWPF.Services.Encode.Model;
using HandBrakeWPF.Services.Encode.Model.Models;
using HandBrakeWPF.Services.Interfaces;
@@ -77,7 +76,6 @@ namespace HandBrakeWPF.ViewModels
private readonly INotifyIconService notifyIconService;
private readonly IUserSettingService userSettingService;
private readonly IScan scanService;
- private readonly IEncode encodeService;
private readonly Win7 windowsSeven = new Win7();
private string windowName;
private string sourceLabel;
@@ -112,9 +110,6 @@ namespace HandBrakeWPF.ViewModels
/// <param name="scanService">
/// The scan Service.
/// </param>
- /// <param name="encodeService">
- /// The encode Service.
- /// </param>
/// <param name="presetService">
/// The preset Service.
/// </param>
@@ -165,7 +160,7 @@ namespace HandBrakeWPF.ViewModels
/// The Meta Data View Model
/// </param>
/// <param name="notifyIconService">Wrapper around the WinForms NotifyIcon for this app. </param>
- public MainViewModel(IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService,
+ public MainViewModel(IUserSettingService userSettingService, IScan scanService, IPresetService presetService,
IErrorService errorService, IUpdateService updateService,
IPrePostActionService whenDoneService, IWindowManager windowManager, IPictureSettingsViewModel pictureSettingsViewModel, IVideoViewModel videoViewModel, ISummaryViewModel summaryViewModel,
IFiltersViewModel filtersViewModel, IAudioViewModel audioViewModel, ISubtitlesViewModel subtitlesViewModel,
@@ -173,7 +168,6 @@ namespace HandBrakeWPF.ViewModels
IQueueViewModel queueViewModel, IMetaDataViewModel metaDataViewModel, INotifyIconService notifyIconService)
{
this.scanService = scanService;
- this.encodeService = encodeService;
this.presetService = presetService;
this.errorService = errorService;
this.updateService = updateService;
@@ -208,6 +202,7 @@ namespace HandBrakeWPF.ViewModels
this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
this.queueProcessor.QueueCompleted += this.QueueCompleted;
this.queueProcessor.QueueChanged += this.QueueChanged;
+ this.queueProcessor.QueuePaused += this.QueueProcessor_QueuePaused;
this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
this.userSettingService.SettingChanged += this.UserSettingServiceSettingChanged;
@@ -1262,16 +1257,17 @@ namespace HandBrakeWPF.ViewModels
public void Shutdown()
{
// Shutdown Service
- this.encodeService.Stop();
+ this.queueProcessor.Stop();
this.presetService.SaveCategoryStates();
// Unsubscribe from Events.
this.scanService.ScanStarted -= this.ScanStared;
this.scanService.ScanCompleted -= this.ScanCompleted;
this.scanService.ScanStatusChanged -= this.ScanStatusChanged;
-
+ this.queueProcessor.QueuePaused -= this.QueueProcessor_QueuePaused;
this.queueProcessor.QueueCompleted -= this.QueueCompleted;
this.queueProcessor.QueueChanged -= this.QueueChanged;
+
this.queueProcessor.JobProcessingStarted -= this.QueueProcessorJobProcessingStarted;
this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeStatusChanged;
this.userSettingService.SettingChanged -= this.UserSettingServiceSettingChanged;
@@ -1592,9 +1588,9 @@ namespace HandBrakeWPF.ViewModels
}
// Check if we already have jobs, and if we do, just start the queue.
- if (this.queueProcessor.Count != 0 || this.encodeService.IsPasued)
+ if (this.queueProcessor.Count != 0 || this.queueProcessor.EncodeService.IsPasued)
{
- if (this.encodeService.IsPasued)
+ if (this.queueProcessor.EncodeService.IsPasued)
{
this.IsEncoding = true;
}
@@ -1665,8 +1661,7 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public void PauseEncode()
{
- this.queueProcessor.Pause();
- this.encodeService.Pause();
+ this.queueProcessor.PauseEncode();
this.IsEncoding = false;
}
@@ -1675,8 +1670,7 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public void StopEncode()
{
- this.queueProcessor.Pause();
- this.encodeService.Stop();
+ this.queueProcessor.Stop();
}
/// <summary>
@@ -2474,6 +2468,17 @@ namespace HandBrakeWPF.ViewModels
});
}
+ private void QueueProcessor_QueuePaused(object sender, EventArgs e)
+ {
+ Execute.OnUIThread(
+ () =>
+ {
+ this.ProgramStatusLabel = Resources.Main_QueuePaused;
+ this.NotifyOfPropertyChange(() => this.QueueLabel);
+ this.NotifyOfPropertyChange(() => this.StartLabel);
+ });
+ }
+
/// <summary>
/// Allows the main window to respond to setting changes.
/// </summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs
index 35c8d6a86..b646bf552 100644
--- a/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs
@@ -193,7 +193,7 @@ namespace HandBrakeWPF.ViewModels
if (processor != null && processor.EncodeService.IsEncoding)
{
MessageBoxResult result =
- errorService.ShowMessageBox(
+ this.errorService.ShowMessageBox(
Resources.ShellViewModel_CanClose,
Resources.Warning,
MessageBoxButton.YesNo,
@@ -201,8 +201,7 @@ namespace HandBrakeWPF.ViewModels
if (result == MessageBoxResult.Yes)
{
- processor.Pause();
- processor.EncodeService.Stop();
+ processor.Stop();
if (this.MainViewModel != null)
{
this.MainViewModel.Shutdown();