黄学彪
2019-11-20 5174e95a428876018ce3372f3dbc24b2861ea472
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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;
        }
    }
}