diff options
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 15 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs | 22 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs | 30 |
3 files changed, 64 insertions, 3 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index bc6caa38a..20a779e43 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1668,6 +1668,21 @@ namespace HandBrakeWPF.ViewModels this.Destination = saveFileDialog.FileName;
+ // Disk Space Check
+ string drive = Path.GetPathRoot(this.Destination);
+ if (drive != null)
+ {
+ DriveInfo c = new DriveInfo(drive);
+ if (c.AvailableFreeSpace < this.userSettingService.GetUserSetting<long>(UserSettingConstants.PauseOnLowDiskspaceLevel))
+ {
+ this.errorService.ShowMessageBox(
+ Resources.MainViewModel_LowDiskSpaceWarning,
+ Resources.MainViewModel_LowDiskSpace,
+ MessageBoxButton.OK,
+ MessageBoxImage.Warning);
+ }
+ }
+
// Set the Extension Dropdown. This will also set Mp4/m4v correctly.
if (!string.IsNullOrEmpty(saveFileDialog.FileName))
{
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index 3e37a8a85..3176070d0 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -88,6 +88,7 @@ namespace HandBrakeWPF.ViewModels private bool disableQuickSyncDecoding;
private bool isClScaling;
private bool showQueueInline;
+ private bool pauseOnLowDiskspace;
#endregion
@@ -587,6 +588,23 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
+ /// Gets or sets a value indicating whether HandBrake should pause on low disk space.
+ /// </summary>
+ public bool PauseOnLowDiskspace
+ {
+ get
+ {
+ return this.pauseOnLowDiskspace;
+ }
+
+ set
+ {
+ this.pauseOnLowDiskspace = value;
+ this.NotifyOfPropertyChange(() => this.PauseOnLowDiskspace);
+ }
+ }
+
+ /// <summary>
/// Gets or sets PriorityLevelOptions.
/// </summary>
public BindingList<string> PriorityLevelOptions
@@ -1222,7 +1240,8 @@ namespace HandBrakeWPF.ViewModels this.SelectedPriority = userSettingService.GetUserSetting<string>(UserSettingConstants.ProcessPriority);
this.PreventSleep = userSettingService.GetUserSetting<bool>(UserSettingConstants.PreventSleep);
-
+ this.PauseOnLowDiskspace = userSettingService.GetUserSetting<bool>(UserSettingConstants.PauseOnLowDiskspace);
+
// Log Verbosity Level
this.logVerbosityOptions.Clear();
this.logVerbosityOptions.Add(0);
@@ -1312,6 +1331,7 @@ namespace HandBrakeWPF.ViewModels /* System and Logging */
userSettingService.SetUserSetting(UserSettingConstants.ProcessPriority, this.SelectedPriority);
userSettingService.SetUserSetting(UserSettingConstants.PreventSleep, this.PreventSleep);
+ userSettingService.SetUserSetting(UserSettingConstants.PauseOnLowDiskspace, this.PauseOnLowDiskspace);
userSettingService.SetUserSetting(UserSettingConstants.Verbosity, this.SelectedVerbosity);
userSettingService.SetUserSetting(UserSettingConstants.SaveLogWithVideo, this.CopyLogToEncodeDirectory);
userSettingService.SetUserSetting(UserSettingConstants.SaveLogToCopyDirectory, this.CopyLogToSepcficedLocation);
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs index 8167c1953..e3dccd32c 100644 --- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs @@ -396,8 +396,9 @@ namespace HandBrakeWPF.ViewModels this.queueProcessor.QueueCompleted += this.queueProcessor_QueueCompleted;
this.queueProcessor.QueueChanged += this.QueueManager_QueueChanged;
this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeService_EncodeStatusChanged;
- this.queueProcessor.EncodeService.EncodeCompleted += EncodeService_EncodeCompleted;
+ this.queueProcessor.EncodeService.EncodeCompleted += this.EncodeService_EncodeCompleted;
this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
+ this.queueProcessor.LowDiskspaceDetected += this.QueueProcessor_LowDiskspaceDetected;
this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);
this.JobStatus = Resources.QueueViewModel_QueueReady;
@@ -416,8 +417,10 @@ namespace HandBrakeWPF.ViewModels this.queueProcessor.QueueCompleted -= this.queueProcessor_QueueCompleted;
this.queueProcessor.QueueChanged -= this.QueueManager_QueueChanged;
this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeService_EncodeStatusChanged;
- this.queueProcessor.EncodeService.EncodeCompleted -= EncodeService_EncodeCompleted;
+ this.queueProcessor.EncodeService.EncodeCompleted -= this.EncodeService_EncodeCompleted;
this.queueProcessor.JobProcessingStarted -= this.QueueProcessorJobProcessingStarted;
+ this.queueProcessor.LowDiskspaceDetected -= this.QueueProcessor_LowDiskspaceDetected;
+
base.OnDeactivate(close);
}
@@ -449,6 +452,29 @@ 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.IsEncoding = false;
+
+ this.errorService.ShowMessageBox(
+ Resources.MainViewModel_LowDiskSpaceWarning,
+ Resources.MainViewModel_LowDiskSpace,
+ MessageBoxButton.OK,
+ MessageBoxImage.Warning);
+ });
+ }
+
+ /// <summary>
/// Handle the Queue Changed Event.
/// </summary>
/// <param name="sender">
|