You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

48 lines
1.6 KiB

using System;
using System.Windows.Forms;
namespace CK.SCP.Utils
{
public static class MessageHelper
{
public static void ShowEx(Exception ex)
{
ex = GetInnerException(ex);
var str = ex.ToString().Length > 100 ? ex.Message : ex.ToString();
MessageBox.Show(str, "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
LogHelper.Write(ex.ToString());
}
private static Exception GetInnerException(Exception ex)
{
while (true)
{
if (ex.InnerException == null) return ex;
ex = ex.InnerException;
}
}
public static void ShowError(Exception ex)
{
//MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
LogHelper.Write(ex.ToString());
}
public static void ShowError(string msg)
{
// MessageBox.Show(msg, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
LogHelper.Write(msg);
}
public static DialogResult ShowWarning(string msg)
{
return MessageBox.Show(msg, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
public static DialogResult ShowQuestion(string msg)
{
return MessageBox.Show(msg, "问题", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
}
public static void ShowInfo(string msg)
{
MessageBox.Show(msg, "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}