using Shared.Phone.UserCenter; using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone { /// /// 消息的逻辑 /// public class HdlMessageLogic { #region ■ 变量声明___________________________ /// /// 消息的逻辑 /// private static HdlMessageLogic m_Current = null; /// /// 消息的逻辑 /// public static HdlMessageLogic Current { get { if (m_Current == null) { m_Current = new HdlMessageLogic(); } return m_Current; } } #endregion #region ■ 一般的方法_________________________ /// /// 显示信息框 /// /// 信息类型 /// 信息 /// 单击确认后执行的回调函数 /// 按钮的文本 /// 等待时间,单位为秒,设置确认按钮在多长时间后才能够点击 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) { //出现未知错误,数据丢失 this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError)); //Log出力 HdlLogLogic.Current.WriteLog(ex); } action = null; }; } alert.Show(); }); } #endregion } /// /// 信息显示的类型 /// public enum ShowMsgType { /// /// 普通提示类型 /// Normal = 1, /// /// 确认类型 /// Confirm = 2, /// /// 错误类型 /// Error = 3, /// /// Tip类型 /// Tip = 4, /// /// 提醒类型 /// Remind = 5 } }