From f0a84ed897f3b8bca6a681b4d43c70d7e8ee012d Mon Sep 17 00:00:00 2001 From: Sverrir Sigmundarson Date: Thu, 26 Nov 2015 14:22:18 +0100 Subject: Using ErrorService.ShowMessageBox instead of MessageBox.Show --- .../HandBrakeWPF/ViewModels/ChaptersViewModel.cs | 32 ++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'win/CS') diff --git a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs index 1948a2443..037bacde0 100644 --- a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs @@ -16,6 +16,7 @@ namespace HandBrakeWPF.ViewModels using System.IO; using System.Text; using System.Linq; + using System.Windows; using System.Windows.Forms; using Caliburn.Micro; @@ -31,17 +32,24 @@ namespace HandBrakeWPF.ViewModels using ChapterMarker = HandBrakeWPF.Services.Encode.Model.Models.ChapterMarker; using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask; using GeneralApplicationException = HandBrakeWPF.Exceptions.GeneralApplicationException; + using MessageBox = System.Windows.Forms.MessageBox; /// /// The Chapters View Model /// public class ChaptersViewModel : ViewModelBase, IChaptersViewModel { + #region Constants and Fields + + private readonly IErrorService errorService; + /// /// The source chapters backing field /// private List sourceChaptersList; + #endregion + #region Constructors and Destructors /// @@ -53,9 +61,13 @@ namespace HandBrakeWPF.ViewModels /// /// The user Setting Service. /// - public ChaptersViewModel(IWindowManager windowManager, IUserSettingService userSettingService) + /// + /// The Error Service + /// + public ChaptersViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IErrorService errorService) { this.Task = new EncodeTask(); + this.errorService = errorService; } #endregion @@ -235,13 +247,12 @@ namespace HandBrakeWPF.ViewModels // If the number of chapters don't match, prompt for confirmation if (importedChapters.Count != this.Task.ChapterNames.Count) { - if (DialogResult.Yes != - MessageBox.Show( + if (MessageBoxResult.Yes != + this.errorService.ShowMessageBox( string.Format(Resources.ChaptersViewModel_ValidateImportedChapters_ChapterCountMismatchMsg, this.Task.ChapterNames.Count, importedChapters.Count), Resources.ChaptersViewModel_ValidateImportedChapters_ChapterCountMismatchWarning, - MessageBoxButtons.YesNo, - MessageBoxIcon.Question, - MessageBoxDefaultButton.Button2)) + MessageBoxButton.YesNo, + MessageBoxImage.Question)) { return false; } @@ -255,13 +266,12 @@ namespace HandBrakeWPF.ViewModels var diffs = importedChapters.Zip(this.Task.ChapterNames, (import, source) => source.Duration - import.Value.Item2); if (diffs.Count(diff => Math.Abs(diff.TotalSeconds) > 15) > 2) { - if (DialogResult.Yes != - MessageBox.Show( + if (MessageBoxResult.Yes != + this.errorService.ShowMessageBox( Resources.ChaptersViewModel_ValidateImportedChapters_ChapterDurationMismatchMsg, Resources.ChaptersViewModel_ValidateImportedChapters_ChapterDurationMismatchWarning, - MessageBoxButtons.YesNo, - MessageBoxIcon.Question, - MessageBoxDefaultButton.Button2)) + MessageBoxButton.YesNo, + MessageBoxImage.Question)) { return false; } -- cgit v1.2.3