}\r
}\r
\r
+ /// <summary>\r
+ /// Looks up a localized string similar to Queue Paused.\r
+ /// </summary>\r
+ public static string Main_QueuePaused {\r
+ get {\r
+ return ResourceManager.GetString("Main_QueuePaused", resourceCulture);\r
+ }\r
+ }\r
+ \r
/// <summary>\r
/// Looks up a localized string similar to Scan Cancelled..\r
/// </summary>\r
}\r
}\r
\r
+ /// <summary>\r
+ /// 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..\r
+ /// </summary>\r
+ public static string PauseOnLowDiskspace {\r
+ get {\r
+ return ResourceManager.GetString("PauseOnLowDiskspace", resourceCulture);\r
+ }\r
+ }\r
+ \r
/// <summary>\r
/// Looks up a localized string similar to Output: {0}.\r
/// </summary>\r
}\r
}\r
\r
+ /// <summary>\r
+ /// Looks up a localized string similar to Queue Paused.\r
+ /// </summary>\r
+ public static string QueueViewModel_QueuePaused {\r
+ get {\r
+ return ResourceManager.GetString("QueueViewModel_QueuePaused", resourceCulture);\r
+ }\r
+ }\r
+ \r
/// <summary>\r
/// 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..\r
/// </summary>\r
<value>{1}%, Pass {2} of {3}\r
Remaining Time: {4}</value>\r
</data>\r
+ <data name="PauseOnLowDiskspace" xml:space="preserve">\r
+ <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>\r
+ </data>\r
+ <data name="Main_QueuePaused" xml:space="preserve">\r
+ <value>Queue Paused</value>\r
+ </data>\r
+ <data name="QueueViewModel_QueuePaused" xml:space="preserve">\r
+ <value>Queue Paused</value>\r
+ </data>\r
</root>
\ No newline at end of file
\r
using HandBrakeWPF.Services.Queue.Model;\r
\r
- using IEncode = HandBrakeWPF.Services.Encode.Interfaces.IEncode;\r
+ using IEncode = Encode.Interfaces.IEncode;\r
\r
/// <summary>\r
/// The Queue Processor\r
/// </summary>\r
event EventHandler QueuePaused;\r
\r
- /// <summary>\r
- /// Low Diskspace has been detected.\r
- /// Checked before each job starts.\r
- /// </summary>\r
- event EventHandler LowDiskspaceDetected;\r
-\r
#endregion\r
\r
#region Properties\r
using System.Xml.Serialization;\r
\r
using HandBrake.ApplicationServices.Model;\r
+ using HandBrake.ApplicationServices.Services.Logging;\r
+ using HandBrake.ApplicationServices.Services.Logging.Model;\r
using HandBrake.ApplicationServices.Utilities;\r
\r
using HandBrakeWPF.Factories;\r
+ using HandBrakeWPF.Properties;\r
using HandBrakeWPF.Services.Encode.Factories;\r
using HandBrakeWPF.Services.Encode.Model;\r
using HandBrakeWPF.Services.Interfaces;\r
/// </summary>\r
public event EventHandler QueuePaused;\r
\r
- /// <summary>\r
- /// The low diskspace detected.\r
- /// </summary>\r
- public event EventHandler LowDiskspaceDetected;\r
-\r
#endregion\r
\r
#region Properties\r
/// </summary>\r
public void Pause()\r
{\r
- this.InvokeQueuePaused(EventArgs.Empty);\r
this.IsProcessing = false;\r
+ this.InvokeQueuePaused(EventArgs.Empty); \r
}\r
\r
/// <summary>\r
this.EncodeService.EncodeCompleted -= this.EncodeServiceEncodeCompleted;\r
this.EncodeService.EncodeCompleted += this.EncodeServiceEncodeCompleted;\r
\r
- if (this.EncodeService.IsEncoding)\r
+ if (this.EncodeService.IsPasued)\r
{\r
this.EncodeService.Resume();\r
+ this.IsProcessing = true;\r
}\r
\r
if (!this.EncodeService.IsEncoding)\r
{\r
this.ProcessNextJob();\r
}\r
-\r
- this.IsProcessing = true;\r
}\r
\r
#endregion\r
this.IsProcessing = false;\r
}\r
\r
- /// <summary>\r
- /// The on low diskspace detected.\r
- /// </summary>\r
- protected virtual void OnLowDiskspaceDetected()\r
- {\r
- this.LowDiskspaceDetected?.Invoke(this, EventArgs.Empty);\r
- }\r
-\r
/// <summary>\r
/// After an encode is complete, move onto the next job.\r
/// </summary>\r
QueueTask job = this.GetNextJobForProcessing();\r
if (job != null)\r
{\r
- if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PauseOnLowDiskspace))\r
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PauseOnLowDiskspace) && !DriveUtilities.HasMinimumDiskSpace(job.Task.Destination, this.userSettingService.GetUserSetting<long>(UserSettingConstants.PauseOnLowDiskspaceLevel)))\r
{\r
- string drive = Path.GetPathRoot(job.Task.Destination);\r
- if (!string.IsNullOrEmpty(drive) && !drive.StartsWith("\\"))\r
- {\r
- DriveInfo c = new DriveInfo(drive);\r
- if (c.AvailableFreeSpace < this.userSettingService.GetUserSetting<long>(UserSettingConstants.PauseOnLowDiskspaceLevel))\r
- {\r
- job.Status = QueueItemStatus.Waiting;\r
- this.InvokeQueueChanged(EventArgs.Empty);\r
- this.OnLowDiskspaceDetected();\r
- return; // Don't start the next job.\r
- }\r
- }\r
+ LogService.GetLogger().LogMessage(Resources.PauseOnLowDiskspace, LogMessageType.ScanOrEncode, LogLevel.Info);\r
+ job.Status = QueueItemStatus.Waiting;\r
+ this.Pause();\r
+ return; // Don't start the next job.\r
}\r
\r
+ this.IsProcessing = true;\r
this.InvokeJobProcessingStarted(new QueueProgressEventArgs(job));\r
this.EncodeService.Start(job.Task, job.Configuration);\r
}\r
\r
return drives;\r
}\r
+\r
+ public static bool HasMinimumDiskSpace(string destination, long minimumInBytes)\r
+ {\r
+ string drive = Path.GetPathRoot(destination);\r
+ if (!string.IsNullOrEmpty(drive) && !drive.StartsWith("\\"))\r
+ {\r
+ DriveInfo c = new DriveInfo(drive);\r
+ if (c.AvailableFreeSpace < minimumInBytes)\r
+ {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ return true;\r
+ }\r
}\r
}\r
this.scanService.ScanCompleted += this.ScanCompleted;\r
this.scanService.ScanStatusChanged += this.ScanStatusChanged;\r
this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;\r
+ this.queueProcessor.QueuePaused += this.QueueProcessor_QueuePaused;\r
this.queueProcessor.QueueCompleted += this.QueueCompleted;\r
this.queueProcessor.QueueChanged += this.QueueChanged;\r
this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;\r
this.queueProcessor.QueueCompleted -= this.QueueCompleted;\r
this.queueProcessor.QueueChanged -= this.QueueChanged;\r
this.queueProcessor.JobProcessingStarted -= this.QueueProcessorJobProcessingStarted;\r
+ this.queueProcessor.QueuePaused -= this.QueueProcessor_QueuePaused;\r
this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeStatusChanged;\r
this.userSettingService.SettingChanged -= this.UserSettingServiceSettingChanged;\r
}\r
}\r
\r
this.ProgramStatusLabel = Resources.Main_QueueFinished + errorDesc;\r
+\r
+ if (this.windowsSeven.IsWindowsSeven)\r
+ {\r
+ this.windowsSeven.SetTaskBarProgressToNoProgress();\r
+ }\r
+ });\r
+ }\r
+\r
+ private void QueueProcessor_QueuePaused(object sender, EventArgs e)\r
+ {\r
+ Execute.OnUIThread(\r
+ () =>\r
+ {\r
+ this.ProgramStatusLabel = Resources.Main_QueuePaused;\r
this.IsEncoding = false;\r
\r
if (this.windowsSeven.IsWindowsSeven)\r
this.queueProcessor.QueueCompleted += this.queueProcessor_QueueCompleted;\r
this.queueProcessor.QueueChanged += this.QueueManager_QueueChanged;\r
this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;\r
+ this.queueProcessor.QueuePaused += this.QueueProcessor_QueuePaused;\r
}\r
\r
public void Deactivate()\r
this.queueProcessor.QueueCompleted -= this.queueProcessor_QueueCompleted;\r
this.queueProcessor.QueueChanged -= this.QueueManager_QueueChanged;\r
this.queueProcessor.JobProcessingStarted -= this.QueueProcessorJobProcessingStarted;\r
+ this.queueProcessor.QueuePaused -= this.QueueProcessor_QueuePaused;\r
}\r
\r
/// <summary>\r
this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeService_EncodeStatusChanged;\r
this.queueProcessor.EncodeService.EncodeCompleted += this.EncodeService_EncodeCompleted;\r
this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;\r
- this.queueProcessor.LowDiskspaceDetected += this.QueueProcessor_LowDiskspaceDetected;\r
+ this.queueProcessor.QueuePaused += this.QueueProcessor_QueuePaused;\r
\r
this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);\r
this.JobStatus = Resources.QueueViewModel_QueueReady;\r
this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeService_EncodeStatusChanged;\r
this.queueProcessor.EncodeService.EncodeCompleted -= this.EncodeService_EncodeCompleted;\r
this.queueProcessor.JobProcessingStarted -= this.QueueProcessorJobProcessingStarted;\r
- this.queueProcessor.LowDiskspaceDetected -= this.QueueProcessor_LowDiskspaceDetected;\r
+ this.queueProcessor.QueuePaused -= this.QueueProcessor_QueuePaused;\r
\r
base.OnDeactivate(close);\r
}\r
});\r
}\r
\r
- /// <summary>\r
- /// Detect Low Disk Space before starting new queue tasks.\r
- /// </summary>\r
- /// <param name="sender">Event invoker. </param>\r
- /// <param name="e">Event Args.</param>\r
- private void QueueProcessor_LowDiskspaceDetected(object sender, EventArgs e)\r
- {\r
- Execute.OnUIThreadAsync(\r
- () =>\r
- {\r
- this.queueProcessor.Pause();\r
- this.JobStatus = Resources.QueueViewModel_QueuePending;\r
- this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);\r
- this.IsQueueRunning = false;\r
-\r
- this.errorService.ShowMessageBox(\r
- Resources.MainViewModel_LowDiskSpaceWarning,\r
- Resources.MainViewModel_LowDiskSpace,\r
- MessageBoxButton.OK,\r
- MessageBoxImage.Warning);\r
- });\r
- }\r
-\r
/// <summary>\r
/// Handle the Queue Changed Event.\r
/// </summary>\r
this.IsQueueRunning = true; \r
}\r
\r
+ private void QueueProcessor_QueuePaused(object sender, EventArgs e)\r
+ {\r
+ this.JobStatus = Resources.QueueViewModel_QueuePaused;\r
+ this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);\r
+ this.IsQueueRunning = false;\r
+ }\r
+\r
#endregion\r
}\r
}
\ No newline at end of file