黄学彪
2020-04-13 3793a9a38ac6c4c4111c2bba3a35a71c30601e82
ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs
@@ -14,12 +14,14 @@
        /// </summary>
        /// <param name="room"></param>
        /// <param name="doorLock"></param>
        public UserDoorLockPage(Shared.Common.Room room, CommonDevice doorLock)
        public UserDoorLockPage(Room room, CommonDevice doorLock)
        {
            //徐梅的门锁界面打开(网关全局接收时使用)
            ControlCommonResourse.IsDoorLockPageOpen = true;
            this.doorLock = doorLock as ZigBee.Device.DoorLock;
            currentRoom = room;
            deviceUI = doorLock;
            BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor;
            BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor;
            ZbGateway.StatusList.Add(this);
        }
@@ -168,6 +170,14 @@
        ///  当前音量
        /// </summary>
        int currentVolume = -1;
        /// <summary>
        /// waitClickTime
        /// </summary>
        DateTime waitClickTime = DateTime.MaxValue;
        /// <summary>
        /// IsClick
        /// </summary>
        bool IsClick = true;
        #endregion
        /// <summary>
@@ -197,8 +207,8 @@
            btnFuncSet = new Button
            {
                X = Application.GetRealWidth(103),
                Height = Application.GetRealHeight(69),
                Width = Application.GetRealWidth(69),
                Height = Application.GetMinReal(69),
                Width = Application.GetMinReal(69),
                UnSelectedImagePath = "DoorLock/SettingIcon.png",
            };
            btnFuncSetFrameLayout.AddChidren(btnFuncSet);
@@ -259,8 +269,8 @@
            midTopFrameLayout.AddChidren(btnRecordFrameLayout);
            btnRecord = new Button()
            {
                Width = Application.GetRealWidth(69),
                Height = Application.GetRealHeight(69),
                Width = Application.GetMinReal(69),
                Height = Application.GetMinReal(69),
                X = Application.GetRealWidth(46),
                Y = Application.GetRealHeight(46),
                UnSelectedImagePath = "DoorLock/RecordIcon.png",
@@ -277,8 +287,8 @@
            midTopFrameLayout.AddChidren(btnCollectFrameLayout);
            btnCollect = new Button()
            {
                Width = Application.GetRealWidth(69),
                Height = Application.GetRealHeight(69),
                Width = Application.GetMinReal(69),
                Height = Application.GetMinReal(69),
                X = Application.GetRealWidth(15),
                Y = Application.GetRealHeight(46),
                UnSelectedImagePath = "Item/Collection.png",
@@ -319,8 +329,8 @@
            //门锁开/关图片
            btnDoorLockPic = new Button()
            {
                Width = Application.GetRealWidth(383),
                Height = Application.GetRealHeight(343),
                Width = Application.GetMinReal(383),
                Height = Application.GetMinReal(343),
                X = Application.GetRealWidth(161),
                Y = Application.GetRealHeight(415),
                UnSelectedImagePath = "DoorLock/DoorLockPicClose.png",
@@ -368,8 +378,8 @@
            progressButton = new Button()
            {
                Width = Application.GetRealWidth(84),//639-35
                Height = Application.GetRealHeight(93),
                Width = Application.GetMinReal(84),//639-35
                Height = Application.GetMinReal(93),
                X = Application.GetRealWidth(58),
                Y = Application.GetRealHeight(347),
                UnSelectedImagePath = "DoorLock/UnLockButton.png",
@@ -378,8 +388,8 @@
            btnDoorOpenPic = new Button()
            {
                Width = Application.GetRealWidth(81),
                Height = Application.GetRealHeight(81),
                Width = Application.GetMinReal(81),
                Height = Application.GetMinReal(81),
                X = Application.GetRealWidth(164),
                Y = Application.GetRealHeight(6),
                UnSelectedImagePath = "DoorLock/DoorLockOpen.png",
@@ -388,8 +398,8 @@
            btnDoorClosePic = new Button()
            {
                Width = Application.GetRealWidth(81),
                Height = Application.GetRealHeight(81),
                Width = Application.GetMinReal(81),
                Height = Application.GetMinReal(81),
                X = Application.GetRealWidth(164),
                Y = Application.GetRealHeight(117),
                UnSelectedImagePath = "DoorLock/DoorLockClose.png",
@@ -400,8 +410,8 @@
            //电量
            btnPower = new Button()
            {
                Width = Application.GetRealWidth(81),
                Height = Application.GetRealHeight(81),
                Width = Application.GetMinReal(81),
                Height = Application.GetMinReal(81),
                X = Application.GetRealWidth(253),
                Y = Application.GetRealHeight(994),
                UnSelectedImagePath = "DoorLock/PowerOffline.png",
@@ -419,8 +429,8 @@
            midTopFrameLayout.AddChidren(btnVolumeFrameLayout);
            btnVolume = new Button()
            {
                Width = Application.GetRealWidth(81),
                Height = Application.GetRealHeight(81),
                Width = Application.GetMinReal(81),
                Height = Application.GetMinReal(81),
                X = Application.GetRealWidth(40),
                Y = Application.GetRealHeight(40),
                UnSelectedImagePath = "DoorLock/VolumeIcon.png",
@@ -439,8 +449,8 @@
            midTopFrameLayout.AddChidren(btnNormallyOpenFrameLayout);
            btnNormallyOpen = new Button()
            {
                Width = Application.GetRealWidth(81),
                Height = Application.GetRealHeight(81),
                Width = Application.GetMinReal(81),
                Height = Application.GetMinReal(81),
                X = Application.GetRealWidth(40),
                Y = Application.GetRealHeight(40),
                UnSelectedImagePath = "DoorLock/NormallyOpen.png",
@@ -472,8 +482,8 @@
            #region 当前房间
            var btnCurrentRoomPic = new Button()
            {
                Width = Application.GetRealWidth(81),
                Height = Application.GetRealHeight(81),
                Width = Application.GetMinReal(81),
                Height = Application.GetMinReal(81),
                X = Application.GetRealWidth(58),
                Y = Application.GetRealHeight(29),
                UnSelectedImagePath = "DoorLock/RoomPic.png",
@@ -590,22 +600,27 @@
            if (typeTag == "DoorLockProgrammingEventNotificationCommand" && tempDevice != null)
            {
                var tempDoor = (ZigBee.Device.DoorLock)tempDevice;
                if (tempDoor.doorLockOperatingEventNotificationCommand != null)
                if (tempDevice.DeviceEpoint == doorLock.DeviceEpoint
                                     && tempDevice.DeviceAddr == doorLock.DeviceAddr)
                {
                    //非主人不弹这个窗口
                    if (UserCenterResourse.UserInfo.AuthorityNo != 1)
                    {
                        return;
                    }
                    //非管理员的密码,不弹这个窗口
                    if (tempDoor.doorLockOperatingEventNotificationCommand.UserID > 9)
                    {
                        return;
                    }
                    if (canOpenNormallyMode)
                    if (tempDoor.doorLockOperatingEventNotificationCommand != null)
                    {
                        Application.RunOnMainThread(() => { NomallyOpenModeInvalidDialog(true); });
                        //非主人不弹这个窗口
                        if (UserCenterResourse.UserInfo.AuthorityNo != 1)
                        {
                            return;
                        }
                        string key = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
                        if (doorLock.IsDoorLockNormallyMode.ContainsKey(key))
                        {
                            if (doorLock.IsDoorLockNormallyMode[key] == true)
                            {
                                if (canOpenNormallyMode)
                                {
                                    Application.RunOnMainThread(() => { NomallyOpenModeInvalidDialog(true); });
                                }
                            }
                        }
                    }
                }
            }
@@ -625,7 +640,6 @@
                                Application.RunOnMainThread(() =>
                                {
                                    currentPower = dataReport.AttriButeData;
                                    waitGetDoorLockPower = DateTime.MaxValue;
                                    UpdatePower();
                                });
                            }
@@ -678,7 +692,7 @@
                            }
                            NormallyOpenModeValue(tempRes);
                            HaveLogicNormallyOpenMode = await Shared.Phone.Device.Logic.SkipView.Exist();
                            Application.RunOnMainThread(() =>
                            {
                                UpdateNomallyOpenStatus();
@@ -772,10 +786,13 @@
            //设置
            EventHandler<MouseEventArgs> btnFuncSetHander = (sender, e) =>
            {
                var functionSetting = new Shared.Phone.UserCenter.DoorLock.FunctionSetting(doorLock);
                //打开其他界面时前移除
                RemoveFromParent();
                var functionSetting = new Shared.Phone.UserCenter.DoorLock.FunctionSetting(currentRoom, doorLock);
                Shared.Phone.UserView.HomePage.Instance.AddChidren(functionSetting);
                Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                functionSetting.Show();
                functionSetting.devicNameAction += (deviceRename) =>
                {
                    if (!string.IsNullOrEmpty(deviceRename))
@@ -816,15 +833,11 @@
                btnCollect.IsSelected = !btnCollect.IsSelected;
                if (btnCollect.IsSelected)
                {
                    HdlRoomLogic.Current.AddLoveDevice(deviceUI);//收藏
                    //Test
                    HaveLogicNormallyOpenMode = true;
                    HdlRoomLogic.Current.AddLoveDevice(deviceUI);//收藏
                }
                else
                {
                    HdlRoomLogic.Current.DeleteLoveDevice(deviceUI);//取消收藏
                    //Test
                    HaveLogicNormallyOpenMode = false;
                    HdlRoomLogic.Current.DeleteLoveDevice(deviceUI);//取消收藏
                }
            };
            btnCollectFrameLayout.MouseDownEventHandler += handerCollect;
@@ -833,13 +846,30 @@
            //开锁事件
            EventHandler<MouseEventArgs> hander1 = async (sender, e) =>
            {
                //常开模式下,点击开锁无效
                if (btnNormallyOpen.IsSelected == true)
                {
                    this.ShowMassage(ShowMsgType.Remind, "当前状态为常开模式");
                    return;
                string key = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
                if (doorLock.IsDoorLockNormallyMode.ContainsKey(key))
                {
                    if (doorLock.IsDoorLockNormallyMode[key] == true)
                    {
                        if (canOpenNormallyMode)
                        {
                            NomallyOpenModeInvalidDialog(false);
                        }
                        else
                        {
                            OpenDoorLockHandle(progressButton, btnDoorLockPic, btnStatus);
                        }
                    }
                    else
                    {
                        OpenDoorLockHandle(progressButton, btnDoorLockPic, btnStatus);
                    }
                }
                OpenDoorLockHandle(progressButton, btnDoorLockPic, btnStatus);
                else
                {
                    OpenDoorLockHandle(progressButton, btnDoorLockPic, btnStatus);
                }
            };
            openFrameLayout.MouseUpEventHandler += hander1;
            btnDoorOpenPic.MouseUpEventHandler += hander1;
@@ -883,7 +913,6 @@
            EventHandler<MouseEventArgs> handerNormallyOpen = (sender, e) =>
            {
                NomallyOpenDialog();
            };
            btnNormallyOpenFrameLayout.MouseUpEventHandler += handerNormallyOpen;
            btnNormallyOpen.MouseUpEventHandler += handerNormallyOpen;
@@ -905,15 +934,15 @@
            {
                btnPower.UnSelectedImagePath = "DoorLock/Power40.png";
            }
            else if (currentPower <= 60 && currentPower > 40 || currentPower == 60)
            else if (currentPower <= 60 && currentPower > 40)
            {
                btnPower.UnSelectedImagePath = "DoorLock/Power60.png";
            }
            else if (currentPower <= 80 && currentPower >= 60)
            else if (currentPower <= 80 && currentPower > 60)
            {
                btnPower.UnSelectedImagePath = "DoorLock/Power80.png";
            }
            else if (currentPower <= 100 && currentPower >= 80)
            else if (currentPower <= 100 && currentPower > 80)
            {
                btnPower.UnSelectedImagePath = "DoorLock/Power100.png";
            }
@@ -1025,7 +1054,7 @@
            {
                if (UserCenterResourse.UserInfo.AuthorityNo != 1)
                {
                    this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.NoAccess));
                    this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.OnlyMasterOperate));
                    return;
                }
@@ -1060,6 +1089,9 @@
                        }
                        else
                        {
                            //添加App开启常开模式的历史记录
                            HdlDeviceDoorLockLogic.Current.AddDoorHistoryLog(this.doorLock, 9001, string.Empty);
                            //每次重新设置常开,默认时间都是12小时
                            DoorLockCommonInfo.NormallyOpenModeInvalidTime = 12;
                            NormallyOpenModeValue(true);
@@ -1072,11 +1104,12 @@
                            var alertNomallyModeIsTurnOn = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.DoorLockLogic, msgNomallyModeIsTurnOn, doorLockInValidSetting);
                            alertNomallyModeIsTurnOn.Show();
                            //点击自动化
                            alertNomallyModeIsTurnOn.LogicClickEvent += () =>
                            {
                                //自动化
                                Shared.Phone.Device.Logic.SkipView.SkipAddLogic(2);
                                //逻辑调用前记得移除
                                ZbGateway.StatusList.Remove(this);
                                Shared.Phone.Device.Logic.SkipView.SkipAddLogic(2, doorLock);
                            };
                            alertNomallyModeIsTurnOn.InvalidClickEvent += async () =>
                            {
@@ -1100,7 +1133,7 @@
        {
            if (UserCenterResourse.UserInfo.AuthorityNo != 1)
            {
                //this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.NoAccess));
                this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.OnlyMasterOperate));
                return;
            }
            string msg = Language.StringByID(R.MyInternationalizationString.NomallyModeIsCanceled).Replace("{0}", "\r\n");
@@ -1168,7 +1201,7 @@
                //确认取消常开
                if (IsFromReport)
                {
                    NormallyOpenModeValue(true);
                    NormallyOpenModeValue(false);
                    UpdateNomallyOpenStatus();
                }
                else
@@ -1188,13 +1221,15 @@
                        return;
                    }
                    else
                    {
                    {
                        //添加App开启常开模式的历史记录
                        HdlDeviceDoorLockLogic.Current.AddDoorHistoryLog(this.doorLock, 9002, string.Empty);
                        NormallyOpenModeValue(false);
                        UpdateNomallyOpenStatus();
                        string msg2 = Language.StringByID(R.MyInternationalizationString.CloseNormallyOpenModeSuccess);
                        this.ShowTipMsg(msg2);
                        Shared.Phone.Device.Logic.SkipView.LockCloseLogic(doorLock);
                        //
                    }
                }
            };
@@ -1228,8 +1263,7 @@
                }
                var temp = int.Parse(obj);
                DoorLockCommonInfo.NormallyOpenModeInvalidTime = temp;
                Shared.Phone.Device.Logic.SkipView.LockAddModifyLogic(DoorLockCommonInfo.NormallyOpenModeInvalidTime,doorLock);
                //调用自动化接口设置失效时间
                Shared.Phone.Device.Logic.SkipView.LockAddModifyLogic(DoorLockCommonInfo.NormallyOpenModeInvalidTime, doorLock);
            };
        }
        /// <summary>
@@ -1274,13 +1308,13 @@
            btnDoorOpenPic.Enable = false;
            if (UserCenterResourse.UserInfo.AuthorityNo != 1)
            {
                var result = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid);
                var result = await DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid);
                if (result == false)
                {
                    var result1 = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockUnlockAccess(doorLock, Shared.Common.Config.Instance.Guid);
                    var result1 = await DoorLockCommonInfo.GetDoorLockUnlockAccess(doorLock, Shared.Common.Config.Instance.Guid);
                    if (result1 == true)
                    {
                        RemoteUnlockRequest(doorLock, action, progressButton, btnDoorLockPic, btnStatus, btnDoorLockTitle);
                        RemoteUnlockRequest(currentRoom, deviceUI, action, progressButton, btnDoorLockPic, btnStatus, btnDoorLockTitle);
                        devicNameSecAction += (deviceRename) =>
                        {
                            if (!string.IsNullOrEmpty(deviceRename))
@@ -1310,7 +1344,7 @@
            }
            else
            {
                RemoteUnlockRequest(doorLock, action, progressButton, btnDoorLockPic, btnStatus, btnDoorLockTitle);
                RemoteUnlockRequest(currentRoom, deviceUI, action, progressButton, btnDoorLockPic, btnStatus, btnDoorLockTitle);
                devicNameSecAction += (deviceRename) =>
                {
                    if (!string.IsNullOrEmpty(deviceRename))
@@ -1333,6 +1367,8 @@
        /// </summary>
        public override void RemoveFromParent()
        {
            //徐梅的门锁界面关闭(网关全局接收时使用)
            ControlCommonResourse.IsDoorLockPageOpen = false;
            if (IsDrawerLockMode)
            {
                CommonPage.Instance.IsDrawerLockMode = false;