using System;
|
using System.Text;
|
|
namespace Shared.Phone.UserCenter
|
{
|
/// <summary>
|
/// 显示一个信息框
|
/// </summary>
|
public class ShowMsgControl
|
{
|
/// <summary>
|
/// 点击确认的事件
|
/// </summary>
|
public Action ConfirmClickEvent = null;
|
/// <summary>
|
/// 提示控件
|
/// </summary>
|
private Alert alert = null;
|
/// <summary>
|
/// 提示控件
|
/// </summary>
|
private Tip myTip = null;
|
|
/// <summary>
|
/// 显示一个需要确认的信息框
|
/// </summary>
|
/// <param name="i_msgType">信息类型</param>
|
/// <param name="i_msg">信息</param>
|
/// <param name="buttonText">确认按钮的文本</param>
|
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;
|
}
|
}
|
|
/// <summary>
|
/// 显示
|
/// </summary>
|
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;
|
}
|
}
|
}
|