// --------------------------------------------------------------------------------------------------------------------
//
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
//
//
// The Error Service
//
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Services
{
using System;
using System.Windows;
using Caliburn.Micro;
using Interfaces;
using ViewModels.Interfaces;
///
/// The Error Service
///
public class ErrorService : IErrorService
{
///
/// Show an Exception Error Window
///
///
/// The message.
///
///
/// The solution.
///
///
/// The details.
///
public void ShowError(string message, string solution, string details)
{
IWindowManager windowManager = IoC.Get();
IErrorViewModel errorViewModel = IoC.Get();
if (windowManager != null && errorViewModel != null)
{
errorViewModel.ErrorMessage = message;
errorViewModel.Solution = solution;
errorViewModel.Details = details;
windowManager.ShowDialog(errorViewModel);
}
}
///
/// Show an Exception Error Window
///
///
/// The message.
///
///
/// The solution.
///
///
/// The exception.
///
public void ShowError(string message, string solution, Exception exception)
{
IWindowManager windowManager = IoC.Get();
IErrorViewModel errorViewModel = IoC.Get();
if (windowManager != null && errorViewModel != null)
{
errorViewModel.ErrorMessage = message;
errorViewModel.Solution = solution;
errorViewModel.Details = exception.ToString();
windowManager.ShowDialog(errorViewModel);
}
}
///
/// 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.
///
///
/// The message.
///
///
/// The header.
///
///
/// The buttons.
///
///
/// The image.
///
///
/// The MessageBoxResult Object
///
public MessageBoxResult ShowMessageBox(string message, string header, MessageBoxButton buttons, MessageBoxImage image)
{
return MessageBox.Show(message, header, buttons, image);
}
}
}