HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-11-04 c7698e163e43cea9e7f8ee45f8e3f91c9265cca4
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.UserCenter.UserMain
{
    /// <summary>
    /// 二次安全验证
    /// </summary>
    public class SecondAuthenticationForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm()
        {
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uSecondAuthentication));
 
            //初始化中部信息
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame()
        {
            //清空bodyFrame
            this.ClearBodyFrame();
 
            var frameTop = new FrameListControl(12);
            frameTop.Height = Application.GetRealHeight(446);
            frameTop.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(frameTop);
 
            var rowFinger = new FrameRowControl(frameTop.rowSpace / 2);
            rowFinger.UseClickStatu = false;
            frameTop.AddChidren(rowFinger);
            //指纹验证
            var btnFinger = rowFinger.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uFingerprintAuthentication), 400, 58);
            btnFinger.Y = Application.GetRealHeight(12) + rowFinger.chidrenYaxis;
            rowFinger.AddChidren(btnFinger, ChidrenBindMode.NotBind);
            //仅对本机有效
            var btnEffect= rowFinger.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uOnlyEffectToThisPhone), 400, 40);
            btnEffect.Y = Application.GetRealHeight(72) + rowFinger.chidrenYaxis;
            btnEffect.TextSize = 12;
            btnEffect.TextColor = UserCenterColor.Current.TextGrayColor1;
            rowFinger.AddChidren(btnEffect, ChidrenBindMode.NotBind);
            //开关按钮
            var btnFingerSwicth = rowFinger.AddMostRightSwitchIcon();
            btnFingerSwicth.IsSelected = UserCenterResourse.Option.FingerprintAuthentication;
            //底线
            rowFinger.AddBottomLine();
 
            var rowPsw = new FrameRowControl(frameTop.rowSpace / 2);
            frameTop.AddChidren(rowPsw);
            //密码验证
            rowPsw.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uPasswordAuthentication), 400);
            //右箭头
            rowPsw.AddRightArrow();
            //去设置
            var btnSettion1 = rowPsw.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGotoSettion), 400);
            if (string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == false)
            {
                //去修改
                btnSettion1.TextID = R.MyInternationalizationString.uGotoEditor;
            }
            //底线
            rowPsw.AddBottomLine();
 
            var rowGesture = new FrameRowControl(frameTop.rowSpace / 2);
            frameTop.AddChidren(rowGesture);
            //手势验证
            rowGesture.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uGestureAuthentication), 400);
            //右箭头
            rowGesture.AddRightArrow();
            //去设置
            var btnSettion2 = rowGesture.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGotoSettion), 400);
            if (string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == false)
            {
                //去修改
                btnSettion2.TextID = R.MyInternationalizationString.uGotoEditor;
            }
 
            //二次安全验证将用于下列操作
            var btnTitle = new NormalViewControl(800, 49, true);
            btnTitle.X = ControlCommonResourse.XXLeft;
            btnTitle.Y = frameTop.Bottom + Application.GetRealHeight(35);
            btnTitle.TextSize = 12;
            btnTitle.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnTitle.TextID = R.MyInternationalizationString.uSecondarySecurityWillBeUsedForTheFollowingOperations;
            bodyFrameLayout.AddChidren(btnTitle);
 
            var frameButtom = new FrameListControl(12);
            frameButtom.Y = btnTitle.Bottom + Application.GetRealHeight(23);
            frameButtom.Height = Application.GetRealHeight(449);
            frameButtom.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(frameButtom);
 
            var rowAdmin = new FrameRowControl(frameButtom.rowSpace / 2);
            rowAdmin.UseClickStatu = false;
            frameButtom.AddChidren(rowAdmin);
            //管理员授权
            rowAdmin.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uAdministratorAuthorization), 400);
            //授权成员成为管理员
            var btnMsg = rowAdmin.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uAuthorizedMembersBecomeAdministrators), 400);
            btnMsg.TextSize = 12;
            btnMsg.TextColor = UserCenterColor.Current.TextGrayColor2;
            //底线
            rowAdmin.AddBottomLine();
 
            var rowLock = new FrameRowControl(frameTop.rowSpace / 2);
            rowLock.UseClickStatu = false;
            frameButtom.AddChidren(rowLock);
            //远程开锁
            var btnUnLock = rowLock.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uRemoteUnLocks), 400, 58);
            btnUnLock.Y = Application.GetRealHeight(12) + rowLock.chidrenYaxis;
            rowLock.AddChidren(btnUnLock, ChidrenBindMode.NotBind);
            //通过APP开启门锁
            var btnUnLockByApp = rowLock.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uUnLockDoorByApp), 400, 40);
            btnUnLockByApp.Y = Application.GetRealHeight(72) + rowLock.chidrenYaxis;
            btnUnLockByApp.TextSize = 12;
            btnUnLockByApp.TextColor = UserCenterColor.Current.TextGrayColor1;
            rowLock.AddChidren(btnUnLockByApp, ChidrenBindMode.NotBind);
            //开关按钮
            var btnLockSwicth = rowLock.AddMostRightSwitchIcon();
            //底线
            rowLock.AddBottomLine();
            btnLockSwicth.IsSelected = UserCenterResourse.Option.DoorUnLockByRemote;
 
            var rowSafety = new FrameRowControl(frameButtom.rowSpace / 2);
            rowSafety.UseClickStatu = false;
            frameButtom.AddChidren(rowSafety);
            //安防设置
            rowSafety.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uSafetySettion), 400);
            //配置防区
            var btnMsg2 = rowSafety.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGarrisonConfiguration), 400);
            btnMsg2.TextSize = 12;
            btnMsg2.TextColor = UserCenterColor.Current.TextGrayColor2;
 
            //指纹验证
            btnFingerSwicth.ButtonClickEvent += (sender, e) =>
            {
                if (btnFingerSwicth.IsSelected == false)
                {
                    TouchIDUtils.TouchIDSupperType type = TouchIDUtils.getTouchIDSupperType();
                    if (type == TouchIDUtils.TouchIDSupperType.None)
                    {
                        //开启指纹验证失败!请前往手机{0}设置开启指纹开锁验证
                        string msg = Language.StringByID(R.MyInternationalizationString.uUseFingerprintAuthenticationFailMsg);
                        msg = msg.Replace("{0}", "\r\n");
                        this.ShowMassage(ShowMsgType.Normal, msg);
                        return;
                    }
                    //将Touch ID用于「ZigBee」{0}更改安防设置和开启门锁时使用
                    string msg2 = Language.StringByID(R.MyInternationalizationString.uUseFingerprintAuthenticationMsg);
                    msg2 = msg2.Replace("{0}", "\r\n");
                    this.ShowMassage(ShowMsgType.Confirm, msg2, () =>
                    {
                        //如果设置有安全验证,想要修改它,必须先通过安全验证
                        //如果没有设置有安全验证,则无需验证
                        HdlCheckLogic.Current.CheckSecondarySecurity(
                            () => { this.DoFingerprintAuthentication(btnFingerSwicth, btnLockSwicth); },//处理指纹验证
                            () => { this.DoFingerprintAuthentication(btnFingerSwicth, btnLockSwicth); });//处理指纹验证
                    });
                }
                else
                {
                    //如果设置有安全验证,想要修改它,必须先通过安全验证
                    //如果没有设置有安全验证,则无需验证
                    HdlCheckLogic.Current.CheckSecondarySecurity(
                        () => { this.DoFingerprintAuthentication(btnFingerSwicth, btnLockSwicth); },//处理指纹验证
                        () => { this.DoFingerprintAuthentication(btnFingerSwicth, btnLockSwicth); });//处理指纹验证
                }
            };
            //密码验证
            rowPsw.ButtonClickEvent += (sender, e) =>
            {
                //如果没有密码验证
                if (string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == true)
                {
                    //如果设置有其他验证方式,则需要验证,否则直接跳过验证
                    HdlCheckLogic.Current.CheckSecondarySecurity(
                   () => { var form = new Password.EditorSecondaryPasswordForm(); form.AddForm(); },
                   () => { var form = new Password.EditorSecondaryPasswordForm(); form.AddForm(); });
                }
                else
                {
                    var form = new Password.EditorSecondaryPasswordForm();
                    form.AddForm();
                }
            };
            //手势验证
            rowGesture.ButtonClickEvent += (sender, e) =>
            {
                //如果没有手势验证
                if (string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == true)
                {
                    //如果设置有其他验证方式,则需要验证,否则直接跳过验证
                    HdlCheckLogic.Current.CheckSecondarySecurity(
                   () => { var form = new Password.EditorGesturePasswordForm(); form.AddForm(); },
                   () => { var form = new Password.EditorGesturePasswordForm(); form.AddForm(); });
                }
                else
                {
                    var form = new Password.EditorGesturePasswordForm();
                    form.AddForm();
                }
            };
            //远程开锁
            btnLockSwicth.ButtonClickEvent += (sender, e) =>
            {
                //如果设置有安全验证,想要修改它,必须先通过安全验证
                //如果没有设置有安全验证,则无需验证
                HdlCheckLogic.Current.CheckSecondarySecurity(
                    () => { this.DoRemoteUnLocks(btnLockSwicth); },//处理远程开锁
                    () => { this.DoRemoteUnLocks(btnLockSwicth); });//处理远程开锁
            };
        }
 
        #endregion
 
        #region ■ 指纹验证___________________________
 
        /// <summary>
        /// 指纹验证
        /// </summary>
        /// <param name="btnFingerSwicth"></param>
        /// <param name="btnLockSwicth"></param>
        private void DoFingerprintAuthentication(MostRightIconControl btnFingerSwicth, MostRightIconControl btnLockSwicth)
        {
            if (btnFingerSwicth.IsSelected == false)
            {
                TouchIDUtils.TouchIDSupperType type = TouchIDUtils.getTouchIDSupperType();
                if (type == TouchIDUtils.TouchIDSupperType.None)
                {
                    //开启指纹验证失败!请前往手机{0}设置开启指纹开锁验证
                    string msg = Language.StringByID(R.MyInternationalizationString.uUseFingerprintAuthenticationFailMsg);
                    if (msg.Contains("{0}") == true)
                    {
                        msg = string.Format(msg, "\r\n");
                    }
                    this.ShowMassage(ShowMsgType.Normal, msg);
                    return;
                }
 
                UserCenterResourse.Option.FingerprintAuthentication = !btnFingerSwicth.IsSelected;
                UserCenterResourse.Option.Save();
                //重新刷新界面
                this.InitMiddleFrame();
            }
            else
            {
                if (string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == true
                    && string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == true
                    && btnLockSwicth.IsSelected == true)
                {
                    //所有验证都取消了,则取消远程开锁功能
                    UserCenterResourse.Option.DoorUnLockByRemote = false;
                }
                UserCenterResourse.Option.FingerprintAuthentication = !btnFingerSwicth.IsSelected;
                UserCenterResourse.Option.Save();
                //重新刷新界面
                this.InitMiddleFrame();
            }
        }
 
        #endregion
 
        #region ■ 远程开锁___________________________
 
        /// <summary>
        /// 远程开锁
        /// </summary>
        /// <param name="btnLockSwicth"></param>
        private void DoRemoteUnLocks(MostRightIconControl btnLockSwicth)
        {
            if (btnLockSwicth.IsSelected == false
                && string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == true
                && string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == true)
            {
                TouchIDUtils.TouchIDSupperType type = TouchIDUtils.getTouchIDSupperType();
                if (type == TouchIDUtils.TouchIDSupperType.None || UserCenterResourse.Option.FingerprintAuthentication == false)
                {
                    //远程开锁开启失败,请先设置{0}二次安全验证方式
                    string msg = Language.StringByID(R.MyInternationalizationString.uUseUnLockByRemoteFailMsg);
                    if (msg.Contains("{0}") == true)
                    {
                        msg = string.Format(msg, "\r\n");
                    }
                    this.ShowMassage(ShowMsgType.Normal, msg);
                    return;
                }
            }
            UserCenterResourse.Option.DoorUnLockByRemote = !btnLockSwicth.IsSelected;
            UserCenterResourse.Option.Save();
            //重新刷新界面
            this.InitMiddleFrame();
        }
 
        #endregion
 
        #region ■ 界面重新激活事件___________________
 
        /// <summary>
        /// 自身的上层界面关闭后,它自身处于最上层时,触发的事件
        /// </summary>
        public override int FormActionAgainEvent()
        {
            //重新刷新界面
            this.InitMiddleFrame();
 
            return 1;
        }
 
        #endregion
    }
}