黄学彪
2020-12-16 0d9f64668fd7350d6a21fd157e32009a96d98134
ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonLayout.cs
@@ -16,14 +16,6 @@
        #region 变量申明
        public new FrameLayout topFrameLayout = new FrameLayout { Height = Application.GetRealHeight(184), BackgroundColor = ZigbeeColor.Current.XMTopFrameLayout };
        public FrameLayout midFrameLayout = new FrameLayout { Height = Application.GetRealHeight(1925 - 184), BackgroundColor = ZigbeeColor.Current.XMMidFrameLayout };
        /// <summary>
        /// 选中的开锁方式回调
        /// </summary>
        public Action<string> ChooseUnlockMethodAction = null;
        /// <summary>
        /// 选中的开锁方式回调
        /// </summary>
        public Action<int> UndateUnlockMethodAction = null;
        #region 底部有圆角布局
        /// 背景阴影界面
        /// </summary>
@@ -304,7 +296,7 @@
                        {
                            btnNext.IsSelected = true;
                        }
                        if (!UserCenterResourse.AccountOption.DoorUnLockByRemote)
                        if (!HdlUserCenterResourse.AccountOption.DoorUnLockByRemote)
                        {
                            string msg = Language.StringByID(R.MyInternationalizationString.RemoteUnlockBindSucessTip).Replace("{0}", "\r\n");
                            var alert = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.Confirm, msg, Language.StringByID(R.MyInternationalizationString.GoSetting));
@@ -425,7 +417,7 @@
                return;
            }
            if (!UserCenterResourse.AccountOption.DoorUnLockByRemote)
            if (!HdlUserCenterResourse.AccountOption.DoorUnLockByRemote)
            {
                SystemSecondAuthentication();
                return;
@@ -584,332 +576,31 @@
        /// <param name="curIndex"></param>
        /// <param name="btnAllMethod"></param>
        /// <param name="btnMethodText"></param>
        public void DisplayAllUnlockMethod(ZigBee.Device.DoorLock doorLock, int curIndex, Button btnAllMethod, Button btnMethodText)
        public void DisplayAllUnlockMethod(int curIndex, Button btnAllMethod, Button btnMethodText)
        {
            var listDevice = Common.LocalDevice.Current.GetDevicesByMac(doorLock.DeviceAddr);
            var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(listDevice);
            if (curIndex == 0)
            switch (curIndex)
            {
                btnAllMethod.UnSelectedImagePath = "DoorLock/AllMethod.png";
                btnAllMethod.SelectedImagePath = "DoorLock/AllMethodOn.png";
                btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.AllMethod);
            }
            else if (curIndex == 1)
            {
                btnAllMethod.UnSelectedImagePath = "DoorLock/Password.png";
                btnAllMethod.SelectedImagePath = "DoorLock/PasswordOn.png";
                btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.PasswordUnlock);
            }
            else if (curIndex == 2)
            {
                if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.IntelligentLocks_AT1F)
                {
                    btnAllMethod.UnSelectedImagePath = "DoorLock/Fingerprint.png";
                    btnAllMethod.SelectedImagePath = "DoorLock/FingerprintOn.png";
                    btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.CalmFingerprintUnlock);
                }
                else if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.IntelligentLocks_HAT1B)
                {
                    btnAllMethod.UnSelectedImagePath = "DoorLock/Fingerprint.png";
                    btnAllMethod.SelectedImagePath = "DoorLock/FingerprintOn.png";
                    btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.CalmFingerprintUnlock);
                }
                else
                {
                case 0:
                    btnAllMethod.UnSelectedImagePath = "DoorLock/AllMethod.png";
                    btnAllMethod.SelectedImagePath = "DoorLock/AllMethodOn.png";
                    btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.AllMethod);
                    break;
                case 1:
                    btnAllMethod.UnSelectedImagePath = "DoorLock/Password.png";
                    btnAllMethod.SelectedImagePath = "DoorLock/PasswordOn.png";
                    btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.PasswordUnlock);
                    break;
                case 2:
                    btnAllMethod.UnSelectedImagePath = "DoorLock/Fingerprint.png";
                    btnAllMethod.SelectedImagePath = "DoorLock/FingerprintOn.png";
                    btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.FingerprintUnlock);
                }
            }
            else if (curIndex == 3)
            {
                if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.IntelligentLocks_AT1F)
                {
                    btnAllMethod.UnSelectedImagePath = "DoorLock/faceId.png";
                    btnAllMethod.SelectedImagePath = "DoorLock/faceIdOn.png";
                    btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.FaceIDUnlock);
                }
                else if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.IntelligentLocks_AT1TF)
                {
                    break;
                case 3:
                    btnAllMethod.UnSelectedImagePath = "DoorLock/proximityCard.png";
                    btnAllMethod.SelectedImagePath = "DoorLock/proximityCardOn.png";
                    btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock);
                }
                else
                {
                    btnAllMethod.UnSelectedImagePath = "DoorLock/proximityCard.png";
                    btnAllMethod.SelectedImagePath = "DoorLock/proximityCardOn.png";
                    btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock);
                }
                    break;
            }
            if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.IntelligentLocks_AT1TF)
            {
                if (curIndex == 4)
                {
                    btnAllMethod.UnSelectedImagePath = "DoorLock/faceId.png";
                    btnAllMethod.SelectedImagePath = "DoorLock/faceIdOn.png";
                    btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.FaceIDUnlock);
                }
            }
            //switch (curIndex)
            //{
            //    case 0:
            //        btnAllMethod.UnSelectedImagePath = "DoorLock/AllMethod.png";
            //        btnAllMethod.SelectedImagePath = "DoorLock/AllMethodOn.png";
            //        btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.AllMethod);
            //        break;
            //    case 1:
            //        btnAllMethod.UnSelectedImagePath = "DoorLock/Password.png";
            //        btnAllMethod.SelectedImagePath = "DoorLock/PasswordOn.png";
            //        btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.PasswordUnlock);
            //        break;
            //    case 2:
            //        btnAllMethod.UnSelectedImagePath = "DoorLock/Fingerprint.png";
            //        btnAllMethod.SelectedImagePath = "DoorLock/FingerprintOn.png";
            //        btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.FingerprintUnlock);
            //        break;
            //    case 3:
            //        btnAllMethod.UnSelectedImagePath = "DoorLock/proximityCard.png";
            //        btnAllMethod.SelectedImagePath = "DoorLock/proximityCardOn.png";
            //        btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock);
            //        break;
            //    case 4:
            //        btnAllMethod.UnSelectedImagePath = "DoorLock/faceId.png";
            //        btnAllMethod.SelectedImagePath = "DoorLock/faceIdOn.png";
            //        btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.FaceIDUnlock);
            //        break;
            //    case 5:
            //        btnAllMethod.UnSelectedImagePath = "DoorLock/Fingerprint.png";
            //        btnAllMethod.SelectedImagePath = "DoorLock/FingerprintOn.png";
            //        btnMethodText.Text = Language.StringByID(R.MyInternationalizationString.CalmFingerprintUnlock);
            //        break;
            //}
        }
        /// <summary>
        /// 侧边导航栏
        /// </summary>
        public void SideslipFramelayout(ZigBee.Device.DoorLock doorLock)
        {
            #region sidelipFrameLayout UI
            var dialog = new Dialog
            {
            };
            dialog.Show();
            var flMain = new FrameLayout { BackgroundColor = 0x00000000 };
            dialog.AddChidren(flMain);
            flMain.MouseUpEventHandler += (sender11, e11) =>
            {
                dialog.Close();
            };
            var sidelipFrameLayout = new FrameLayout()
            {
                Width = Application.GetRealWidth(449),
                Y = Application.GetRealHeight(115 + 160),
                X = Application.GetRealWidth(596),
                BackgroundImagePath = "DoorLock/SideslipPic.png",
            };
            flMain.AddChidren(sidelipFrameLayout);
            var sidelipVerticalScrolViewLayout = new VerticalScrolViewLayout()
            {
                Y = Application.GetRealHeight(28),
            };
            sidelipFrameLayout.AddChidren(sidelipVerticalScrolViewLayout);
            #endregion
            Button oldbutton = null;
            Button oldbuttonText = null;
            int count = 1 + GetSupportType(doorLock);
            sidelipFrameLayout.Height = Application.GetRealHeight(150) * count + Application.GetRealHeight(6);
            sidelipVerticalScrolViewLayout.Height = Application.GetRealHeight(150) * count + Application.GetRealHeight(6);
            for (var i = 0; i < count; i++)
            {
                #region rowFrameLayout UI
                var rowFrameLayout = new FrameLayout()
                {
                    Height = Application.GetRealHeight(150),
                    X = Application.GetRealWidth(81),
                };
                sidelipVerticalScrolViewLayout.AddChidren(rowFrameLayout);
                var btnAllMethod = new Button()
                {
                    Width = Application.GetRealWidth(81),
                    Height = Application.GetRealHeight(81),
                    Y = Application.GetRealHeight(35),
                };
                rowFrameLayout.AddChidren(btnAllMethod);
                var btnMethodText = new Button()
                {
                    Width = Application.GetRealWidth(311),
                    Height = Application.GetRealHeight(58),
                    X = Application.GetRealWidth(92),
                    Y = Application.GetRealHeight(49),
                    TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                    TextSize = 14,
                    TextAlignment = TextAlignment.CenterLeft,
                };
                rowFrameLayout.AddChidren(btnMethodText);
                var line2 = new Button()
                {
                    Y = rowFrameLayout.Height - 1,
                    X = Application.GetRealWidth(81),
                    Width = Application.GetRealWidth(965),
                    Height = 1,
                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
                };
                rowFrameLayout.AddChidren(line2);
                if (i == count)
                {
                    line2.Visible = false;
                }
                #endregion
                #region 数据处理
                EventHandler<MouseEventArgs> hander = (sender, e) =>
                {
                    if (!btnAllMethod.IsSelected)
                    {
                        if (oldbutton != null)
                        {
                            oldbutton.IsSelected = false;
                        }
                        if (oldbuttonText != null)
                        {
                            oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3;
                        }
                        oldbutton = btnAllMethod;
                        oldbuttonText = btnMethodText;
                        doorLock.ReSave();
                        btnAllMethod.IsSelected = true;
                        oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                        oldbuttonText.IsBold = true;
                        doorLock.currentUserDisplayMethod = btnMethodText.Text;
                        TypeRefresh(doorLock);
                    }
                    dialog.Close();
                };
                rowFrameLayout.MouseUpEventHandler += hander;
                btnAllMethod.MouseUpEventHandler += hander;
                btnMethodText.MouseUpEventHandler += hander;
                DisplayAllUnlockMethod(doorLock, i, btnAllMethod, btnMethodText);
                if (string.IsNullOrEmpty(doorLock.currentUserDisplayMethod) && i == 0)
                {
                    CurrentSelectUnlockMethod(btnAllMethod, btnMethodText, oldbutton, oldbuttonText);
                }
                if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.AllMethod) && i == 0)
                {
                    CurrentSelectUnlockMethod(btnAllMethod, btnMethodText, oldbutton, oldbuttonText);
                }
                if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.PasswordUnlock) && i == 1)
                {
                    CurrentSelectUnlockMethod(btnAllMethod, btnMethodText, oldbutton, oldbuttonText);
                }
                if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.FingerprintUnlock) && i == 2)
                {
                    CurrentSelectUnlockMethod(btnAllMethod, btnMethodText, oldbutton, oldbuttonText);
                }
                if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock) && i == 3)
                {
                    CurrentSelectUnlockMethod(btnAllMethod, btnMethodText, oldbutton, oldbuttonText);
                }
                if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.FaceIDUnlock) && i == 4)
                {
                    CurrentSelectUnlockMethod(btnAllMethod, btnMethodText, oldbutton, oldbuttonText);
                }
                if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.CalmFingerprintUnlock) && i == 5)
                {
                    CurrentSelectUnlockMethod(btnAllMethod, btnMethodText, oldbutton, oldbuttonText);
                }
                #endregion
            }
        }
        /// <summary>
        /// 当前门锁支持的开锁类型个数
        /// </summary>
        /// <param name="doorLock"></param>
        /// <returns></returns>
        public int GetSupportType(ZigBee.Device.DoorLock doorLock)
        {
            int count = 0;
            var listDevice = Common.LocalDevice.Current.GetDevicesByMac(doorLock.DeviceAddr);
            var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(listDevice);
            if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.IntelligentLocks_AT1F)
            {
                //AT1F有密码,感应卡,faceID
                count = 3;
            }
            else if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.IntelligentLocks_AT1T)
            {
                //AT1T有密码,指纹,感应卡
                count = 3;
            }
            else if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.IntelligentLocks_AT1TF)
            {
                //AT1TF有密码,指纹,感应卡,faceID
                count = 4;
            }
            else if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.IntelligentLocks_HAT1B)
            {
                //HAT1B密码、静脉纹、刷卡
                count = 3;
            }
            else if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.IntelligentLocks_HAT1T)
            {
                //HAT1T密码、指纹、刷卡
                count = 3;
            }
            else
            {
                //只有密码,指纹,感应卡
                count = 3;
            }
            return count;
        }
        /// <summary>
        /// 类型区分
        /// </summary>
        public void TypeRefresh(ZigBee.Device.DoorLock doorLock)
        {
            if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.PasswordUnlock))
            {
                UndateUnlockMethodAction?.Invoke(0);
            }
            else if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock))
            {
                UndateUnlockMethodAction?.Invoke(3);
            }
            else if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.CalmFingerprintUnlock))
            {
                UndateUnlockMethodAction?.Invoke(13);
            }
            else if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.FaceIDUnlock))
            {
                UndateUnlockMethodAction?.Invoke(14);
            }
            else if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.FingerprintUnlock))
            {
                UndateUnlockMethodAction?.Invoke(15);
            }
            else
            {
                UndateUnlockMethodAction?.Invoke(-1);
            }
            //每次调完清空
            UndateUnlockMethodAction = null;
        }
        #region ■ 一般方法___________________________