]> granicus.if.org Git - handbrake/commitdiff
WinGui: Improve the error message when importing a preset fails.
authorsr55 <sr55.hb@outlook.com>
Sat, 15 Nov 2014 17:57:45 +0000 (17:57 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 15 Nov 2014 17:57:45 +0000 (17:57 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6521 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
win/CS/HandBrakeWPF/Properties/Resources.resx
win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
win/CS/HandBrakeWPF/Views/ErrorView.xaml

index 3759f9eaec39bbba0cf4169ba85980055b60e554..b452cf9f9c4bfd046bff62f2ae1a9b4180ec1b22 100644 (file)
@@ -499,6 +499,25 @@ namespace HandBrakeWPF.Properties {
             }\r
         }\r
         \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Unable to import the selected preset..\r
+        /// </summary>\r
+        public static string Main_PresetImportFailed {\r
+            get {\r
+                return ResourceManager.GetString("Main_PresetImportFailed", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The preset may be corrupted or from an older version of HandBrake which is not supported. \r
+        ///Presets from older versions must be re-created in the current version..\r
+        /// </summary>\r
+        public static string Main_PresetImportFailedSolution {\r
+            get {\r
+                return ResourceManager.GetString("Main_PresetImportFailedSolution", resourceCulture);\r
+            }\r
+        }\r
+        \r
         /// <summary>\r
         ///   Looks up a localized string similar to This preset appears to already exist. Would you like to overwrite it?.\r
         /// </summary>\r
index 8e4c82d29b258a258181518f48421f79111a45c7..c74324d6abd8c99b5b9ae62f4c4692207a0450ae 100644 (file)
@@ -536,4 +536,11 @@ Not both at the same time!</value>
   <data name="Main_UnableToLoadHelpSolution" xml:space="preserve">\r
     <value>You can still access the help pages by visiting the website directly at: https://handbrake.fr</value>\r
   </data>\r
+  <data name="Main_PresetImportFailed" xml:space="preserve">\r
+    <value>Unable to import the selected preset.</value>\r
+  </data>\r
+  <data name="Main_PresetImportFailedSolution" xml:space="preserve">\r
+    <value>The preset may be corrupted or from an older version of HandBrake which is not supported. \r
+Presets from older versions must be re-created in the current version.</value>\r
+  </data>\r
 </root>
\ No newline at end of file
index cf57289d2c84fba2a7f9832572a3a74561025b6b..3665c7acf6f306210ece872b09c1425ab8c442a8 100644 (file)
@@ -1685,27 +1685,37 @@ namespace HandBrakeWPF.ViewModels
                     }\r
                 }\r
 \r
-                Preset preset = PlistPresetFactory.CreatePreset(plist);\r
+                Preset preset = null;\r
+                try\r
+                {\r
+                    preset = PlistPresetFactory.CreatePreset(plist);\r
+                }\r
+                catch (Exception exc)\r
+                {\r
+                    this.errorService.ShowError(Resources.Main_PresetImportFailed, Resources.Main_PresetImportFailedSolution, exc);\r
+                }\r
 \r
-                if (this.presetService.CheckIfPresetExists(preset.Name))\r
+                if (preset != null)\r
                 {\r
-                    if (!presetService.CanUpdatePreset(preset.Name))\r
+                    if (this.presetService.CheckIfPresetExists(preset.Name))\r
                     {\r
-                        MessageBox.Show(Resources.Main_PresetErrorBuiltInName, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
-                        return;\r
-                    }\r
+                        if (!presetService.CanUpdatePreset(preset.Name))\r
+                        {\r
+                            MessageBox.Show(Resources.Main_PresetErrorBuiltInName, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
+                            return;\r
+                        }\r
 \r
-                    MessageBoxResult result =\r
-                        MessageBox.Show(Resources.Main_PresetOverwriteWarning, Resources.Overwrite, MessageBoxButton.YesNo, MessageBoxImage.Warning);\r
-                    if (result == MessageBoxResult.Yes)\r
+                        MessageBoxResult result = MessageBox.Show(Resources.Main_PresetOverwriteWarning, Resources.Overwrite, MessageBoxButton.YesNo, MessageBoxImage.Warning);\r
+                        if (result == MessageBoxResult.Yes)\r
+                        {\r
+                            presetService.Update(preset);\r
+                        }\r
+                    }\r
+                    else\r
                     {\r
-                        presetService.Update(preset);\r
+                        presetService.Add(preset);\r
                     }\r
                 }\r
-                else\r
-                {\r
-                    presetService.Add(preset);\r
-                }\r
 \r
                 this.NotifyOfPropertyChange(() => this.Presets);\r
             }\r
index 95b6e85cb103f01657085f67d8bd6424e21a8296..54cb7a2e6f46d4a0f95f660148fb37674aec2291 100644 (file)
         Style="{StaticResource windowStyle}"\r
         FontSize="11"\r
         TextOptions.TextFormattingMode="Display"\r
-        WindowStartupLocation="CenterScreen">\r
+        WindowStartupLocation="CenterOwner">\r
     <Grid>\r
         <Grid.RowDefinitions>\r
-            <RowDefinition Height="70" />\r
+            <RowDefinition Height="Auto" />\r
             <RowDefinition Height="*" />\r
             <RowDefinition Height="Auto" />\r
         </Grid.RowDefinitions>\r
@@ -35,9 +35,9 @@
 \r
             <Image Width="64"\r
                    Height="64"\r
-                   Margin="10,0,0,0"\r
+                   Margin="10,4,0,4"\r
                    Source="Images/ErrorX.png" />\r
-            <Grid Height="64" Margin="10,0,0,0">\r
+            <Grid Margin="10,0,0,0">\r
                 <Grid.RowDefinitions>\r
                     <RowDefinition Height="Auto" />\r
                     <RowDefinition Height="Auto" />\r
@@ -49,7 +49,7 @@
                            Text="{Binding ErrorMessage}" />\r
                 <TextBlock Grid.Row="1"\r
                            Margin="0,5,0,0"\r
-                           Text="{Binding Solution}" />\r
+                           Text="{Binding Solution}" TextWrapping="Wrap" />\r
 \r
                 <TextBlock Grid.Row="2"\r
                            Margin="0,0,0,2"\r