From 332f03f3f68dca799a2e50ceb7e34578ac0bcd5f Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 20 May 2012 01:11:36 +0000 Subject: WinGui: Initial Implementation of Add All to Queue. Fix the Queue so that it processes everything correctly rather than just the last job added. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4689 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/CS/HandBrakeWPF/App.xaml.cs | 26 +++++++++++- win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs | 28 ++++++++++++- win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 35 ++++++++++++++-- win/CS/HandBrakeWPF/Views/MainView.xaml | 56 +++++++++++++++++++++---- win/CS/HandBrakeWPF/Views/OptionsView.xaml | 2 +- win/CS/HandBrakeWPF/Views/Styles/Styles.xaml | 2 + 6 files changed, 132 insertions(+), 17 deletions(-) (limited to 'win/CS/HandBrakeWPF') diff --git a/win/CS/HandBrakeWPF/App.xaml.cs b/win/CS/HandBrakeWPF/App.xaml.cs index 13efba30b..ff32ba5c9 100644 --- a/win/CS/HandBrakeWPF/App.xaml.cs +++ b/win/CS/HandBrakeWPF/App.xaml.cs @@ -59,7 +59,19 @@ namespace HandBrakeWPF private void Dispatcher_UnhandledException( object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { - this.ShowError(e.Exception); + if (e.Exception.GetType() == typeof(GeneralApplicationException)) + { + this.ShowError(e.Exception); + } + else if (e.Exception.InnerException.GetType() == typeof(GeneralApplicationException)) + { + this.ShowError(e.Exception.InnerException); + } + else + { + this.ShowError(e.Exception); + } + e.Handled = true; } @@ -83,9 +95,19 @@ namespace HandBrakeWPF GeneralApplicationException applicationException = exception as GeneralApplicationException; if (applicationException != null) { + string details = string.Format( + "{0}{1}{2}{3}{4}", + applicationException.Error, + Environment.NewLine, + applicationException.Solution, + Environment.NewLine, + applicationException.ActualException != null + ? applicationException.ActualException.ToString() + : "No additional exception information available."); + errorView.ErrorMessage = applicationException.Error; errorView.Solution = applicationException.Solution; - errorView.Details = applicationException.ActualException.ToString(); + errorView.Details = details; } } else diff --git a/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs b/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs index 3fb62e151..bf39d859a 100644 --- a/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs +++ b/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs @@ -52,7 +52,7 @@ namespace HandBrakeWPF.Helpers { // Get the Source Name and remove any invalid characters string sourceName = Path.GetInvalidFileNameChars().Aggregate(sourceOrLabelName, (current, character) => current.Replace(character.ToString(), string.Empty)); - + // Remove Underscores if (userSettingService.GetUserSetting(UserSettingConstants.AutoNameRemoveUnderscore)) sourceName = sourceName.Replace("_", " "); @@ -161,5 +161,31 @@ namespace HandBrakeWPF.Helpers return autoNamePath; } + + /// + /// Check if there is a valid autoname path. + /// + /// + /// True if there is a valid path + /// + public static bool IsAutonamingEnabled() + { + IUserSettingService userSettingService = IoC.Get(); + // If there is an auto name path, use it... + if (userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath).Trim().StartsWith("{source_path}")) + { + return true; + } + else if (userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath).Contains("{source_folder_name}")) + { + return true; + } + else + { + return + Directory.Exists( + userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath).Trim()); + } + } } } diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 6c5576442..80b56edea 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -24,6 +24,7 @@ namespace HandBrakeWPF.ViewModels using Caliburn.Micro; using HandBrake.ApplicationServices; + using HandBrake.ApplicationServices.Exceptions; using HandBrake.ApplicationServices.Model; using HandBrake.ApplicationServices.Model.Encoding; using HandBrake.ApplicationServices.Parsing; @@ -290,7 +291,7 @@ namespace HandBrakeWPF.ViewModels // File Menu Item - MenuItem titleSpecific = new MenuItem {Header = new TextBlock { Text = "Title Specific Scan", Margin = new Thickness(8, 0, 0, 0), VerticalAlignment = VerticalAlignment.Center }}; + MenuItem titleSpecific = new MenuItem { Header = new TextBlock { Text = "Title Specific Scan", Margin = new Thickness(8, 0, 0, 0), VerticalAlignment = VerticalAlignment.Center } }; MenuItem titleSpecificFolder = new MenuItem { @@ -599,7 +600,10 @@ namespace HandBrakeWPF.ViewModels this.SelectedPointToPoint = PointToPointMode.Chapters; this.SelectedAngle = 1; - this.CurrentTask.Destination = AutoNameHelper.AutoName(this.CurrentTask, this.SourceName); + if (this.UserSettingService.GetUserSetting(UserSettingConstants.AutoNaming)) + { + this.CurrentTask.Destination = AutoNameHelper.AutoName(this.CurrentTask, this.SourceName); + } this.NotifyOfPropertyChange(() => this.CurrentTask); this.Duration = selectedTitle.Duration.ToString(); @@ -813,7 +817,7 @@ namespace HandBrakeWPF.ViewModels QueueTask task = new QueueTask { - Task = this.CurrentTask, + Task = new EncodeTask(this.CurrentTask), Query = QueryGeneratorUtility.GenerateQuery(this.CurrentTask) }; this.queueProcessor.QueueManager.Add(task); @@ -824,6 +828,30 @@ namespace HandBrakeWPF.ViewModels } } + /// + /// Add all Items to the queue + /// + public void AddAllToQueue() + { + if (this.ScannedSource == null || this.ScannedSource.Titles == null || this.ScannedSource.Titles.Count == 0) + { + this.errorService.ShowMessageBox("You must first scan a source and setup your job before adding to the queue.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + if (!AutoNameHelper.IsAutonamingEnabled()) + { + this.errorService.ShowMessageBox("You must turn on automatic file naming in preferences before you can add to the queue.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + foreach (Title title in this.ScannedSource.Titles) + { + this.SelectedTitle = title; + this.AddToQueue(); + } + } + /// /// Folder Scan /// @@ -888,7 +916,6 @@ namespace HandBrakeWPF.ViewModels } } - /// /// Cancel a Scan /// diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index 6d8e57b98..425ff041b 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -3,9 +3,11 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Data="clr-namespace:System.Windows.Data;assembly=PresentationFramework" xmlns:Converters="clr-namespace:HandBrakeWPF.Converters" xmlns:Micro="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" - xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" Title="{Data:Binding Path=WindowTitle}" Width="1015" FontSize="11" Background="#FFF0F0F0" + xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" Title="{Data:Binding Path=WindowTitle}" Width="1015" + FontSize="11" Background="#FFF0F0F0" Micro:Message.Attach="[Event Loaded] = [Action Load]" UseLayoutRounding="True" SizeToContent="Height" + SnapsToDevicePixels="True" AllowDrop="True"> @@ -140,13 +142,49 @@