xm
2019-07-16 b910cb79c9b5bcc204022a3cf9e6950f0a64dfbd
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
150
151
152
153
154
155
156
157
158
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.UserCenter.Safety
{
    /// <summary>
    /// 胁迫密码设置的菜单界面★
    /// </summary>
    public class CoercePasswordMainForm : UserCenterCommonForm
    {
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm()
        {
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uCoercePasswordSettion));
 
            //初始化中部信息
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        public void InitMiddleFrame()
        {
            bodyFrameLayout.RemoveAll();
 
            //密码设置
            string text = Language.StringByID(R.MyInternationalizationString.uPasswordSettion);
            var rowPsw = new OnlyCenterViewRow(text);
            //将图标控件适配为【点号】控件
            rowPsw.ChangedIconInPointMode();
            bodyFrameLayout.AddChidren(rowPsw);
            rowPsw.InitControl();
            //点号图片有点特殊,需要调整偏移量
            rowPsw.btnName.X -= ControlCommonResourse.PointXXLeft;
 
            //添加向右的图标
            rowPsw.AddRightIconControl();
            //状态
            var btnStatuPsw = new RowSecondRightTextView();
            rowPsw.AddChidren(btnStatuPsw);
 
            rowPsw.MouseUpEvent += (sender, e) =>
            {
                var form = new EdtiorCoercePasswordForm();
                this.AddForm(form, btnStatuPsw.TextColor != UserCenterColor.Current.Green);
            };
 
            //联系人设置
            text = Language.StringByID(R.MyInternationalizationString.uContactSettion);
            var rowContact = new OnlyCenterViewRow(text);
            rowContact.Y = rowPsw.Bottom;
            //将图标控件适配为【点号】控件
            rowContact.ChangedIconInPointMode();
            bodyFrameLayout.AddChidren(rowContact);
            rowContact.InitControl();
            //点号图片有点特殊,需要调整偏移量
            rowContact.btnName.X -= ControlCommonResourse.PointXXLeft;
 
            //添加向右的图标
            rowContact.AddRightIconControl();
            //状态
            var btnStaturowContact = new RowSecondRightTextView();
            rowContact.AddChidren(btnStaturowContact);
 
            rowContact.MouseUpEvent += (sender, e) =>
            {
                var form = new CoerceContactSettionForm();
                this.AddForm(form, btnStaturowContact.Tag);
            };
 
            //设置行的状态
            this.SetRowStatu(btnStatuPsw, btnStaturowContact);
        }
 
        /// <summary>
        /// 设置行的状态
        /// </summary>
        /// <param name="btnStatuPsw"></param>
        /// <param name="btnStaturowContact"></param>
        private async void SetRowStatu(RowSecondRightTextView btnStatuPsw, RowSecondRightTextView btnStaturowContact)
        {
            //开启进度条
            this.ShowProgressBar();
 
            //判断是否设置有胁迫密码
            var listData = await Common.LocalSafeguard.Current.GetAllUserPassword();
            bool isEsixt = false;
            if (listData != null)
            {
                foreach (var data in listData)
                {
                    if (data.UserId == 5)
                    {
                        isEsixt = true;
                        break;
                    }
                }
            }
            else
            {
                //关闭进度条
                this.CloseProgressBar(ShowReLoadMode.YES);
                return;
            }
 
            if (isEsixt == true)
            {
                Application.RunOnMainThread(() =>
                {
                    //已设置
                    btnStatuPsw.TextID = R.MyInternationalizationString.uAlreadySettion;
                    btnStatuPsw.TextColor = UserCenterColor.Current.Green;
                });
            }
            else
            {
                Application.RunOnMainThread(() =>
                {
                    //未设置
                    btnStatuPsw.TextID = R.MyInternationalizationString.uNotHadSettion;
                    btnStatuPsw.TextColor = UserCenterColor.Current.Gray;
                });
            }
 
            //获取联系方式
            var result = await Common.LocalSafeguard.Current.GetCoercePhoneNumber();
            if (result == null || result.Actions.Count == 0 || result.Actions[0].PushTarget.Count == 0)
            {
                Application.RunOnMainThread(() =>
                {
                    //未设置
                    btnStaturowContact.TextID = R.MyInternationalizationString.uNotHadSettion;
                    btnStaturowContact.TextColor = UserCenterColor.Current.Gray;
                    var data = new List<ZigBee.Device.Safeguard.PushTargetInfo>();
                    btnStaturowContact.Tag = data;
                });
            }
            else
            {
                Application.RunOnMainThread(() =>
                {
                    //已设置
                    btnStaturowContact.TextID = R.MyInternationalizationString.uAlreadySettion;
                    btnStaturowContact.TextColor = UserCenterColor.Current.Green;
                    btnStaturowContact.Tag = result.Actions[0].PushTarget;
                });
            }
 
            //关闭进度条
            this.CloseProgressBar();
        }
    }
}