using System;
using System.Text;
namespace Shared.Phone.UserCenter
{
///
/// 显示一个信息框
///
public class ShowMsgControl
{
///
/// 点击确认的事件
///
public Action ConfirmClickEvent = null;
///
/// 提示控件
///
private Alert alert = null;
///
/// 提示控件
///
private Tip myTip = null;
///
/// 显示一个需要确认的信息框
///
/// 信息类型
/// 信息
/// 确认按钮的文本
public ShowMsgControl(ShowMsgType i_msgType, string i_msg, string buttonText = null)
{
//确认按钮文本
string okText = buttonText == null ? Language.StringByID(R.MyInternationalizationString.OkMsg) : buttonText;
if (i_msgType == ShowMsgType.Normal)
{
alert = new Alert(Language.StringByID(R.MyInternationalizationString.NormalTip), i_msg, okText);
}
else if (i_msgType == ShowMsgType.Error)
{
alert = new Alert(Language.StringByID(R.MyInternationalizationString.ErrorTip), i_msg, okText);
}
else if (i_msgType == ShowMsgType.Confirm)
{
alert = new Alert(Language.StringByID(R.MyInternationalizationString.NormalTip),
i_msg, Language.StringByID(R.MyInternationalizationString.uCancel), okText);
}
else if (i_msgType == ShowMsgType.Tip)
{
myTip = new Tip();
myTip.Direction = AMPopTipDirection.None;
myTip.CloseTime = 2;
myTip.Text = i_msg;
}
}
///
/// 显示
///
public void Show()
{
if (alert != null)
{
alert.Show();
if (this.ConfirmClickEvent != null)
{
alert.ResultEventHandler += (sender, e) =>
{
if (e == true)
{
this.ConfirmClickEvent?.Invoke();
}
this.ConfirmClickEvent = null;
};
}
}
else if (myTip != null)
{
myTip.Show(Common.CommonPage.Instance);
}
alert = null;
myTip = null;
}
}
}