using System;
|
using System.Collections.Generic;
|
using System.Text;
|
|
namespace HDL_ON.Stan
|
{
|
/// <summary>
|
/// 消息的逻辑
|
/// </summary>
|
public class HdlMessageLogic
|
{
|
#region ■ 变量声明___________________________
|
|
/// <summary>
|
/// 消息的逻辑
|
/// </summary>
|
private static HdlMessageLogic m_Current = null;
|
/// <summary>
|
/// 消息的逻辑
|
/// </summary>
|
public static HdlMessageLogic Current
|
{
|
get
|
{
|
if (m_Current == null)
|
{
|
m_Current = new HdlMessageLogic();;
|
}
|
return m_Current;
|
}
|
}
|
|
#endregion
|
|
#region ■ 一般的方法_________________________
|
|
/// <summary>
|
/// 显示信息框
|
/// </summary>
|
/// <param name="msgType">信息类型</param>
|
/// <param name="msg">信息</param>
|
/// <param name="action">单击确认后执行的回调函数</param>
|
/// <param name="buttonText">按钮的文本</param>
|
/// <param name="i_waitTime">等待时间,单位为秒,设置确认按钮在多长时间后才能够点击</param>
|
public void ShowMassage(ShowMsgType msgType, string msg, Action action = null, string buttonText = null, int i_waitTime = -1)
|
{
|
//空对象时,不显示
|
if (string.IsNullOrEmpty(msg))
|
{
|
return;
|
}
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
var alert = new ShowMsgControl(msgType, msg, buttonText, null, i_waitTime);
|
if (action != null)
|
{
|
alert.ConfirmClickEvent += () =>
|
{
|
try
|
{
|
//回调函数
|
action?.Invoke();
|
}
|
catch (Exception ex)
|
{
|
//出现未知错误,数据丢失
|
HdlMessageLogic.Current.ShowAppProgramIsError(ex);
|
}
|
action = null;
|
};
|
}
|
alert.Show();
|
});
|
}
|
|
/// <summary>
|
/// 显示App程序出现了致命错误
|
/// </summary>
|
/// <param name="ex"></param>
|
public void ShowAppProgramIsError(Exception ex)
|
{
|
this.ShowMassage(ShowMsgType.Error, "System Error!", () =>
|
{
|
//string msg = ex.Message + "\r\n";
|
//msg += ex.StackTrace;
|
|
//var form = new HideOptionFileContentForm();
|
//form.AddForm(string.Empty);
|
//form.SetTextContent(msg);
|
|
}, "ok");
|
}
|
|
#endregion
|
}
|
}
|