1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ErrorService.cs" company="HandBrake Project (http://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
// The Error Service
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Services
{
using System;
using System.Windows;
using Interfaces;
using Caliburn.Micro;
using ViewModels.Interfaces;
/// <summary>
/// The Error Service
/// </summary>
public class ErrorService : IErrorService
{
/// <summary>
/// Show an Exception Error Window
/// </summary>
/// <param name="message">
/// The message.
/// </param>
/// <param name="solution">
/// The solution.
/// </param>
/// <param name="details">
/// The details.
/// </param>
public void ShowError(string message, string solution, string details)
{
IWindowManager windowManager = IoC.Get<IWindowManager>();
IErrorViewModel errorViewModel = IoC.Get<IErrorViewModel>();
if (windowManager != null && errorViewModel != null)
{
errorViewModel.ErrorMessage = message;
errorViewModel.Solution = solution;
errorViewModel.Details = details;
windowManager.ShowDialog(errorViewModel);
}
}
/// <summary>
/// Show an Exception Error Window
/// </summary>
/// <param name="message">
/// The message.
/// </param>
/// <param name="solution">
/// The solution.
/// </param>
/// <param name="exception">
/// The exception.
/// </param>
public void ShowError(string message, string solution, Exception exception)
{
IWindowManager windowManager = IoC.Get<IWindowManager>();
IErrorViewModel errorViewModel = IoC.Get<IErrorViewModel>();
if (windowManager != null && errorViewModel != null)
{
errorViewModel.ErrorMessage = message;
errorViewModel.Solution = solution;
errorViewModel.Details = exception.ToString();
windowManager.ShowDialog(errorViewModel);
}
}
/// <summary>
/// Show a Message Box.
/// It is good practice to use this, so that if we ever introduce unit testing, the message boxes won't cause issues.
/// </summary>
/// <param name="message">
/// The message.
/// </param>
/// <param name="header">
/// The header.
/// </param>
/// <param name="buttons">
/// The buttons.
/// </param>
/// <param name="image">
/// The image.
/// </param>
/// <returns>
/// The MessageBoxResult Object
/// </returns>
public MessageBoxResult ShowMessageBox(string message, string header, MessageBoxButton buttons, MessageBoxImage image)
{
return MessageBox.Show(message, header, buttons, image);
}
}
}
|