From 66a9965c44ecc32a6696abca876ab9d1cd091584 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 28 二月 2020 15:25:13 +0800
Subject: [PATCH] 2020.2.28

---
 ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonLayout.cs |  509 ++++++++++++++++++++++++++++---------------------------
 1 files changed, 258 insertions(+), 251 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonLayout.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonLayout.cs
index 62d78a5..8b4e4d4 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonLayout.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonLayout.cs
@@ -14,26 +14,14 @@
         #region 鈼� 鍙橀噺鐢虫槑__________________________
         public FrameLayout topFrameLayout = new FrameLayout { Height = Application.GetRealHeight(184), BackgroundColor = ZigbeeColor.Current.XMTopFrameLayout };
         public FrameLayout midFrameLayout = new FrameLayout { Height = Application.GetRealHeight(1921 - 184), BackgroundColor = ZigbeeColor.Current.XMMidFrameLayout };
-
         #region 鈼� 搴曢儴鏈夊渾瑙掑竷灞�__________________________
         public FrameLayout shadowRadiusFrameLayout = new FrameLayout { BackgroundColor = 0x0f000000 };
-        public FrameLayout bottomRadiusFrameLayout1 = new FrameLayout()
-        {
-            Height = Application.GetRealHeight(100),
-            Y = Application.GetRealHeight(930),
-            Radius = 17,
-            BackgroundColor = ZigbeeColor.Current.XMWhite,
-        };
-        public FrameLayout bottomRadiusFrameLayout2 = new FrameLayout()
-        {
-            Height = Application.GetRealHeight(806 - 50),
-            Y = Application.GetRealHeight(930 + 48),
-            BackgroundColor = ZigbeeColor.Current.XMWhite,
-        };
+
         public FrameLayout bottomRadiusFrameLayout = new FrameLayout()
         {
             Height = Application.GetRealHeight(806),
             Y = Application.GetRealHeight(930),
+            BackgroundColor = ZigbeeColor.Current.XMWhite,
         };
 
         public Button btnCancel = new Button
@@ -65,11 +53,29 @@
             Height = Application.GetRealHeight(58),
             Width = Application.GetRealWidth(101),
             Text = Language.StringByID(R.MyInternationalizationString.Complete),
-            TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
+            TextColor = Shared.Common.ZigbeeColor.Current.XMOrange,
             TextSize = 14,
         };
+
+        public Button line = new Button()
+        {
+            Y = Application.GetRealHeight(138),
+            Height = 1,
+            BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
+        };
+
         #endregion
 
+        /// <summary> 
+        /// 鈼� 涓儴鍒锋柊甯冨眬__________________________
+        /// </summary>
+        //public VerticalRefreshLayout midVerticalScrolViewLayout = new VerticalRefreshLayout()
+        //{
+        //};
+
+        /// <summary>
+        /// 鈼� 鏍囬鏍忓竷灞�__________________________
+        /// </summary>
         public FrameLayout titleFrameLayout = new FrameLayout
         {
             Y = Application.GetRealHeight(92),
@@ -99,14 +105,6 @@
         };
 
         /// <summary>
-        /// 鏍囬杩斿洖鎸夐敭
-        /// </summary>
-        public Button btnTip = new Button
-        {
-            Gravity = Gravity.Center,
-        };
-
-        /// <summary>
         /// 鏍囬涓嬬嚎
         /// </summary>
         public Button btnTitleLine = new Button
@@ -115,6 +113,7 @@
             Height = 1,
             BackgroundColor = Shared.Common.ZigbeeColor.Current.XMTitleLine,
         };
+
 
         /// <summary>
         /// 寮圭獥鍙栨秷鎸夐敭
@@ -148,11 +147,11 @@
                 Width = Application.GetRealWidth(1080 - 161),
                 Height = Application.GetRealWidth(69),
                 TextSize = 17,
+                IsBold = true,
                 X = Application.GetRealWidth(161 - 116),
             };
             titleFrameLayout.AddChidren(title);
             btnBackFrameLayout.AddChidren(btnBack);
-            this.midFrameLayout.AddChidren(this.btnTip);
         }
         /// <summary>
         /// 闂ㄩ攣涓儴甯冨眬
@@ -185,12 +184,12 @@
         /// <param name="frameLayout"></param>
         public void BottomRadiusFrameLayout(FrameLayout frameLayout)
         {
-            this.shadowRadiusFrameLayout.AddChidren(this.bottomRadiusFrameLayout1);
-            this.shadowRadiusFrameLayout.AddChidren(this.bottomRadiusFrameLayout2);
             this.shadowRadiusFrameLayout.AddChidren(this.bottomRadiusFrameLayout);
+            this.bottomRadiusFrameLayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight);
             this.bottomRadiusFrameLayout.AddChidren(btnCancel);
             this.bottomRadiusFrameLayout.AddChidren(btnBottomTitle);
             this.bottomRadiusFrameLayout.AddChidren(btnFinish);
+            this.bottomRadiusFrameLayout.AddChidren(line);
         }
 
         /// <summary>
@@ -206,22 +205,28 @@
             doorDialog.dialogMidFraFrameLayout.Height = Application.GetRealHeight(69);
             doorDialog.dialogMidFraFrameLayout.X = Application.GetRealWidth(58);
             doorDialog.dialogMidFraFrameLayout.Y = Application.GetRealHeight(213);
-            doorDialog.dialogMidFraFrameLayout.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBorder;
+            doorDialog.dialogMidFraFrameLayout.BackgroundColor = BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBorder;
+
+            var editInputPasswordFrameLayout = new FrameLayout()
+            {
+                Width = Application.GetRealWidth(677) - 2,
+                Height = Application.GetRealHeight(69) - 2,
+                X = 1,
+                Y = 1,
+                BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
+            };
+            doorDialog.dialogMidFraFrameLayout.AddChidren(editInputPasswordFrameLayout);
 
             var editInputPassword = new EditText()
             {
-                Width = Application.GetRealWidth(672),
-                Height = Application.GetRealHeight(63),
-                X = Application.GetRealWidth(3),
-                Y = Application.GetRealHeight(3),
-                TextSize = 14,
+                X = Application.GetRealHeight(25),
+                TextSize = 13,
                 PlaceholderTextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                 PlaceholderText = Language.StringByID(R.MyInternationalizationString.InputUnlockPasswrd),
                 TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
-                TextAlignment = TextAlignment.CenterLeft,
-                BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
+                TextAlignment = TextAlignment.BottomLeft,
             };
-            doorDialog.dialogMidFraFrameLayout.AddChidren(editInputPassword);
+            editInputPasswordFrameLayout.AddChidren(editInputPassword);
 
             doorDialog.dialogBtnCancel.MouseUpEventHandler += (sender1, e1) =>
             {
@@ -274,6 +279,7 @@
                         System.Threading.Thread.Sleep(500);
                         doorLock.RemoteUnlockPassword = editInputPassword.Text;
                         ZigBee.Device.DoorLock.minValue = DateTime.MinValue;
+                        ZigBee.Device.DoorLock.failedCount = 3;
                         ZigBee.Device.DoorLock.RemoteUnlockCount = 5;
                         oldTime = DateTime.MaxValue;
                         CommonPage.Loading.Hide();
@@ -284,45 +290,14 @@
                         }
                         if (!UserCenterResourse.Option.DoorUnLockByRemote)
                         {
-                            var dialog2 = new Dialog { };
-                            var doorDialog2 = new Shared.Phone.UserCenter.DoorLock.DoorlockDialog(dialog2, Language.StringByID(R.MyInternationalizationString.Tip));
-                            doorDialog2.Show();
-                            doorDialog2.dialogMidFraFrameLayout.Width = Application.GetRealWidth(674);
-                            doorDialog2.dialogMidFraFrameLayout.Height = Application.GetRealHeight(115);
-                            doorDialog2.dialogMidFraFrameLayout.X = Application.GetRealWidth(60);
-                            doorDialog2.dialogMidFraFrameLayout.Y = Application.GetRealHeight(167);
-                            doorDialog2.dialogBtnConfirm.Text = Language.StringByID(R.MyInternationalizationString.GoSetting);
-                            var midText1 = new Button()
-                            {
-                                Width = Application.GetRealWidth(674),
-                                Height = Application.GetRealHeight(115 / 2),
-                                TextSize = 14,
-                                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
-                                TextAlignment = TextAlignment.Center,
-                                TextID = R.MyInternationalizationString.RemoteUnlockBindSucessTip1,
-                            };
-                            doorDialog2.dialogMidFraFrameLayout.AddChidren(midText1);
-                            var midText2 = new Button()
-                            {
-                                Width = Application.GetRealWidth(674),
-                                Height = Application.GetRealHeight(115 / 2),
-                                Y = Application.GetRealHeight(115 / 2),
-                                TextSize = 14,
-                                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
-                                TextAlignment = TextAlignment.Center,
-                                TextID = R.MyInternationalizationString.RemoteUnlockBindSucessTip2,
-                            };
-                            doorDialog2.dialogMidFraFrameLayout.AddChidren(midText2);
-
-                            doorDialog2.dialogBtnCancel.MouseUpEventHandler += (sender2, e2) =>
-                            {
-                                dialog2.Close();
-                            };
-                            doorDialog2.dialogBtnConfirm.MouseUpEventHandler += async (sender2, e2) =>
+                            string msg = Language.StringByID(R.MyInternationalizationString.RemoteUnlockBindSucessTip).Replace("{0}", "\r\n");
+                            var alert = new Shared.Phone.UserCenter.ShowMsgControl(ShowMsgType.Confirm, msg, Language.StringByID(R.MyInternationalizationString.GoSetting));
+                            alert.Show();
+                            //浣跨敤纭鍨嬪脊妗嗘椂,鐨勫洖璋冨嚱鏁�
+                            alert.ConfirmClickEvent += () =>
                             {
                                 var form = new UserCenter.UserMain.SecondAuthenticationForm();
                                 form.AddForm();
-                                dialog2.Close();
                             };
                         }
                         doorLock.ReSave();
@@ -332,14 +307,14 @@
                         ZigBee.Device.DoorLock.RemoteUnlockCount--;
                         string tipText = Language.StringByID(R.MyInternationalizationString.OperrateFailed) + "," + Language.StringByID(R.MyInternationalizationString.Surplus) + ZigBee.Device.DoorLock.RemoteUnlockCount.ToString() + Language.StringByID(R.MyInternationalizationString.Opportunity);
                         CommonPage.Loading.Hide();
-                        new Tip() { MaxWidth = 150, Text = tipText, Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show((View)sender1);
+                        new Tip() { MaxWidth = 150, Text = tipText, Direction = AMPopTipDirection.Down, CloseTime = 2 }.Show(editInputPassword);
                         return;
                     }
                 }
                 else
                 {
                     CommonPage.Loading.Hide();
-                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show((View)sender1);
+                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Down, CloseTime = 2 }.Show(editInputPassword);
                     return;
                 }
             };
@@ -354,48 +329,76 @@
         }
 
         /// <summary>
+        /// 瀹夊叏楠岃瘉
+        /// </summary>
+        /// <param name="doorLock">闂ㄩ攣璁惧</param>
+        /// <param name="action">浜屾楠岃瘉鐨勭粨鏋滄垚鍔熷悗鐨勯�氱煡</param> 
+        public static void SecurityRequest(ZigBee.Device.DoorLock doorLock, Action action)
+        {
+            string msg = Language.StringByID(R.MyInternationalizationString.GoPersonalCenter).Replace("{0}", "\r\n");
+            var alert = new Shared.Phone.UserCenter.ShowMsgControl(ShowMsgType.Confirm, msg, Language.StringByID(R.MyInternationalizationString.GoSetting));
+            alert.Show();
+            //浣跨敤纭鍨嬪脊妗嗘椂,鐨勫洖璋冨嚱鏁�
+            alert.ConfirmClickEvent += () =>
+            {
+                var form = new UserCenter.UserMain.SecondAuthenticationForm();
+                form.AddForm();
+            };
+        }
+
+        /// <summary>
         /// 杩滅▼寮�閿佽姹�
         /// </summary>
         /// <param name="doorLock">闂ㄩ攣璁惧</param>
         /// <param name="action">浜屾楠岃瘉鐨勭粨鏋滄垚鍔熷悗鐨勯�氱煡</param>
         /// <param name="progressButton">闂ㄩ攣寮�鎴栧叧鏃惰繘搴︽樉绀�</param>
         /// <param name="btnDoorLockPic">闂ㄩ攣鍥剧墖寮�/鍏虫樉绀�</param>
-        public void RemoteUnlockRequest(ZigBee.Device.DoorLock doorLock, Action action, Button progressButton = null, Button btnDoorLockPic = null, Button btnStatus = null)
+        public void RemoteUnlockRequest(ZigBee.Device.DoorLock doorLock, Action action, Button progressButton = null, Button btnDoorLockPic = null, Button btnStatus = null, Button btnDoorLockTitle = null)
         {
-            if (doorLock.RemoteUnlockPassword == "")
+            if (string.IsNullOrEmpty(doorLock.RemoteUnlockPassword))
             {
-                var dialog = new Dialog { };
-                var doorDialog = new Shared.Phone.UserCenter.DoorLock.DoorlockDialog(dialog, Language.StringByID(R.MyInternationalizationString.Tip));
-                doorDialog.Show();
-                doorDialog.dialogMidFraFrameLayout.Width = Application.GetRealWidth(415);
-                doorDialog.dialogMidFraFrameLayout.Height = Application.GetRealHeight(58);
-                doorDialog.dialogMidFraFrameLayout.X = Application.GetRealWidth(190);
-                doorDialog.dialogMidFraFrameLayout.Y = Application.GetRealHeight(202);
-                doorDialog.dialogMidFraFrameLayout.AddChidren(doorDialog.dialogMidText);
-                doorDialog.dialogMidText.Text = Language.StringByID(R.MyInternationalizationString.BindRemoteUnlockDoorlock);
-                doorDialog.dialogMidFraFrameLayout.AddChidren(doorDialog.dialogMidText);
-                doorDialog.dialogBtnConfirm.Text = Language.StringByID(R.MyInternationalizationString.GoSetting);
-                doorDialog.dialogBtnCancel.MouseUpEventHandler += (sender1, e1) =>
-                {
-                    dialog.Close();
-                };
-                doorDialog.dialogBtnConfirm.MouseUpEventHandler += (sender1, e1) =>
+                string msgRemoteUnlockRequest = Language.StringByID(R.MyInternationalizationString.BindRemoteUnlockDoorlock);
+                var alertRemoteUnlockRequest = new Shared.Phone.UserCenter.ShowMsgControl(ShowMsgType.Confirm, msgRemoteUnlockRequest, Language.StringByID(R.MyInternationalizationString.GoSetting));
+                alertRemoteUnlockRequest.Show();
+                //浣跨敤纭鍨嬪脊妗嗘椂,鐨勫洖璋冨嚱鏁�
+                alertRemoteUnlockRequest.ConfirmClickEvent += () =>
                 {
                     if (UserCenterResourse.UserInfo.AuthorityNo == 1)
                     {
-                        var userDoorLockPage = new Shared.Phone.UserCenter.DoorLock.FunctionSetting(doorLock);
-                        Shared.Phone.UserView.HomePage.Instance.AddChidren(userDoorLockPage);
+                        var functionSetting = new Shared.Phone.UserCenter.DoorLock.FunctionSetting(doorLock);
+                        Shared.Phone.UserView.HomePage.Instance.AddChidren(functionSetting);
                         Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
-                        userDoorLockPage.Show();
-                        dialog.Close();
+                        functionSetting.Show();
+                        functionSetting.devicNameAction += (deviceRename) =>
+                        {
+                            if (!string.IsNullOrEmpty(deviceRename))
+                            {
+                                if (btnDoorLockTitle != null)
+                                {
+                                    btnDoorLockTitle.Text = deviceRename;
+                                }
+                            }
+                        };
                     }
                     else
                     {
-                        var userDoorLockPage = new Shared.Phone.UserCenter.DoorLock.FunctionSettingSub(doorLock);
-                        Shared.Phone.UserView.HomePage.Instance.AddChidren(userDoorLockPage);
+                        var functionSettingSub = new Shared.Phone.UserCenter.DoorLock.FunctionSettingSub(doorLock);
+                        Shared.Phone.UserView.HomePage.Instance.AddChidren(functionSettingSub);
                         Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
-                        userDoorLockPage.Show();
-                        dialog.Close();
+                        functionSettingSub.Show();
+                        functionSettingSub.devicNameAction += (deviceRename) =>
+                        {
+                            if (!string.IsNullOrEmpty(deviceRename))
+                            {
+                                if (!string.IsNullOrEmpty(deviceRename))
+                                {
+                                    if (btnDoorLockTitle != null)
+                                    {
+                                        btnDoorLockTitle.Text = deviceRename;
+                                    }
+                                }
+                            }
+                        };
                     }
                 };
                 return;
@@ -403,208 +406,212 @@
 
             if (!UserCenterResourse.Option.DoorUnLockByRemote)
             {
-                var dialog2 = new Dialog { };
-                var doorDialog2 = new Shared.Phone.UserCenter.DoorLock.DoorlockDialog(dialog2, Language.StringByID(R.MyInternationalizationString.Tip));
-                doorDialog2.Show();
-                doorDialog2.dialogMidFraFrameLayout.Width = Application.GetRealWidth(674);
-                doorDialog2.dialogMidFraFrameLayout.Height = Application.GetRealHeight(115);
-                doorDialog2.dialogMidFraFrameLayout.X = Application.GetRealWidth(60);
-                doorDialog2.dialogMidFraFrameLayout.Y = Application.GetRealHeight(167);
-                doorDialog2.dialogBtnConfirm.Text = Language.StringByID(R.MyInternationalizationString.GoSetting);
-                var midText1 = new Button()
-                {
-                    Width = Application.GetRealWidth(674),
-                    Height = Application.GetRealHeight(115 / 2),
-                    TextSize = 14,
-                    TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
-                    TextAlignment = TextAlignment.Center,
-                    TextID = R.MyInternationalizationString.GoPersonalCenter,
-                };
-                doorDialog2.dialogMidFraFrameLayout.AddChidren(midText1);
-                var midText2 = new Button()
-                {
-                    Width = Application.GetRealWidth(674),
-                    Height = Application.GetRealHeight(115 / 2),
-                    Y = Application.GetRealHeight(115 / 2),
-                    TextSize = 14,
-                    TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
-                    TextAlignment = TextAlignment.Center,
-                    TextID = R.MyInternationalizationString.OpenRemoteVerification,
-                };
-                doorDialog2.dialogMidFraFrameLayout.AddChidren(midText2);
-
-                doorDialog2.dialogBtnCancel.MouseUpEventHandler += (sender2, e2) =>
-                {
-                    dialog2.Close();
-                };
-                doorDialog2.dialogBtnConfirm.MouseUpEventHandler += async (sender2, e2) =>
+                string msgDoorUnLockByRemote = Language.StringByID(R.MyInternationalizationString.GoPersonalCenter).Replace("{0}", "\r\n");
+                var alertDoorUnLockByRemote = new Shared.Phone.UserCenter.ShowMsgControl(ShowMsgType.Confirm, msgDoorUnLockByRemote, Language.StringByID(R.MyInternationalizationString.GoSetting));
+                alertDoorUnLockByRemote.Show();
+                //浣跨敤纭鍨嬪脊妗嗘椂,鐨勫洖璋冨嚱鏁�
+                alertDoorUnLockByRemote.ConfirmClickEvent += () =>
                 {
                     var form = new UserCenter.UserMain.SecondAuthenticationForm();
                     form.AddForm();
-                    dialog2.Close();
                 };
                 return;
             }
 
-            var dialog3 = new Dialog { };
-            var doorDialog3 = new Shared.Phone.UserCenter.DoorLock.DoorlockDialog(dialog3, Language.StringByID(R.MyInternationalizationString.UnlockRequest));
-            doorDialog3.Show();
-            doorDialog3.dialogMidFraFrameLayout.Width = Application.GetRealWidth(415);
-            doorDialog3.dialogMidFraFrameLayout.Height = Application.GetRealHeight(58);
-            doorDialog3.dialogMidFraFrameLayout.X = Application.GetRealWidth(228);
-            doorDialog3.dialogMidFraFrameLayout.Y = Application.GetRealHeight(202);
-            doorDialog3.dialogMidFraFrameLayout.AddChidren(doorDialog3.dialogMidText);
-            doorDialog3.dialogMidText.Text = Language.StringByID(R.MyInternationalizationString.SureToOpenDoorLock);
-            doorDialog3.dialogMidFraFrameLayout.AddChidren(doorDialog3.dialogMidText);
-            doorDialog3.dialogBtnConfirm.Text = Language.StringByID(R.MyInternationalizationString.Confrim);
-            doorDialog3.dialogBtnCancel.MouseUpEventHandler += (sender1, e1) =>
+            string msg = Language.StringByID(R.MyInternationalizationString.SureToOpenDoorLock);
+            var alert = new Shared.Phone.UserCenter.ShowMsgControl(ShowMsgType.Confirm, msg, Language.StringByID(R.MyInternationalizationString.DoorlockConfirm));
+            alert.Show();
+            //浣跨敤纭鍨嬪脊妗嗘椂,鐨勫洖璋冨嚱鏁�
+            alert.ConfirmClickEvent += () =>
             {
-                dialog3.Close();
-            };
-            doorDialog3.dialogBtnConfirm.MouseUpEventHandler += (sender1, e1) =>
-            {
-                action = async () =>
+                action = () =>
                 {
-                    //System.Threading.Tasks.Task.Run(async () =>
-                    //{
-                    Application.RunOnMainThread(() => { CommonPage.Loading.Start("Loading..."); });
-                    try
+                    System.Threading.Tasks.Task.Run(async () =>
                     {
-                        //杩滅▼寮�閿�
-                        if (progressButton != null)
-                        {
-                            progressButton.Y = Application.GetRealHeight(10);
-                        }
-                        if (btnDoorLockPic != null)
-                        {
-                            btnDoorLockPic.IsSelected = true;
-                        }
-                        if (btnStatus != null)
+                        Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); });
+                        try
                         {
                             Application.RunOnMainThread(() =>
                             {
-                                btnStatus.Text = Language.StringByID(R.MyInternationalizationString.Opening);
-                            });
-                        }
-                        var remoteControlResult = await doorLock.RemoteControlAsync(doorLock.RemoteUnlockPassword);
-                        //寮�閿佹垚鍔燂紝杩斿洖榛樿鍝嶅簲
-                        if (remoteControlResult != null && remoteControlResult.responseData != null)
-                        {
-                            if (remoteControlResult.responseData.status == 0)
-                            {
                                 if (progressButton != null)
                                 {
-                                    progressButton.Y = Application.GetRealHeight(347);
+                                    progressButton.Y = Application.GetRealHeight(10);
                                 }
                                 if (btnDoorLockPic != null)
                                 {
-                                    btnDoorLockPic.IsSelected = false;
+                                    btnDoorLockPic.IsSelected = true;
                                 }
                                 if (btnStatus != null)
                                 {
+                                    btnStatus.Text = Language.StringByID(R.MyInternationalizationString.Opening);
+
+                                }
+                            });
+                            //杩滅▼寮�閿� 
+                            var remoteControlResult = await doorLock.RemoteControlAsync(doorLock.RemoteUnlockPassword);
+                            //寮�閿佹垚鍔燂紝杩斿洖榛樿鍝嶅簲
+                            if (remoteControlResult != null && remoteControlResult.responseData != null)
+                            {
+                                if (remoteControlResult.responseData.status == 0)
+                                {
+                                    ZigBee.Device.DoorLock.failedCount = 3;
                                     Application.RunOnMainThread(() =>
                                     {
-                                        btnStatus.Text = Language.StringByID(R.MyInternationalizationString.DoorLockOpen);
-                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.UnlockSuccess), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show((View)sender1);
+                                        if (progressButton != null)
+                                        {
+                                            progressButton.Y = Application.GetRealHeight(347);
+                                        }
+                                        if (btnDoorLockPic != null)
+                                        {
+                                            btnDoorLockPic.IsSelected = false;
+                                        }
+                                        if (btnStatus != null)
+                                        {
+                                            btnStatus.Text = Language.StringByID(R.MyInternationalizationString.DoorLockOpen);
+                                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.UnlockSuccess), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(CommonPage.Instance);
+                                        }
+                                    });
+                                    System.Threading.Thread.Sleep(5000);
+                                }
+                                else
+                                {
+                                    Application.RunOnMainThread(() =>
+                                    {
+                                        if (progressButton != null)
+                                        {
+                                            progressButton.Y = Application.GetRealHeight(347);
+                                        }
+                                        if (btnDoorLockPic != null)
+                                        {
+                                            btnDoorLockPic.IsSelected = false;
+                                        }
+                                        if (btnStatus != null)
+                                        {
+                                            btnStatus.Text = Language.StringByID(R.MyInternationalizationString.CLose);
+                                        }
+                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.UnlockFailed), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(CommonPage.Instance);
                                     });
                                 }
-                                System.Threading.Thread.Sleep(5000);
+                            }
+                            else if (remoteControlResult != null && remoteControlResult.IsPawDispear == true)
+                            {
+                                ZigBee.Device.DoorLock.failedCount--;
+                                if (ZigBee.Device.DoorLock.failedCount != 0)
+                                {
+                                    Application.RunOnMainThread(() =>
+                                    {
+                                        if (progressButton != null)
+                                        {
+                                            progressButton.Y = Application.GetRealHeight(347);
+                                        }
+                                        if (btnDoorLockPic != null)
+                                        {
+                                            btnDoorLockPic.IsSelected = false;
+                                        }
+                                        if (btnStatus != null)
+                                        {
+                                            btnStatus.Text = Language.StringByID(R.MyInternationalizationString.CLose);
+                                        }
+                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.UnlockFailed), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(CommonPage.Instance);
+                                    });
+                                }
+                                else
+                                {
+                                    Application.RunOnMainThread(() =>
+                                    {
+                                        if (progressButton != null)
+                                        {
+                                            progressButton.Y = Application.GetRealHeight(347);
+                                        }
+                                        if (btnDoorLockPic != null)
+                                        {
+                                            btnDoorLockPic.IsSelected = false;
+                                        }
+                                        if (btnStatus != null)
+                                        {
+                                            btnStatus.Text = Language.StringByID(R.MyInternationalizationString.CLose);
+                                        }
+                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.DoorlockPasswordDispear), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(CommonPage.Instance);
+                                        CommonPage.Loading.Hide();
+                                        doorLock.RemoteUnlockPassword = "";
+                                        if (UserCenterResourse.UserInfo.AuthorityNo == 1)
+                                        {
+                                            var functionSetting = new Shared.Phone.UserCenter.DoorLock.FunctionSetting(doorLock);
+                                            Shared.Phone.UserView.HomePage.Instance.AddChidren(functionSetting);
+                                            Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
+                                            functionSetting.Show();
+                                            functionSetting.devicNameAction += (deviceRename) =>
+                                            {
+                                                if (!string.IsNullOrEmpty(deviceRename))
+                                                {
+                                                    if (btnDoorLockTitle != null)
+                                                    {
+                                                        btnDoorLockTitle.Text = deviceRename;
+                                                    }
+                                                }
+                                            };
+                                        }
+                                        else
+                                        {
+                                            var functionSettingSub = new Shared.Phone.UserCenter.DoorLock.FunctionSettingSub(doorLock);
+                                            Shared.Phone.UserView.HomePage.Instance.AddChidren(functionSettingSub);
+                                            Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
+                                            functionSettingSub.Show();
+                                            functionSettingSub.devicNameAction += (deviceRename) =>
+                                            {
+                                                if (!string.IsNullOrEmpty(deviceRename))
+                                                {
+                                                    if (!string.IsNullOrEmpty(deviceRename))
+                                                    {
+                                                        if (btnDoorLockTitle != null)
+                                                        {
+                                                            btnDoorLockTitle.Text = deviceRename;
+                                                        }
+                                                    }
+                                                }
+                                            };
+                                        }
+                                    });
+                                }
                             }
                             else
                             {
-                                if (progressButton != null)
-                                {
-                                    progressButton.Y = Application.GetRealHeight(347);
-                                }
-                                if (btnDoorLockPic != null)
-                                {
-                                    btnDoorLockPic.IsSelected = false;
-                                }
                                 Application.RunOnMainThread(() =>
                                 {
+                                    if (progressButton != null)
+                                    {
+                                        progressButton.Y = Application.GetRealHeight(347);
+                                    }
+                                    if (btnDoorLockPic != null)
+                                    {
+                                        btnDoorLockPic.IsSelected = false;
+                                    }
                                     if (btnStatus != null)
                                     {
                                         btnStatus.Text = Language.StringByID(R.MyInternationalizationString.CLose);
                                     }
-                                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.UnlockFailed), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show((View)sender1);
+                                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(CommonPage.Instance);
                                 });
                             }
                         }
-                        else if (remoteControlResult != null && remoteControlResult.IsPawDispear == true)
+                        catch { }
+                        finally
                         {
-                            if (progressButton != null)
-                            {
-                                progressButton.Y = Application.GetRealHeight(347);
-                            }
-                            if (btnDoorLockPic != null)
-                            {
-                                btnDoorLockPic.IsSelected = false;
-                            }
                             Application.RunOnMainThread(() =>
                             {
                                 if (btnStatus != null)
                                 {
                                     btnStatus.Text = Language.StringByID(R.MyInternationalizationString.CLose);
                                 }
-                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.DoorlockPasswordDispear), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show((View)sender1);
                                 CommonPage.Loading.Hide();
-                                doorLock.RemoteUnlockPassword = "";
-                            });
-                            dialog3.Close();
-
-                            if (UserCenterResourse.UserInfo.AuthorityNo == 1)
-                            {
-                                var userDoorLockPage = new Shared.Phone.UserCenter.DoorLock.FunctionSetting(doorLock);
-                                Shared.Phone.UserView.HomePage.Instance.AddChidren(userDoorLockPage);
-                                Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
-                                userDoorLockPage.Show();
-
-                            }
-                            else
-                            {
-                                var userDoorLockPage = new Shared.Phone.UserCenter.DoorLock.FunctionSettingSub(doorLock);
-                                Shared.Phone.UserView.HomePage.Instance.AddChidren(userDoorLockPage);
-                                Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
-                                userDoorLockPage.Show();
-                            }
-                        }
-                        else
-                        {
-                            if (progressButton != null)
-                            {
-                                progressButton.Y = Application.GetRealHeight(347);
-                            }
-                            if (btnDoorLockPic != null)
-                            {
-                                btnDoorLockPic.IsSelected = false;
-                            }
-                            Application.RunOnMainThread(() =>
-                            {
-                                if (btnStatus != null)
-                                {
-                                    btnStatus.Text = Language.StringByID(R.MyInternationalizationString.CLose);
-                                }
-                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show((View)sender1);
                             });
                         }
-                    }
-                    catch { }
-                    finally
-                    {
-                        Application.RunOnMainThread(() =>
-                        {
-                            if (btnStatus != null)
-                            {
-                                btnStatus.Text = Language.StringByID(R.MyInternationalizationString.CLose);
-                            }
-                            CommonPage.Loading.Hide();
-                        });
-                    }
-                    //});
+                    });
                 };
                 HdlCheckLogic.Current.CheckSecondarySecurity(action);
-                dialog3.Close();
             };
         }
+        // 鑾峰彇鍒板埌鍚嶇О鏇存敼鍥炶皟閫氱煡
+        public Action<string> devicNameSecAction;
     }
 }

--
Gitblit v1.8.0