diff options
Diffstat (limited to 'win')
-rw-r--r-- | win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 1 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Model/AddQueueError.cs | 29 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Properties/Resources.Designer.cs | 2 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Properties/Resources.resx | 2 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs | 3 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 60 |
6 files changed, 69 insertions, 28 deletions
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index de74348b3..2e4860bef 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -158,6 +158,7 @@ <Compile Include="Instance\HandBrakeInstanceManager.cs" />
<Compile Include="Instance\Model\ServerResponse.cs" />
<Compile Include="Instance\RemoteInstance.cs" />
+ <Compile Include="Model\AddQueueError.cs" />
<Compile Include="Model\Audio\AudioBehaviourTrack.cs" />
<Compile Include="Model\Audio\AudioTrackDefaultsMode.cs" />
<Compile Include="Model\Audio\AudioBehaviourModes.cs" />
diff --git a/win/CS/HandBrakeWPF/Model/AddQueueError.cs b/win/CS/HandBrakeWPF/Model/AddQueueError.cs new file mode 100644 index 000000000..f029ce4ad --- /dev/null +++ b/win/CS/HandBrakeWPF/Model/AddQueueError.cs @@ -0,0 +1,29 @@ +// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="AutoNameHelper.cs" company="HandBrake Project (http://handbrake.fr)"> +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// </copyright> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Model +{ + using System.Windows; + + public class AddQueueError + { + public string Message { get; } + + public string Header { get; } + + public MessageBoxButton Buttons { get; } + + public MessageBoxImage ErrorType { get; } + + public AddQueueError(string message, string header, MessageBoxButton buttons, MessageBoxImage errorType) + { + this.Message = message; + this.Header = header; + this.Buttons = buttons; + this.ErrorType = errorType; + } + } +}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index df97f4a66..8803d1757 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -1126,7 +1126,7 @@ namespace HandBrakeWPF.Properties { } /// <summary> - /// Looks up a localized string similar to Unable to add the last job to the queue. Do you wish to proceed trying to add the rest?. + /// Looks up a localized string similar to Do you wish to proceed trying to add the rest?. /// </summary> public static string Main_ContinueAddingToQueue { get { diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index baf8533d9..f5e31ea09 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -740,7 +740,7 @@ Time Remaining: {5}, Elapsed: {6:d\:hh\:mm\:ss}</value> <value>HandBrake requires Windows 7 or later to run. Version 0.9.9 (XP) and 0.10.5 (Vista) was the last version to support these versions.</value>
</data>
<data name="Main_ContinueAddingToQueue" xml:space="preserve">
- <value>Unable to add the last job to the queue. Do you wish to proceed trying to add the rest?</value>
+ <value>Do you wish to proceed trying to add the rest?</value>
</data>
<data name="Main_QueueOverwritePrompt" xml:space="preserve">
<value>The file '{0}' already exists!
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs index 3f0c6ae2e..7a6a7b4fa 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs @@ -11,6 +11,7 @@ namespace HandBrakeWPF.ViewModels.Interfaces {
using System.Windows;
+ using HandBrakeWPF.Model;
using HandBrakeWPF.Services.Queue.Model;
using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
@@ -49,7 +50,7 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// <returns>
/// True if added, false if error
/// </returns>
- bool AddToQueue();
+ AddQueueError AddToQueue();
void AddAllToQueue();
void AddSelectionToQueue();
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 857ce9c42..fbb241ea2 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1319,18 +1319,16 @@ namespace HandBrakeWPF.ViewModels /// <returns>
/// True if added, false if error.
/// </returns>
- public bool AddToQueue()
+ public AddQueueError AddToQueue()
{
if (this.ScannedSource == null || string.IsNullOrEmpty(this.ScannedSource.ScanPath) || this.ScannedSource.Titles.Count == 0)
{
- this.errorService.ShowMessageBox(Resources.Main_ScanSource, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
- return false;
+ return new AddQueueError(Resources.Main_ScanSource, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (string.IsNullOrEmpty(this.CurrentTask.Destination))
{
- this.errorService.ShowMessageBox(Resources.Main_SetDestination, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
- return false;
+ return new AddQueueError(Resources.Main_SetDestination, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (File.Exists(this.CurrentTask.Destination))
@@ -1338,44 +1336,38 @@ namespace HandBrakeWPF.ViewModels MessageBoxResult result = this.errorService.ShowMessageBox(string.Format(Resources.Main_QueueOverwritePrompt, Path.GetFileName(this.CurrentTask.Destination)), Resources.Question, MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.No)
{
- return false;
- }
+ return null; // Handled by the above action.
+ }
}
if (!DirectoryUtilities.IsWritable(Path.GetDirectoryName(this.CurrentTask.Destination), false, this.errorService))
{
- this.errorService.ShowMessageBox(Resources.Main_NoPermissionsOrMissingDirectory, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
- return false;
+ return new AddQueueError(Resources.Main_NoPermissionsOrMissingDirectory, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
}
-
if (!DriveUtilities.HasMinimumDiskSpace(
this.Destination,
this.userSettingService.GetUserSetting<long>(UserSettingConstants.PauseOnLowDiskspaceLevel)))
{
- this.errorService.ShowMessageBox(Resources.Main_LowDiskspace, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
- return false;
+ return new AddQueueError(Resources.Main_LowDiskspace, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
}
// Sanity check the filename
if (!string.IsNullOrEmpty(this.Destination) && FileHelper.FilePathHasInvalidChars(this.Destination))
{
- this.errorService.ShowMessageBox(Resources.Main_InvalidDestination, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
this.NotifyOfPropertyChange(() => this.Destination);
- return false;
+ return new AddQueueError(Resources.Main_InvalidDestination, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (this.Destination == this.ScannedSource.ScanPath)
{
- this.errorService.ShowMessageBox(Resources.Main_SourceDestinationMatchError, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
this.Destination = null;
- return false;
+ return new AddQueueError(Resources.Main_SourceDestinationMatchError, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (this.scannedSource != null && !string.IsNullOrEmpty(this.scannedSource.ScanPath) && this.Destination.ToLower() == this.scannedSource.ScanPath.ToLower())
{
- this.errorService.ShowMessageBox(Resources.Main_MatchingFileOverwriteWarning, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
- return false;
+ return new AddQueueError(Resources.Main_MatchingFileOverwriteWarning, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
}
QueueTask task = new QueueTask(new EncodeTask(this.CurrentTask), HBConfigurationFactory.Create(), this.ScannedSource.ScanPath, this.SelectedPreset);
@@ -1386,8 +1378,7 @@ namespace HandBrakeWPF.ViewModels }
else
{
- this.errorService.ShowMessageBox(Resources.Main_DuplicateDestinationOnQueue, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Warning);
- return false;
+ return new AddQueueError(Resources.Main_DuplicateDestinationOnQueue, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Warning);
}
if (!this.IsEncoding)
@@ -1395,7 +1386,7 @@ namespace HandBrakeWPF.ViewModels this.ProgramStatusLabel = string.Format(Resources.Main_XEncodesPending, this.queueProcessor.Count);
}
- return true;
+ return null;
}
/// <summary>
@@ -1436,9 +1427,10 @@ namespace HandBrakeWPF.ViewModels foreach (Title title in this.ScannedSource.Titles)
{
this.SelectedTitle = title;
- if (!this.AddToQueue())
+ var addError = this.AddToQueue();
+ if (addError != null)
{
- MessageBoxResult result = this.errorService.ShowMessageBox(Resources.Main_ContinueAddingToQueue, Resources.Question, MessageBoxButton.YesNo, MessageBoxImage.Question);
+ MessageBoxResult result = this.errorService.ShowMessageBox(addError.Message + Environment.NewLine + Environment.NewLine + Resources.Main_ContinueAddingToQueue, addError.Header, MessageBoxButton.YesNo, addError.ErrorType);
if (result == MessageBoxResult.No)
{
@@ -1473,7 +1465,16 @@ namespace HandBrakeWPF.ViewModels foreach (SelectionTitle title in tasks)
{
this.SelectedTitle = title.Title;
- this.AddToQueue();
+ var addError = this.AddToQueue();
+ if (addError != null)
+ {
+ MessageBoxResult result = this.errorService.ShowMessageBox(addError.Message + Environment.NewLine + Environment.NewLine + Resources.Main_ContinueAddingToQueue, addError.Header, MessageBoxButton.YesNo, addError.ErrorType);
+
+ if (result == MessageBoxResult.No)
+ {
+ break;
+ }
+ }
}
}, this.selectedPreset);
@@ -1564,11 +1565,20 @@ namespace HandBrakeWPF.ViewModels }
// Create the Queue Task and Start Processing
- if (this.AddToQueue())
+ var addError = this.AddToQueue();
+ if (addError == null)
{
this.IsEncoding = true;
this.queueProcessor.Start(this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ClearCompletedFromQueue));
}
+ else
+ {
+ this.errorService.ShowMessageBox(
+ addError.Message,
+ addError.Header,
+ addError.Buttons,
+ addError.ErrorType);
+ }
}
/// <summary>
|