gxc
2019-12-25 944b87b6bcccb095cd73f13f4410fb20faf48f74
ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs
old mode 100755 new mode 100644
@@ -6,9 +6,12 @@
{
    public class UserDoorLockPage : DoorLockCommonLayout, ZigBee.Common.IStatus
    {
        public UserDoorLockPage(ZigBee.Device.DoorLock doorLock, Shared.Phone.UserCenter.MemberInfoRes accountObj)
        public UserDoorLockPage(Shared.Common.Room room, DeviceUI doorLock)
        {
            this.doorLock = doorLock;
            this.doorLock = doorLock.CommonDevice as ZigBee.Device.DoorLock;
            currentRoom = room;
            deviceUI = doorLock;
            BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor;
            ZigBee.Device.ZbGateway.StatusList.Add(this);
        }
@@ -16,15 +19,18 @@
        #region ◆ 变量申明__________________________
        ZigBee.Device.DoorLock doorLock;
        FrameLayout bottomFrameLayout;
        Shared.Common.Room currentRoom;
        DeviceUI deviceUI;
        Action action;
        Button btnDoorLockTitle;
        #endregion
        /// <summary>
        /// UI显示
        /// UI显示
        /// </summary>
        public void Show()
        {
            this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.DoorLock));
            this.TopFrameLayout(this, "");
            EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
            {
@@ -32,40 +38,70 @@
            };
            this.btnBack.MouseUpEventHandler += eHandlerBack;
            this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
            this.MidFrameLayout(this);
            this.MidFrameLayout(this);
            var btnShare = new Button
            {
                X = Application.GetRealWidth(850),
                X = Application.GetRealWidth(850 - 116),
                Height = Application.GetRealHeight(69),
                Width = Application.GetRealWidth(69),
                UnSelectedImagePath = "DoorLock/ShareIcon.png",
            };
            this.titleFrameLayout.AddChidren(btnShare);
            var btnFuncSetFrameLayout = new FrameLayout
            {
                X = Application.GetRealWidth(850 - 116),
                Height = Application.GetRealHeight(69),
                Width = Application.GetRealWidth(69 * 2 + 58),
            };
            this.titleFrameLayout.AddChidren(btnFuncSetFrameLayout);
            var btnFuncSet = new Button
            {
                X = Application.GetRealWidth(953),
                X = Application.GetRealWidth(103),
                Height = Application.GetRealHeight(69),
                Width = Application.GetRealWidth(69),
                UnSelectedImagePath = "DoorLock/SettingIcon.png",
            };
            this.titleFrameLayout.AddChidren(btnFuncSet);
            btnFuncSetFrameLayout.AddChidren(btnFuncSet);
            btnFuncSet.MouseDownEventHandler += (sender, e) =>
            {
                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 (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))
                        {
                            btnDoorLockTitle.Text = deviceRename;
                            //改房间
                            Shared.Common.Room.CurrentRoom.ChangedRoom(deviceUI.CommonDevice, currentRoom.Id);
                            deviceUI.CommonDevice.ReSave();
                        }
                    };
                }
                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))
                        {
                            btnDoorLockTitle.Text = deviceRename;
                        }
                    };
                }
            };
            btnShare.MouseDownEventHandler += (sender, e) =>
            {
                var doorLock = new ZigBee.Device.DoorLock();
                var memberManagement = new Shared.Phone.UserCenter.DoorLock.MemberManagement(doorLock);
                Shared.Phone.UserView.HomePage.Instance.AddChidren(memberManagement);
                Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                memberManagement.Show();
            };
            MidFrameLayoutContent();
@@ -84,14 +120,14 @@
            };
            this.midFrameLayout.AddChidren(midTopFrameLayout);
            var btnDoorLockTitle = new Button()
            btnDoorLockTitle = new Button()
            {
                Width = Application.GetRealWidth(250),
                Height = Application.GetRealHeight(60),
                X = Application.GetRealWidth(372),
                Y = Application.GetRealHeight(46),
                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                Text = Language.StringByID(R.MyInternationalizationString.SmartDoorLock),
                Text = string.IsNullOrEmpty(doorLock.DeviceName) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : doorLock.DeviceName,
                TextSize = 15,
                TextAlignment = TextAlignment.Center,
            };
@@ -108,11 +144,9 @@
            midTopFrameLayout.AddChidren(btnRecord);
            btnRecord.MouseDownEventHandler += (sender, e) =>
            {
                var doorLock = new ZigBee.Device.DoorLock();
                var doorLockRecord = new Shared.Phone.UserCenter.DoorLock.HistoryRecordPage(doorLock);
                Shared.Phone.UserView.HomePage.Instance.AddChidren(doorLockRecord);
                Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                doorLockRecord.Show();
                //历史记录 ----   stan
                var form = new DeviceDoorLock.DoorLockHistoryLogForm();
                form.AddForm(this.doorLock.DeviceAddr);
            };
            var btnCollect = new Button()
@@ -121,11 +155,30 @@
                Height = Application.GetRealHeight(69),
                X = Application.GetRealWidth(850),
                Y = Application.GetRealHeight(46),
                UnSelectedImagePath = "DoorLock/FavoriteIcon.png",
                UnSelectedImagePath = "Item/Collection.png",
                SelectedImagePath = "Item/CollectionSelected.png"
            };
            midTopFrameLayout.AddChidren(btnCollect);
            midTopFrameLayout.AddChidren(btnCollect);
            var de = Shared.Common.Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == deviceUI.FileName);
            if (de == null)
            {
                btnCollect.IsSelected = false;
            }
            else
            {
                btnCollect.IsSelected = true;
            }
            btnCollect.MouseDownEventHandler += (sender, e) =>
            {
                btnCollect.IsSelected = !btnCollect.IsSelected;
                if (btnCollect.IsSelected)
                {
                    Shared.Common.Room.CurrentRoom.GetLoveRoom().AddDevice(deviceUI.FileName);//收藏
                }
                else
                {
                    Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(deviceUI.FileName); //取消收藏
                }
            };
            var btnCurrentText = new Button()
@@ -167,7 +220,7 @@
            var btnFrameLayout = new FrameLayout()
            {
                Width = Application.GetRealWidth(420 - 46),//639-35
                Width = Application.GetRealWidth(420 - 46),
                Height = Application.GetRealHeight(446),
                X = btnDoorLockPic.Right,
                Y = Application.GetRealHeight(354),
@@ -258,7 +311,7 @@
                Height = Application.GetRealHeight(49),
                X = Application.GetRealWidth(150),
                Y = Application.GetRealHeight(46),
                Text = "客厅",
                Text = currentRoom.Name,
                TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
                TextSize = 12,
                TextAlignment = TextAlignment.CenterLeft,
@@ -268,13 +321,55 @@
            EventHandler<MouseEventArgs> hander1 = async (sender, e) =>
             {
                 RemoteUnlockRequest(doorLock, action, progressButton, btnDoorLockPic, btnStatus);
                 if (UserCenterResourse.UserInfo.AuthorityNo != 1)
                 {
                     var result = await Shared.Phone.UserCenter.DoorLock.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);
                         if (result1 == true)
                         {
                             RemoteUnlockRequest(doorLock, action, progressButton, btnDoorLockPic, btnStatus, btnDoorLockTitle);
                             devicNameSecAction += (deviceRename) =>
                             {
                                 if (!string.IsNullOrEmpty(deviceRename))
                                 {
                                     btnDoorLockTitle.Text = deviceRename;
                                     //改房间
                                     Shared.Common.Room.CurrentRoom.ChangedRoom(deviceUI.CommonDevice, currentRoom.Id);
                                     deviceUI.CommonDevice.ReSave();
                                 }
                             };
                         }
                         else
                         {
                             new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.NoAccess), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show(Common.CommonPage.Instance);
                         }
                     }
                     else
                     {
                         new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show(Common.CommonPage.Instance);
                     }
                 }
                 else
                 {
                     RemoteUnlockRequest(doorLock, action, progressButton, btnDoorLockPic, btnStatus, btnDoorLockTitle);
                     devicNameSecAction += (deviceRename) =>
                     {
                         if (!string.IsNullOrEmpty(deviceRename))
                         {
                             btnDoorLockTitle.Text = deviceRename;
                             //改房间
                             Shared.Common.Room.CurrentRoom.ChangedRoom(deviceUI.CommonDevice, currentRoom.Id);
                             deviceUI.CommonDevice.ReSave();
                         }
                     };
                 }
             };
            openFrameLayout.MouseUpEventHandler += hander1;
            btnDoorOpenPic.MouseUpEventHandler += hander1;
            EventHandler<MouseEventArgs> hander2 = (sender, e) =>
            {
                //new Tip() { MaxWidth = 150, Text = "不支持远程关锁", Direction = AMPopTipDirection.Down, CloseTime = 2 }.Show(openFrameLayout);
                btnDoorLockPic.IsSelected = false;
                progressButton.Y = Application.GetRealHeight(347);
            };