From d6fb0646531172f23648441c224cdcccd721b894 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期一, 14 十二月 2020 09:59:01 +0800
Subject: [PATCH] 请合并代码,完成晾衣架最终功能。

---
 ZigbeeApp/Shared/Phone/UserCenter/UserMain/SecondAuthenticationForm.cs |  458 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 458 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/SecondAuthenticationForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/SecondAuthenticationForm.cs
new file mode 100755
index 0000000..f792ccc
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/SecondAuthenticationForm.cs
@@ -0,0 +1,458 @@
+锘縰sing 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));
+
+            var btntitle = (Button)topFrameLayout.GetTagByKey("txtTitle");
+            btntitle.MouseLongEventHandler += (sender, e) =>
+            {
+                //鏄剧ず鏁板瓧鍛戒护绐楀彛
+                this.ShowKeyNumberComandDialog();
+            };
+
+            //鍒濆鍖栦腑閮ㄤ俊鎭�
+            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);
+
+            MostRightIconControl btnFingerSwicth = null;
+            var touchIDSupper = TouchIDUtils.getTouchIDSupperType();
+            if (touchIDSupper == TouchIDUtils.TouchIDSupperType.TouchID)
+            {
+                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);
+                //寮�鍏虫寜閽�
+                btnFingerSwicth = rowFinger.AddMostRightSwitchIcon();
+                btnFingerSwicth.IsSelected = UserCenterResourse.AccountOption.FingerprintAuthentication;
+                //搴曠嚎
+                rowFinger.AddBottomLine();
+            }
+
+            var rowPsw = new FrameRowControl(frameTop.rowSpace / 2);
+            frameTop.AddChidren(rowPsw);
+            //濡傛灉杩欎釜鎵嬫満涓嶆敮鎸乀ouchId鐨勮瘽,鍒欏鍣ㄥ噺鍘昏繖涓鐨勯珮搴�
+            if (touchIDSupper != TouchIDUtils.TouchIDSupperType.TouchID)
+            {
+                frameTop.Height -= rowPsw.Height;
+            }
+            //瀵嗙爜楠岃瘉
+            rowPsw.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uPasswordAuthentication), 400);
+            //鍙崇澶�
+            rowPsw.AddRightArrow();
+            //鍘昏缃�
+            var btnSettion1 = rowPsw.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGotoSettion), 400);
+            if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.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.AccountOption.GestureAuthentication) == false)
+            {
+                //鍘讳慨鏀�
+                btnSettion2.TextID = R.MyInternationalizationString.uGotoEditor;
+            }
+
+            //浜屾瀹夊叏楠岃瘉灏嗙敤浜庝笅鍒楁搷浣�
+            var btnTitle = new NormalViewControl(800, 50, true);
+            btnTitle.X = ControlCommonResourse.XXLeft;
+            btnTitle.Y = frameTop.Bottom + Application.GetRealHeight(34);
+            btnTitle.TextSize = 12;
+            btnTitle.TextColor = UserCenterColor.Current.TextGrayColor3;
+            btnTitle.TextID = R.MyInternationalizationString.uSecondarySecurityWillBeUsedForTheFollowingOperations;
+            bodyFrameLayout.AddChidren(btnTitle);
+            btnTitle.ButtonClickEvent += (sender, e) =>
+            {
+                //闅愬尶鍔熻兘鐐瑰嚮
+                this.HideOptionClick(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.AccountOption.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;
+
+            //鎸囩汗楠岃瘉
+            if (btnFingerSwicth != null)
+            {
+                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;
+                        }
+                        //灏員ouch ID鐢ㄤ簬銆孼igBee銆峽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.AccountOption.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.AccountOption.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.AccountOption.FingerprintAuthentication = !btnFingerSwicth.IsSelected;
+                UserCenterResourse.AccountOption.Save();
+                //閲嶆柊鍒锋柊鐣岄潰
+                this.InitMiddleFrame();
+            }
+            else
+            {
+                if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == true
+                    && string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == true
+                    && btnLockSwicth.IsSelected == true)
+                {
+                    //鎵�鏈夐獙璇侀兘鍙栨秷浜�,鍒欏彇娑堣繙绋嬪紑閿佸姛鑳�
+                    UserCenterResourse.AccountOption.DoorUnLockByRemote = false;
+                }
+                UserCenterResourse.AccountOption.FingerprintAuthentication = !btnFingerSwicth.IsSelected;
+                UserCenterResourse.AccountOption.Save();
+                //閲嶆柊鍒锋柊鐣岄潰
+                this.InitMiddleFrame();
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 杩滅▼寮�閿乢__________________________
+
+        /// <summary>
+        /// 杩滅▼寮�閿�
+        /// </summary>
+        /// <param name="btnLockSwicth"></param>
+        private void DoRemoteUnLocks(MostRightIconControl btnLockSwicth)
+        {
+            if (btnLockSwicth.IsSelected == false
+                && string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == true
+                && string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == true)
+            {
+                TouchIDUtils.TouchIDSupperType type = TouchIDUtils.getTouchIDSupperType();
+                if (type == TouchIDUtils.TouchIDSupperType.None || UserCenterResourse.AccountOption.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.AccountOption.DoorUnLockByRemote = !btnLockSwicth.IsSelected;
+            UserCenterResourse.AccountOption.Save();
+            //閲嶆柊鍒锋柊鐣岄潰
+            this.InitMiddleFrame();
+        }
+
+        #endregion
+
+        #region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________
+
+        /// <summary>
+        /// 鑷韩鐨勪笂灞傜晫闈㈠叧闂悗,瀹冭嚜韬浜庢渶涓婂眰鏃�,瑙﹀彂鐨勪簨浠�
+        /// </summary>
+        public override int FormActionAgainEvent()
+        {
+            //閲嶆柊鍒锋柊鐣岄潰
+            this.InitMiddleFrame();
+
+            return 1;
+        }
+
+        #endregion
+
+        #region 鈻� 闅愬尶鍔熻兘___________________________
+
+        /// <summary>
+        /// 鐐瑰嚮鍚堣
+        /// </summary>
+        private int clickCount = 0;
+        /// <summary>
+        /// 鐐瑰嚮鐨勯偅鐬棿鐨勬椂闂�
+        /// </summary>
+        private DateTime clickTime;
+        /// <summary>
+        /// 闅愬尶鍔熻兘
+        /// </summary>
+        private void HideOptionClick(NormalViewControl btnTitle)
+        {
+            if (clickCount == 0)
+            {
+                clickTime = DateTime.Now;
+            }
+            clickCount++;
+            if (clickCount >= 10)
+            {
+                if ((DateTime.Now - clickTime).TotalSeconds > 3)
+                {
+                    clickCount = 0;
+                    return;
+                }
+                btnTitle.CanClick = false;
+                HdlThreadLogic.Current.RunThread(() =>
+                {
+                    this.ShowProgressBar();
+                    var result = HdlBackupLogic.Current.LoadHideOption();
+                    this.CloseProgressBar();
+                    if (result == true)
+                    {
+                        this.ShowMassage(ShowMsgType.Tip, "鍒锋柊闅愬尶閰嶇疆鎴愬姛");
+                    }
+                    else
+                    {
+                        this.ShowMassage(ShowMsgType.Tip, "鍒锋柊闅愬尶閰嶇疆澶辫触");
+                    }
+                });
+            }
+        }
+
+        /// <summary>
+        /// 鏄剧ず鏁板瓧鍛戒护绐楀彛
+        /// </summary>
+        private void ShowKeyNumberComandDialog()
+        {
+            //鐢熸垚涓�涓脊绐楃敾闈�
+            var dialogForm = new DialogInputControl();
+            dialogForm.SetTitleText("?????");
+
+            //鎸変笅纭鎸夐挳
+            dialogForm.ComfirmClickEvent += ((textValue) =>
+            {
+                dialogForm.CloseDialog();
+                if (textValue.StartsWith("2887") == true)
+                {
+                    var myTime = DateTime.Now;
+                    string strTime1 = myTime.ToString("HHmm");
+                    int value1 = Convert.ToInt32(strTime1.Substring(3, 1));
+                    string check1 = "2887" + strTime1 + (7 + value1).ToString();
+
+                    myTime = myTime.AddMinutes(-1);
+                    string strTime2 = myTime.ToString("HHmm");
+                    int value2 = Convert.ToInt32(strTime2.Substring(3, 1));
+                    string check2 = "2887" + strTime2 + (7 + value2).ToString();
+
+                    myTime = myTime.AddMinutes(2);
+                    string strTime3 = myTime.ToString("HHmm");
+                    int value3 = Convert.ToInt32(strTime3.Substring(3, 1));
+                    string check3 = "2887" + strTime3 + (7 + value3).ToString();
+
+                    if (textValue == check1 || textValue == check2 || textValue == check3)
+                    {
+                        //寮�鍚殣钘忚彍鍗�
+                        UserCenterResourse.HideOption.CenterHideMenu = 1;
+                    }
+                }
+                if (textValue == "84651666")
+                {
+                    //鏄剧ず璁惧鍘嗗彶鐗堟湰
+                    UserCenterResourse.HideOption.DeviceHistory = 1;
+                }
+                if (textValue == "12349")
+                {
+                    //寮哄埗璺宠浆鐪熷疄璁惧鐣岄潰
+                    UserCenterResourse.HideOption.GotoRealDeviceForm = 1;
+                }
+                if (textValue == "12348")
+                {
+                    //寮哄埗璺宠浆缃戝叧鐣岄潰
+                    UserCenterResourse.HideOption.GotoGatewayProductInfoForm = 1;
+                }
+                if (textValue == "abcdef1")
+                {
+                    //寮哄埗鍙樻洿甯稿紑妯″紡鐨勬椂闂翠负鍒嗛挓
+                    UserCenterResourse.HideOption.DoorLockNomallyOpenTimeMode = 1;
+                }
+
+                this.ShowMassage(ShowMsgType.Tip, "Ok!");
+            });
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.8.0