using System.Windows;
using System.Windows.Media;
namespace Muchinfo.MTPClient.Infrastructure.MessageBox
{
public class MessageBoxHelper
{
///
/// 显示成功信息
///
/// 提示信息
/// 标题
/// if set to true [is login].
/// MessageBoxResult.
public static MessageBoxResult ShowSuccess(string message, string caption, bool isLogin = false)
{
return ShowSuccess(Application.Current.MainWindow, message, caption, isLogin);
}
///
/// Shows the success.
///
/// The owner.
/// The message.
/// The caption.
/// if set to true [is login].
/// MessageBoxResult.
public static MessageBoxResult ShowSuccess(Window owner, string message, string caption, bool isLogin = false)
{
var background = GetBackground(isLogin);
return NewMessageBox.Show(owner, message, caption, MessageBoxButton.OK, MessageBoxImage.Information, background);
}
///
/// 显示提示信息
///
/// 提示信息
/// 标题
/// if set to true [is login].
/// MessageBoxResult.
public static MessageBoxResult ShowInfo(string message, string caption, bool isLogin = false)
{
return ShowInfo(Application.Current.MainWindow, message, caption, isLogin);
}
///
/// Shows the information.
///
/// The owner.
/// The message.
/// The caption.
/// if set to true [is login].
/// MessageBoxResult.
public static MessageBoxResult ShowInfo(Window owner, string message, string caption, bool isLogin = false)
{
var background = GetBackground(isLogin);
return NewMessageBox.Show(owner, message, caption, MessageBoxButton.OK, MessageBoxImage.Warning, background);
}
///
/// 显示选择信息
///
/// 提示信息
/// 标题
/// if set to true [is login].
/// System.Windows.MessageBoxResult.
public static MessageBoxResult ShowQuestion(string message, string caption, bool isLogin = false)
{
return ShowQuestion(Application.Current.MainWindow, message, caption, isLogin);
}
///
/// Shows the question.
///
/// The owner.
/// The message.
/// The caption.
/// if set to true [is login].
/// MessageBoxResult.
public static MessageBoxResult ShowQuestion(Window owner, string message, string caption, bool isLogin = false)
{
var background = GetBackground(isLogin);
return NewMessageBox.Show(owner, message, caption, MessageBoxButton.YesNo, MessageBoxImage.Question, background);
}
private static Brush GetBackground(bool isLogin)
{
return GetFromeResource(isLogin ? "MuchinfoBrush3" : "MuchinfoBrush6");
}
private static T GetFromeResource(string resourceName) where T : class
{
try
{
var brush = (T)Application.Current.TryFindResource(resourceName);
if (brush == null) return default(T);
return brush;
}
catch
{
return null;
}
}
}
}