diff options
author | sr55 <[email protected]> | 2014-03-23 12:50:33 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2014-03-23 12:50:33 +0000 |
commit | 844c185f87eae47a25ce86e2977d60bc9c57476d (patch) | |
tree | 6950e538c9339f971b4b5649ccaedb042c7ae227 /win/CS/HandBrakeWPF/ViewModels | |
parent | 39c74335105caafaaf7468958303671d623495e0 (diff) |
WinGui: Restore rolled back tabbing fix + added a check for illegal characters to the destination text box. Add to Queue will now prevent items from begin added with illegal characters also.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6129 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs | 5 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 40 |
2 files changed, 36 insertions, 9 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs index 0d176b7b7..e08d2d9ff 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs @@ -39,7 +39,10 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// <summary>
/// Add the current task to the queue.
/// </summary>
- void AddToQueue();
+ /// <returns>
+ /// True if added, false if error
+ /// </returns>
+ bool AddToQueue();
/// <summary>
/// File Scan
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 08f009bd4..3a3efc972 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -643,7 +643,17 @@ namespace HandBrakeWPF.ViewModels if (!string.IsNullOrEmpty(this.CurrentTask.Destination))
{
- switch (Path.GetExtension(this.CurrentTask.Destination))
+ string ext = string.Empty;
+ try
+ {
+ ext = Path.GetExtension(this.CurrentTask.Destination);
+ }
+ catch (ArgumentException)
+ {
+ this.errorService.ShowMessageBox(Resources.Main_InvalidDestination, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+
+ switch (ext)
{
case ".mkv":
this.SelectedOutputFormat = OutputFormat.Mkv;
@@ -1151,18 +1161,29 @@ namespace HandBrakeWPF.ViewModels /// <summary>
/// Add the current task to the queue.
/// </summary>
- public void AddToQueue()
+ /// <returns>
+ /// True if added, false if error.
+ /// </returns>
+ public bool AddToQueue()
{
if (this.ScannedSource == null || string.IsNullOrEmpty(this.ScannedSource.ScanPath) || this.ScannedSource.Titles.Count == 0)
{
this.errorService.ShowMessageBox(Resources.Main_ScanSourceFirst, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
- return;
+ return false;
}
if (string.IsNullOrEmpty(this.CurrentTask.Destination))
{
this.errorService.ShowMessageBox(Resources.Main_SetDestination, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
- return;
+ return false;
+ }
+
+ // 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;
}
QueueTask task = new QueueTask(new EncodeTask(this.CurrentTask), HBConfigurationFactory.Create());
@@ -1180,6 +1201,8 @@ namespace HandBrakeWPF.ViewModels {
this.ProgramStatusLabel = string.Format(Resources.Main_XEncodesPending, this.queueProcessor.Count);
}
+
+ return true;
}
/// <summary>
@@ -1325,10 +1348,11 @@ namespace HandBrakeWPF.ViewModels }
// Create the Queue Task and Start Processing
- QueueTask task = new QueueTask(new EncodeTask(this.CurrentTask), HBConfigurationFactory.Create());
- this.queueProcessor.Add(task);
- this.queueProcessor.Start(UserSettingService.GetUserSetting<bool>(UserSettingConstants.ClearCompletedFromQueue));
- this.IsEncoding = true;
+ if (this.AddToQueue())
+ {
+ this.queueProcessor.Start(UserSettingService.GetUserSetting<bool>(UserSettingConstants.ClearCompletedFromQueue));
+ this.IsEncoding = true;
+ }
}
/// <summary>
|