diff options
author | sr55 <[email protected]> | 2017-05-27 19:46:55 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2017-05-27 19:47:08 +0100 |
commit | 05faa1f855472e8783905b7fa2a8ce1ad4267722 (patch) | |
tree | f7b786b7acd59a92a55c317cd2caf7b39557a481 /win/CS | |
parent | d9c418e08089da33d6580cdba32439866fb12924 (diff) |
WinGui: Add a log message whent he queue is paused due to low disk space. Improve handling of automated queue pausing. #748
Diffstat (limited to 'win/CS')
7 files changed, 91 insertions, 62 deletions
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index d0b3c079b..92d55b507 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -897,6 +897,15 @@ namespace HandBrakeWPF.Properties { }
/// <summary>
+ /// Looks up a localized string similar to Queue Paused.
+ /// </summary>
+ public static string Main_QueuePaused {
+ get {
+ return ResourceManager.GetString("Main_QueuePaused", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Scan Cancelled..
/// </summary>
public static string Main_ScanCancelled {
@@ -1260,6 +1269,15 @@ namespace HandBrakeWPF.Properties { }
/// <summary>
+ /// Looks up a localized string similar to Queue Paused. Warning, the drive you are encoding to is low on disk space. Please free up some space and press start to continue. You can also adjust the minimum space level in preferences..
+ /// </summary>
+ public static string PauseOnLowDiskspace {
+ get {
+ return ResourceManager.GetString("PauseOnLowDiskspace", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Output: {0}.
/// </summary>
public static string PictureSettings_OutputResolution {
@@ -1547,6 +1565,15 @@ namespace HandBrakeWPF.Properties { }
/// <summary>
+ /// Looks up a localized string similar to Queue Paused.
+ /// </summary>
+ public static string QueueViewModel_QueuePaused {
+ get {
+ return ResourceManager.GetString("QueueViewModel_QueuePaused", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to The Queue has been paused. The currently running job will run to completion and no further jobs will start..
/// </summary>
public static string QueueViewModel_QueuePauseNotice {
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index 1b263c8e9..6a67940ad 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -840,4 +840,13 @@ Your preset file will be archived and new one created. You will need to re-creat <value>{1}%, Pass {2} of {3}
Remaining Time: {4}</value>
</data>
+ <data name="PauseOnLowDiskspace" xml:space="preserve">
+ <value>Queue Paused. Warning, the drive you are encoding to is low on disk space. Please free up some space and press start to continue. You can also adjust the minimum space level in preferences.</value>
+ </data>
+ <data name="Main_QueuePaused" xml:space="preserve">
+ <value>Queue Paused</value>
+ </data>
+ <data name="QueueViewModel_QueuePaused" xml:space="preserve">
+ <value>Queue Paused</value>
+ </data>
</root>
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs b/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs index ffc9107bb..ead10cbf3 100644 --- a/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs +++ b/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs @@ -14,7 +14,7 @@ namespace HandBrakeWPF.Services.Queue.Interfaces using HandBrakeWPF.Services.Queue.Model;
- using IEncode = HandBrakeWPF.Services.Encode.Interfaces.IEncode;
+ using IEncode = Encode.Interfaces.IEncode;
/// <summary>
/// The Queue Processor
@@ -44,12 +44,6 @@ namespace HandBrakeWPF.Services.Queue.Interfaces /// </summary>
event EventHandler QueuePaused;
- /// <summary>
- /// Low Diskspace has been detected.
- /// Checked before each job starts.
- /// </summary>
- event EventHandler LowDiskspaceDetected;
-
#endregion
#region Properties
diff --git a/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs b/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs index f0425b0c0..2292d18a2 100644 --- a/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs +++ b/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs @@ -17,9 +17,12 @@ namespace HandBrakeWPF.Services.Queue using System.Xml.Serialization;
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Services.Logging;
+ using HandBrake.ApplicationServices.Services.Logging.Model;
using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Factories;
+ using HandBrakeWPF.Properties;
using HandBrakeWPF.Services.Encode.Factories;
using HandBrakeWPF.Services.Encode.Model;
using HandBrakeWPF.Services.Interfaces;
@@ -130,11 +133,6 @@ namespace HandBrakeWPF.Services.Queue /// </summary>
public event EventHandler QueuePaused;
- /// <summary>
- /// The low diskspace detected.
- /// </summary>
- public event EventHandler LowDiskspaceDetected;
-
#endregion
#region Properties
@@ -478,8 +476,8 @@ namespace HandBrakeWPF.Services.Queue /// </summary>
public void Pause()
{
- this.InvokeQueuePaused(EventArgs.Empty);
this.IsProcessing = false;
+ this.InvokeQueuePaused(EventArgs.Empty);
}
/// <summary>
@@ -501,17 +499,16 @@ namespace HandBrakeWPF.Services.Queue this.EncodeService.EncodeCompleted -= this.EncodeServiceEncodeCompleted;
this.EncodeService.EncodeCompleted += this.EncodeServiceEncodeCompleted;
- if (this.EncodeService.IsEncoding)
+ if (this.EncodeService.IsPasued)
{
this.EncodeService.Resume();
+ this.IsProcessing = true;
}
if (!this.EncodeService.IsEncoding)
{
this.ProcessNextJob();
}
-
- this.IsProcessing = true;
}
#endregion
@@ -536,14 +533,6 @@ namespace HandBrakeWPF.Services.Queue }
/// <summary>
- /// The on low diskspace detected.
- /// </summary>
- protected virtual void OnLowDiskspaceDetected()
- {
- this.LowDiskspaceDetected?.Invoke(this, EventArgs.Empty);
- }
-
- /// <summary>
/// After an encode is complete, move onto the next job.
/// </summary>
/// <param name="sender">
@@ -644,22 +633,15 @@ namespace HandBrakeWPF.Services.Queue QueueTask job = this.GetNextJobForProcessing();
if (job != null)
{
- if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PauseOnLowDiskspace))
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PauseOnLowDiskspace) && !DriveUtilities.HasMinimumDiskSpace(job.Task.Destination, this.userSettingService.GetUserSetting<long>(UserSettingConstants.PauseOnLowDiskspaceLevel)))
{
- string drive = Path.GetPathRoot(job.Task.Destination);
- if (!string.IsNullOrEmpty(drive) && !drive.StartsWith("\\"))
- {
- DriveInfo c = new DriveInfo(drive);
- if (c.AvailableFreeSpace < this.userSettingService.GetUserSetting<long>(UserSettingConstants.PauseOnLowDiskspaceLevel))
- {
- job.Status = QueueItemStatus.Waiting;
- this.InvokeQueueChanged(EventArgs.Empty);
- this.OnLowDiskspaceDetected();
- return; // Don't start the next job.
- }
- }
+ LogService.GetLogger().LogMessage(Resources.PauseOnLowDiskspace, LogMessageType.ScanOrEncode, LogLevel.Info);
+ job.Status = QueueItemStatus.Waiting;
+ this.Pause();
+ return; // Don't start the next job.
}
+ this.IsProcessing = true;
this.InvokeJobProcessingStarted(new QueueProgressEventArgs(job));
this.EncodeService.Start(job.Task, job.Configuration);
}
diff --git a/win/CS/HandBrakeWPF/Utilities/DriveUtilities.cs b/win/CS/HandBrakeWPF/Utilities/DriveUtilities.cs index d07056ef8..40bb2d5c0 100644 --- a/win/CS/HandBrakeWPF/Utilities/DriveUtilities.cs +++ b/win/CS/HandBrakeWPF/Utilities/DriveUtilities.cs @@ -49,5 +49,20 @@ namespace HandBrakeWPF.Utilities return drives;
}
+
+ public static bool HasMinimumDiskSpace(string destination, long minimumInBytes)
+ {
+ string drive = Path.GetPathRoot(destination);
+ if (!string.IsNullOrEmpty(drive) && !drive.StartsWith("\\"))
+ {
+ DriveInfo c = new DriveInfo(drive);
+ if (c.AvailableFreeSpace < minimumInBytes)
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index c8a59bbbc..5056f99a6 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -205,6 +205,7 @@ namespace HandBrakeWPF.ViewModels this.scanService.ScanCompleted += this.ScanCompleted;
this.scanService.ScanStatusChanged += this.ScanStatusChanged;
this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
+ this.queueProcessor.QueuePaused += this.QueueProcessor_QueuePaused;
this.queueProcessor.QueueCompleted += this.QueueCompleted;
this.queueProcessor.QueueChanged += this.QueueChanged;
this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
@@ -1318,6 +1319,7 @@ namespace HandBrakeWPF.ViewModels this.queueProcessor.QueueCompleted -= this.QueueCompleted;
this.queueProcessor.QueueChanged -= this.QueueChanged;
this.queueProcessor.JobProcessingStarted -= this.QueueProcessorJobProcessingStarted;
+ this.queueProcessor.QueuePaused -= this.QueueProcessor_QueuePaused;
this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeStatusChanged;
this.userSettingService.SettingChanged -= this.UserSettingServiceSettingChanged;
}
@@ -2528,6 +2530,20 @@ namespace HandBrakeWPF.ViewModels }
this.ProgramStatusLabel = Resources.Main_QueueFinished + errorDesc;
+
+ if (this.windowsSeven.IsWindowsSeven)
+ {
+ this.windowsSeven.SetTaskBarProgressToNoProgress();
+ }
+ });
+ }
+
+ private void QueueProcessor_QueuePaused(object sender, EventArgs e)
+ {
+ Execute.OnUIThread(
+ () =>
+ {
+ this.ProgramStatusLabel = Resources.Main_QueuePaused;
this.IsEncoding = false;
if (this.windowsSeven.IsWindowsSeven)
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs index 2267c1a44..0c984e032 100644 --- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs @@ -459,6 +459,7 @@ namespace HandBrakeWPF.ViewModels this.queueProcessor.QueueCompleted += this.queueProcessor_QueueCompleted;
this.queueProcessor.QueueChanged += this.QueueManager_QueueChanged;
this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
+ this.queueProcessor.QueuePaused += this.QueueProcessor_QueuePaused;
}
public void Deactivate()
@@ -466,6 +467,7 @@ namespace HandBrakeWPF.ViewModels this.queueProcessor.QueueCompleted -= this.queueProcessor_QueueCompleted;
this.queueProcessor.QueueChanged -= this.QueueManager_QueueChanged;
this.queueProcessor.JobProcessingStarted -= this.QueueProcessorJobProcessingStarted;
+ this.queueProcessor.QueuePaused -= this.QueueProcessor_QueuePaused;
}
/// <summary>
@@ -480,7 +482,7 @@ namespace HandBrakeWPF.ViewModels this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeService_EncodeStatusChanged;
this.queueProcessor.EncodeService.EncodeCompleted += this.EncodeService_EncodeCompleted;
this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
- this.queueProcessor.LowDiskspaceDetected += this.QueueProcessor_LowDiskspaceDetected;
+ this.queueProcessor.QueuePaused += this.QueueProcessor_QueuePaused;
this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);
this.JobStatus = Resources.QueueViewModel_QueueReady;
@@ -501,7 +503,7 @@ namespace HandBrakeWPF.ViewModels this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeService_EncodeStatusChanged;
this.queueProcessor.EncodeService.EncodeCompleted -= this.EncodeService_EncodeCompleted;
this.queueProcessor.JobProcessingStarted -= this.QueueProcessorJobProcessingStarted;
- this.queueProcessor.LowDiskspaceDetected -= this.QueueProcessor_LowDiskspaceDetected;
+ this.queueProcessor.QueuePaused -= this.QueueProcessor_QueuePaused;
base.OnDeactivate(close);
}
@@ -555,29 +557,6 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
- /// Detect Low Disk Space before starting new queue tasks.
- /// </summary>
- /// <param name="sender">Event invoker. </param>
- /// <param name="e">Event Args.</param>
- private void QueueProcessor_LowDiskspaceDetected(object sender, EventArgs e)
- {
- Execute.OnUIThreadAsync(
- () =>
- {
- this.queueProcessor.Pause();
- this.JobStatus = Resources.QueueViewModel_QueuePending;
- this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);
- this.IsQueueRunning = false;
-
- this.errorService.ShowMessageBox(
- Resources.MainViewModel_LowDiskSpaceWarning,
- Resources.MainViewModel_LowDiskSpace,
- MessageBoxButton.OK,
- MessageBoxImage.Warning);
- });
- }
-
- /// <summary>
/// Handle the Queue Changed Event.
/// </summary>
/// <param name="sender">
@@ -646,6 +625,13 @@ namespace HandBrakeWPF.ViewModels this.IsQueueRunning = true;
}
+ private void QueueProcessor_QueuePaused(object sender, EventArgs e)
+ {
+ this.JobStatus = Resources.QueueViewModel_QueuePaused;
+ this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);
+ this.IsQueueRunning = false;
+ }
+
#endregion
}
}
\ No newline at end of file |