From: sr55 Date: Sat, 15 Nov 2014 17:57:45 +0000 (+0000) Subject: WinGui: Improve the error message when importing a preset fails. X-Git-Tag: 0.10.0~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=38ec1ddd1774cd30c94e8894def48334db9c088e;p=handbrake WinGui: Improve the error message when importing a preset fails. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6521 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index 3759f9eae..b452cf9f9 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -499,6 +499,25 @@ namespace HandBrakeWPF.Properties { } } + /// + /// Looks up a localized string similar to Unable to import the selected preset.. + /// + public static string Main_PresetImportFailed { + get { + return ResourceManager.GetString("Main_PresetImportFailed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The preset may be corrupted or from an older version of HandBrake which is not supported. + ///Presets from older versions must be re-created in the current version.. + /// + public static string Main_PresetImportFailedSolution { + get { + return ResourceManager.GetString("Main_PresetImportFailedSolution", resourceCulture); + } + } + /// /// Looks up a localized string similar to This preset appears to already exist. Would you like to overwrite it?. /// diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index 8e4c82d29..c74324d6a 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -536,4 +536,11 @@ Not both at the same time! You can still access the help pages by visiting the website directly at: https://handbrake.fr + + Unable to import the selected preset. + + + The preset may be corrupted or from an older version of HandBrake which is not supported. +Presets from older versions must be re-created in the current version. + \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index cf57289d2..3665c7acf 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1685,27 +1685,37 @@ namespace HandBrakeWPF.ViewModels } } - Preset preset = PlistPresetFactory.CreatePreset(plist); + Preset preset = null; + try + { + preset = PlistPresetFactory.CreatePreset(plist); + } + catch (Exception exc) + { + this.errorService.ShowError(Resources.Main_PresetImportFailed, Resources.Main_PresetImportFailedSolution, exc); + } - if (this.presetService.CheckIfPresetExists(preset.Name)) + if (preset != null) { - if (!presetService.CanUpdatePreset(preset.Name)) + if (this.presetService.CheckIfPresetExists(preset.Name)) { - MessageBox.Show(Resources.Main_PresetErrorBuiltInName, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); - return; - } + if (!presetService.CanUpdatePreset(preset.Name)) + { + MessageBox.Show(Resources.Main_PresetErrorBuiltInName, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); + return; + } - MessageBoxResult result = - MessageBox.Show(Resources.Main_PresetOverwriteWarning, Resources.Overwrite, MessageBoxButton.YesNo, MessageBoxImage.Warning); - if (result == MessageBoxResult.Yes) + MessageBoxResult result = MessageBox.Show(Resources.Main_PresetOverwriteWarning, Resources.Overwrite, MessageBoxButton.YesNo, MessageBoxImage.Warning); + if (result == MessageBoxResult.Yes) + { + presetService.Update(preset); + } + } + else { - presetService.Update(preset); + presetService.Add(preset); } } - else - { - presetService.Add(preset); - } this.NotifyOfPropertyChange(() => this.Presets); } diff --git a/win/CS/HandBrakeWPF/Views/ErrorView.xaml b/win/CS/HandBrakeWPF/Views/ErrorView.xaml index 95b6e85cb..54cb7a2e6 100644 --- a/win/CS/HandBrakeWPF/Views/ErrorView.xaml +++ b/win/CS/HandBrakeWPF/Views/ErrorView.xaml @@ -10,10 +10,10 @@ Style="{StaticResource windowStyle}" FontSize="11" TextOptions.TextFormattingMode="Display" - WindowStartupLocation="CenterScreen"> + WindowStartupLocation="CenterOwner"> - + @@ -35,9 +35,9 @@ - + @@ -49,7 +49,7 @@ Text="{Binding ErrorMessage}" /> + Text="{Binding Solution}" TextWrapping="Wrap" />