黄学彪
2020-09-22 ade5917841b0fdcb1df7353ef7c56b1a1bdc9282
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.UserCenter.Safety
{
    /// <summary>
    /// 用户密码的列表界面
    /// </summary>
    public class PasswordListUserForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm()
        {
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uSafetyPassword));
 
            //初始化中部信息
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        public void InitMiddleFrame()
        {
            //清空bodyFrame
            this.ClearBodyFrame();
 
            HdlThreadLogic.Current.RunThread(async () =>
            {
                //打开进度条
                this.ShowProgressBar();
                var listData = await HdlSafeguardLogic.Current.GetAllUserPassword();
                if (listData == null)
                {
                    //关闭进度条
                    this.CloseProgressBar(ShowReLoadMode.YES);
                    return;
                }
                //关闭进度条
                this.CloseProgressBar();
 
                var dicEsixt = new Dictionary<int, ZigBee.Device.Safeguard.UserPasswordListObj>();
                foreach (var data in listData)
                {
                    dicEsixt[data.UserId] = data;
                }
 
                HdlThreadLogic.Current.RunMain(() =>
                {
                    var listView = new VerticalListControl(29);
                    listView.Y = Application.GetRealHeight(-6);
                    listView.Height = bodyFrameLayout.Height;
                    listView.BackgroundColor = UserCenterColor.Current.White;
                    bodyFrameLayout.AddChidren(listView);
 
                    //4个用户密码
                    for (int i = 1; i <= 4; i++)
                    {
                        //添加行
                        this.AddPassworRow(listView, dicEsixt, i);
                    }
                    listView.AdjustRealHeight(Application.GetRealHeight(23));
                });
            });   
        }
 
        #endregion
 
        #region ■ 添加行_____________________________
 
        /// <summary>
        /// 添加行
        /// </summary>
        /// <param name="listView"></param>
        /// <param name="dicEsixt"></param>
        /// <param name="pswNo"></param>
        private void AddPassworRow(VerticalListControl listView, Dictionary<int, ZigBee.Device.Safeguard.UserPasswordListObj> dicEsixt, int pswNo)
        {
            string text = Language.StringByID(R.MyInternationalizationString.uUserPassword) + pswNo;
            if (dicEsixt.ContainsKey(pswNo) == true && string.IsNullOrEmpty(dicEsixt[pswNo].PassWordTips) == false)
            {
                text = dicEsixt[pswNo].PassWordTips;
            }
 
            //添加【用户密码】行
            var rowUserPsw = new FrameRowControl(listView.rowSpace / 2);
            listView.AddChidren(rowUserPsw);
            //图标
            var btnUserPswIcon = rowUserPsw.AddLeftIcon(81);
            btnUserPswIcon.UnSelectedImagePath = "Item/Point.png";
            //用户密码
            var btnUserPswText = rowUserPsw.AddLeftCaption(text, 700);
            btnUserPswText.TextSize = 15;
            //向右的图标
            rowUserPsw.AddRightArrow();
            if (dicEsixt.ContainsKey(pswNo) == false)
            {
                //未设置
                rowUserPsw.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uNotHadSettion), 300);
            }
            if (pswNo != 4)
            {
                //底线
                rowUserPsw.AddBottomLine();
            }
            rowUserPsw.ButtonClickEvent += (sender, e) =>
            {
                //新建
                if (dicEsixt.ContainsKey(pswNo) == false)
                {
                    var form = new PasswordAddNewForm();
                    form.AddForm(pswNo, text);
                }
                //编辑
                else
                {
                    var form = new PasswordUserEditorForm();
                    form.AddForm(pswNo, dicEsixt[pswNo].Password, text);
                }
            };
        }
 
        #endregion
 
        #region ■ 界面重新激活事件___________________
 
        /// <summary>
        /// 自身的上层界面关闭后,它自身处于最上层时,触发的事件
        /// </summary>
        public override int FormActionAgainEvent()
        {
            //重新初始化
            this.InitMiddleFrame();
            return 1;
        }
 
        #endregion
    }
}