黄学彪
2019-11-28 3a26f6025130dcaae4aa82ea19b16ad902450eb8
ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonLayout.cs
@@ -14,7 +14,6 @@
        #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()
@@ -70,6 +69,16 @@
        };
        #endregion
        /// <summary>
        /// ◆ 中部刷新布局__________________________
        /// </summary>
        //public VerticalRefreshLayout midVerticalScrolViewLayout = new VerticalRefreshLayout()
        //{
        //};
        /// <summary>
        /// ◆ 标题栏布局__________________________
        /// </summary>
        public FrameLayout titleFrameLayout = new FrameLayout
        {
            Y = Application.GetRealHeight(92),
@@ -97,7 +106,7 @@
            Y = Application.GetRealHeight(98),
            UnSelectedImagePath = "DoorLock/Left.png",
        };
        /// <summary>
        /// 标题下线
        /// </summary>
@@ -107,6 +116,7 @@
            Height = 1,
            BackgroundColor = Shared.Common.ZigbeeColor.Current.XMTitleLine,
        };
        /// <summary>
        /// 弹窗取消按键
@@ -144,7 +154,6 @@
            };
            titleFrameLayout.AddChidren(title);
            btnBackFrameLayout.AddChidren(btnBack);
            //this.midFrameLayout.AddChidren(this.btnTip);
        }
        /// <summary>
        /// 门锁中部布局
@@ -402,7 +411,7 @@
        /// <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 == "")
            {
@@ -425,18 +434,41 @@
                {
                    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();
                        functionSetting.Show();
                        functionSetting.devicNameAction += (deviceRename) =>
                        {
                            if (!string.IsNullOrEmpty(deviceRename))
                            {
                                if (btnDoorLockTitle != null)
                                {
                                    btnDoorLockTitle.Text = deviceRename;
                                }
                            }
                        };
                        dialog.Close();
                    }
                    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();
                        functionSettingSub.Show();
                        functionSettingSub.devicNameAction += (deviceRename) =>
                        {
                            if (!string.IsNullOrEmpty(deviceRename))
                            {
                                if (!string.IsNullOrEmpty(deviceRename))
                                {
                                    if (btnDoorLockTitle != null)
                                    {
                                        btnDoorLockTitle.Text = deviceRename;
                                    }
                                }
                            }
                        };
                        dialog.Close();
                    }
                };
@@ -505,175 +537,196 @@
            };
            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("Loading..."); });
                        try
                        {
                            Application.RunOnMainThread(() =>
                            {
                                btnStatus.Text = Language.StringByID(R.MyInternationalizationString.Opening);
                                if (progressButton != null)
                                {
                                    progressButton.Y = Application.GetRealHeight(10);
                                }
                                if (btnDoorLockPic != null)
                                {
                                    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)
                            //远程开锁
                            var remoteControlResult = await doorLock.RemoteControlAsync(doorLock.RemoteUnlockPassword);
                            //开锁成功,返回默认响应
                            if (remoteControlResult != null && remoteControlResult.responseData != null)
                            {
                                ZigBee.Device.DoorLock.failedCount = 3;
                                if (progressButton != null)
                                if (remoteControlResult.responseData.status == 0)
                                {
                                    progressButton.Y = Application.GetRealHeight(347);
                                }
                                if (btnDoorLockPic != null)
                                {
                                    btnDoorLockPic.IsSelected = false;
                                }
                                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);
                                //Application.RunOnMainThread(() =>
                                //{
                                //    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((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)
                                    ZigBee.Device.DoorLock.failedCount = 3;
                                    Application.RunOnMainThread(() =>
                                    {
                                        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);
                            }
                        }
                        else if (remoteControlResult != null && remoteControlResult.IsPawDispear == true)
                        {
                            ZigBee.Device.DoorLock.failedCount--;
                            if (ZigBee.Device.DoorLock.failedCount != 0)
                            {
                                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);
                            }
                            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.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();
                                        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((View)sender1);
                                        }
                                    });
                                    System.Threading.Thread.Sleep(5000);
                                }
                                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();
                                    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);
                                    });
                                }
                            }
                            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((View)sender1);
                                    });
                                }
                                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((View)sender1);
                                        CommonPage.Loading.Hide();
                                        doorLock.RemoteUnlockPassword = "";
                                        dialog3.Close();
                                        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
                            {
                                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.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show((View)sender1);
                                });
                            }
                        }
                        else
                        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.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show((View)sender1);
                                CommonPage.Loading.Hide();
                            });
                        }
                    }
                    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;
    }
}