From 8b9ce384b26c414db32f98e94e088f5334869c2d Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期三, 13 十一月 2019 15:36:28 +0800
Subject: [PATCH] 全部合并了代码,安卓和 IOS 都测试通过了

---
 ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonLayout.cs |  317 +++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 211 insertions(+), 106 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonLayout.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonLayout.cs
index a78b742..62d78a5 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonLayout.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonLayout.cs
@@ -1,10 +1,11 @@
 锘縰sing System;
+using Newtonsoft.Json.Linq;
 using Shared.Common;
 using ZigBee.Device;
 
 namespace Shared.Phone.UserCenter.DoorLock
 {
-    public class DoorLockCommonLayout : FrameLayout
+    public class DoorLockCommonLayout : EditorCommonForm
     {
         public DoorLockCommonLayout()
         {
@@ -72,6 +73,8 @@
         public FrameLayout titleFrameLayout = new FrameLayout
         {
             Y = Application.GetRealHeight(92),
+            X = Application.GetRealWidth(58 * 2),
+            Width = Application.GetRealWidth(1080 - 116),
             Height = Application.GetRealHeight(69),
         };
 
@@ -80,9 +83,7 @@
         /// </summary>
         public FrameLayout btnBackFrameLayout = new FrameLayout
         {
-            X = Application.GetRealWidth(58),
-            Height = Application.GetRealHeight(58),
-            Width = Application.GetRealWidth(58),
+            Width = Application.GetRealWidth(58 * 2),
         };
 
         /// <summary>
@@ -92,6 +93,8 @@
         {
             Height = Application.GetRealHeight(51),
             Width = Application.GetRealWidth(30),
+            X = Application.GetRealWidth(58),
+            Y = Application.GetRealHeight(98),
             UnSelectedImagePath = "DoorLock/Left.png",
         };
 
@@ -125,8 +128,6 @@
             TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
             BackgroundColor = Shared.Common.ZigbeeColor.Current.XMMidFrameLayout,
         };
-
-
         #endregion
 
         /// <summary>
@@ -136,6 +137,7 @@
         public void TopFrameLayout(FrameLayout frameLayout, string titleText)
         {
             this.AddChidren(topFrameLayout);
+            topFrameLayout.AddChidren(btnBackFrameLayout);
             topFrameLayout.AddChidren(titleFrameLayout);
             topFrameLayout.AddChidren(btnTitleLine);
             var title = new Button()
@@ -143,13 +145,12 @@
                 TextAlignment = TextAlignment.CenterLeft,
                 Text = titleText,
                 TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
-                X = Application.GetRealWidth(161),
                 Width = Application.GetRealWidth(1080 - 161),
                 Height = Application.GetRealWidth(69),
                 TextSize = 17,
+                X = Application.GetRealWidth(161 - 116),
             };
             titleFrameLayout.AddChidren(title);
-            titleFrameLayout.AddChidren(btnBackFrameLayout);
             btnBackFrameLayout.AddChidren(btnBack);
             this.midFrameLayout.AddChidren(this.btnTip);
         }
@@ -237,7 +238,7 @@
                 if (DateTime.Now < ZigBee.Device.DoorLock.minValue)
                 {
                     CommonPage.Loading.Hide();
-                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AfterFiftySeconds), Direction = AMPopTipDirection.Down, CloseTime = 2 }.Show(editInputPassword);
+                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.NoFiftySeconds), Direction = AMPopTipDirection.Down, CloseTime = 2 }.Show(editInputPassword);
                     return;
                 }
 
@@ -266,71 +267,89 @@
                 }
 
                 var verifyResult = await doorLock.VerifyPasswordAsync(editInputPassword.Text);
-                if (verifyResult != null && verifyResult.result == 0)
+                if (verifyResult != null)
                 {
-                    System.Threading.Thread.Sleep(500);
-                    ZigBee.Device.DoorLock.RemoteUnlockPassword = editInputPassword.Text;
-                    ZigBee.Device.DoorLock.minValue = DateTime.MinValue;
-                    ZigBee.Device.DoorLock.RemoteUnlockCount = 5;
-                    oldTime = DateTime.MaxValue;
-                    CommonPage.Loading.Hide();
-                    dialog.Close();
-                    if (btnNext != null)
+                    if (verifyResult.result == 0)
                     {
-                        btnNext.IsSelected = true;
-                    }
-                    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()
+                        System.Threading.Thread.Sleep(500);
+                        doorLock.RemoteUnlockPassword = editInputPassword.Text;
+                        ZigBee.Device.DoorLock.minValue = DateTime.MinValue;
+                        ZigBee.Device.DoorLock.RemoteUnlockCount = 5;
+                        oldTime = DateTime.MaxValue;
+                        CommonPage.Loading.Hide();
+                        dialog.Close();
+                        if (btnNext != null)
                         {
-                            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()
+                            btnNext.IsSelected = true;
+                        }
+                        if (!UserCenterResourse.Option.DoorUnLockByRemote)
                         {
-                            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);
+                            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) =>
-                        {
-                            var form = new UserCenter.UserMain.SecondAuthenticationForm();
-                            form.AddForm();
-                            dialog2.Close();
-                        };
+                            doorDialog2.dialogBtnCancel.MouseUpEventHandler += (sender2, e2) =>
+                            {
+                                dialog2.Close();
+                            };
+                            doorDialog2.dialogBtnConfirm.MouseUpEventHandler += async (sender2, e2) =>
+                            {
+                                var form = new UserCenter.UserMain.SecondAuthenticationForm();
+                                form.AddForm();
+                                dialog2.Close();
+                            };
+                        }
+                        doorLock.ReSave();
+                    }
+                    else
+                    {
+                        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);
+                        return;
                     }
                 }
                 else
                 {
-                    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 = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show((View)sender1);
                     return;
                 }
+            };
+            doorDialog.flMain.MouseUpEventHandler += (sender11, e11) =>
+            {
+                if (btnNext != null)
+                {
+                    btnNext.IsSelected = false;
+                }
+                dialog.Close();
             };
         }
 
@@ -343,7 +362,7 @@
         /// <param name="btnDoorLockPic">闂ㄩ攣鍥剧墖寮�/鍏虫樉绀�</param>
         public void RemoteUnlockRequest(ZigBee.Device.DoorLock doorLock, Action action, Button progressButton = null, Button btnDoorLockPic = null, Button btnStatus = null)
         {
-            if (ZigBee.Device.DoorLock.RemoteUnlockPassword == "")
+            if (doorLock.RemoteUnlockPassword == "")
             {
                 var dialog = new Dialog { };
                 var doorDialog = new Shared.Phone.UserCenter.DoorLock.DoorlockDialog(dialog, Language.StringByID(R.MyInternationalizationString.Tip));
@@ -362,15 +381,7 @@
                 };
                 doorDialog.dialogBtnConfirm.MouseUpEventHandler += (sender1, e1) =>
                 {
-                    if (UserCenterResourse.UserInfo.AuthorityNo == 3)
-                    {
-                        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();
-                        dialog.Close();
-                    }
-                    else
+                    if (UserCenterResourse.UserInfo.AuthorityNo == 1)
                     {
                         var userDoorLockPage = new Shared.Phone.UserCenter.DoorLock.FunctionSetting(doorLock);
                         Shared.Phone.UserView.HomePage.Instance.AddChidren(userDoorLockPage);
@@ -378,7 +389,14 @@
                         userDoorLockPage.Show();
                         dialog.Close();
                     }
-
+                    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();
+                        dialog.Close();
+                    }
                 };
                 return;
             }
@@ -447,55 +465,142 @@
             {
                 action = async () =>
                 {
-                    //杩滅▼寮�閿�
-                    if (progressButton != null)
-                    {
-                        progressButton.Y = Application.GetRealHeight(10);
-                    }
-                    if (btnDoorLockPic != null)
-                    {
-                        btnDoorLockPic.IsSelected = true;
-                    }
-                    if (btnStatus != null)
-                    {
-                        btnStatus.Text = Language.StringByID(R.MyInternationalizationString.Opening);
-                    }
+                    //System.Threading.Tasks.Task.Run(async () =>
+                    //{
                     Application.RunOnMainThread(() => { CommonPage.Loading.Start("Loading..."); });
-                    var remoteControlResult = await doorLock.RemoteControlAsync(ZigBee.Device.DoorLock.RemoteUnlockPassword);
-
-                    if (remoteControlResult != null && remoteControlResult.responseData != null && remoteControlResult.responseData.status == 0)
+                    try
                     {
-
+                        //杩滅▼寮�閿�
                         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)
                         {
-                            System.Threading.Thread.Sleep(2000);
-                            //btnStatus.Text = Language.StringByID(R.MyInternationalizationString.DoorLockOpen);
-                            System.Threading.Thread.Sleep(3000);
-                            btnStatus.Text = Language.StringByID(R.MyInternationalizationString.CLose);
+                            Application.RunOnMainThread(() =>
+                            {
+                                btnStatus.Text = Language.StringByID(R.MyInternationalizationString.Opening);
+                            });
                         }
-                        CommonPage.Loading.Hide();
-                    }
-                    else
-                    {
-                        if (progressButton != null)
+                        var remoteControlResult = await doorLock.RemoteControlAsync(doorLock.RemoteUnlockPassword);
+                        //寮�閿佹垚鍔燂紝杩斿洖榛樿鍝嶅簲
+                        if (remoteControlResult != null && remoteControlResult.responseData != null)
                         {
-                            progressButton.Y = Application.GetRealHeight(347);
+                            if (remoteControlResult.responseData.status == 0)
+                            {
+                                if (progressButton != null)
+                                {
+                                    progressButton.Y = Application.GetRealHeight(347);
+                                }
+                                if (btnDoorLockPic != null)
+                                {
+                                    btnDoorLockPic.IsSelected = false;
+                                }
+                                if (btnStatus != null)
+                                {
+                                    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);
+                                    });
+                                }
+                                System.Threading.Thread.Sleep(5000);
+                            }
+                            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.UnlockFailed), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show((View)sender1);
+                                });
+                            }
                         }
-                        if (btnDoorLockPic != null)
+                        else if (remoteControlResult != null && remoteControlResult.IsPawDispear == true)
                         {
-                            btnDoorLockPic.IsSelected = false;
-                        }
+                            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();
 
-                        CommonPage.Loading.Hide();
+                            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();

--
Gitblit v1.8.0