]> granicus.if.org Git - handbrake/commitdiff
Using ErrorService.ShowMessageBox instead of MessageBox.Show
authorSverrir Sigmundarson <sverrirs@gmail.com>
Thu, 26 Nov 2015 13:22:18 +0000 (14:22 +0100)
committerSverrir Sigmundarson <sverrirs@gmail.com>
Thu, 26 Nov 2015 13:22:18 +0000 (14:22 +0100)
win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs

index 1948a2443736eff3c891b66e1a059d4bff6149a5..037bacde05a7c904f17f9496ea5f2f86b0602abe 100644 (file)
@@ -16,6 +16,7 @@ namespace HandBrakeWPF.ViewModels
     using System.IO;\r
     using System.Text;\r
     using System.Linq;\r
+    using System.Windows;\r
     using System.Windows.Forms;\r
 \r
     using Caliburn.Micro;\r
@@ -31,17 +32,24 @@ namespace HandBrakeWPF.ViewModels
     using ChapterMarker = HandBrakeWPF.Services.Encode.Model.Models.ChapterMarker;\r
     using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;\r
     using GeneralApplicationException = HandBrakeWPF.Exceptions.GeneralApplicationException;\r
+    using MessageBox = System.Windows.Forms.MessageBox;\r
 \r
     /// <summary>\r
     /// The Chapters View Model\r
     /// </summary>\r
     public class ChaptersViewModel : ViewModelBase, IChaptersViewModel\r
     {\r
+        #region Constants and Fields\r
+\r
+        private readonly IErrorService errorService;\r
+\r
         /// <summary>\r
         /// The source chapters backing field\r
         /// </summary>\r
         private List<Chapter> sourceChaptersList;\r
 \r
+        #endregion\r
+\r
         #region Constructors and Destructors\r
 \r
         /// <summary>\r
@@ -53,9 +61,13 @@ namespace HandBrakeWPF.ViewModels
         /// <param name="userSettingService">\r
         /// The user Setting Service.\r
         /// </param>\r
-        public ChaptersViewModel(IWindowManager windowManager, IUserSettingService userSettingService)\r
+        /// <param name="errorService">\r
+        /// The Error Service \r
+        /// </param>\r
+        public ChaptersViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IErrorService errorService)\r
         {\r
             this.Task = new EncodeTask();\r
+            this.errorService = errorService;\r
         }\r
 \r
         #endregion\r
@@ -235,13 +247,12 @@ namespace HandBrakeWPF.ViewModels
             // If the number of chapters don't match, prompt for confirmation\r
             if (importedChapters.Count != this.Task.ChapterNames.Count)\r
             {\r
-                if (DialogResult.Yes !=\r
-                    MessageBox.Show(\r
+                if (MessageBoxResult.Yes !=\r
+                    this.errorService.ShowMessageBox(\r
                         string.Format(Resources.ChaptersViewModel_ValidateImportedChapters_ChapterCountMismatchMsg, this.Task.ChapterNames.Count, importedChapters.Count),\r
                         Resources.ChaptersViewModel_ValidateImportedChapters_ChapterCountMismatchWarning,\r
-                        MessageBoxButtons.YesNo,\r
-                        MessageBoxIcon.Question,\r
-                        MessageBoxDefaultButton.Button2))\r
+                        MessageBoxButton.YesNo,\r
+                        MessageBoxImage.Question))\r
                 {\r
                     return false;\r
                 }\r
@@ -255,13 +266,12 @@ namespace HandBrakeWPF.ViewModels
             var diffs = importedChapters.Zip(this.Task.ChapterNames, (import, source) => source.Duration - import.Value.Item2);\r
             if (diffs.Count(diff => Math.Abs(diff.TotalSeconds) > 15) > 2)\r
             {\r
-                if (DialogResult.Yes !=\r
-                    MessageBox.Show(\r
+                if (MessageBoxResult.Yes !=\r
+                    this.errorService.ShowMessageBox(\r
                         Resources.ChaptersViewModel_ValidateImportedChapters_ChapterDurationMismatchMsg,\r
                         Resources.ChaptersViewModel_ValidateImportedChapters_ChapterDurationMismatchWarning,\r
-                        MessageBoxButtons.YesNo,\r
-                        MessageBoxIcon.Question,\r
-                        MessageBoxDefaultButton.Button2))\r
+                        MessageBoxButton.YesNo,\r
+                        MessageBoxImage.Question))\r
                 {\r
                     return false;\r
                 }\r