陈嘉乐
2020-05-18 5da99fed2eb0d08b6338064da5f998891252c7b8
ZigbeeApp/Shared/Phone/Category/Controls/DeviceRow/Base/DeviceRowCommon.cs
@@ -61,8 +61,7 @@
        /// <summary>
        /// 未分配界面的设备选择控件
        /// </summary>
        /// <param name="i_ChidrenYaxis">子控件Y轴偏移量(真实值,有些界面需要这种特殊操作)</param>
        public DeviceRowCommon(int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
        public DeviceRowCommon()
        {
            this.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft);
            this.Width = Application.GetRealWidth(1022);
@@ -77,11 +76,11 @@
            this.device = i_device;
            //设备图标背景控件
            this.frameIconBackGroud = new FrameLayout();
            frameIconBackGroud.Height = Application.GetMinRealAverage(112);
            frameIconBackGroud.Width = Application.GetMinRealAverage(112);
            frameIconBackGroud.Height = this.GetPictrueRealSize(112);
            frameIconBackGroud.Width = this.GetPictrueRealSize(112);
            frameIconBackGroud.Gravity = Gravity.CenterVertical;
            frameIconBackGroud.X = Application.GetRealWidth(46);
            frameIconBackGroud.Radius = (uint)Application.GetMinRealAverage(112 / 2);
            frameIconBackGroud.Radius = (uint)this.GetPictrueRealSize(112 / 2);
            frameIconBackGroud.BackgroundColor = Common.ZigbeeColor.Current.GXCGrayBackgroundColor;
            this.frameTable.AddChidren(frameIconBackGroud, ChidrenBindMode.NotBind);
            if (chidrenYaxis != 0)
@@ -100,7 +99,8 @@
            //设备名字
            this.btnDeviceName = new NormalViewControl(600, 60, true);
            btnDeviceName.X = Application.GetRealWidth(181);
            btnDeviceName.Y = Application.GetRealHeight(16) + this.chidrenYaxis;
            //当指定实际坐标时,这里需要的偏移量为2倍
            btnDeviceName.Y = Application.GetRealHeight(16) + this.chidrenYaxis * 2;
            btnDeviceName.Text = Common.LocalDevice.Current.GetDeviceEpointName(i_device);
            btnDeviceName.SelectedTextColor = Common.ZigbeeColor.Current.GXCTextSelectedColor;
            this.frameTable.AddChidren(btnDeviceName, ChidrenBindMode.BindEventOnly);
@@ -109,6 +109,7 @@
            {
                //没有状态功能,则把设备名字控件中
                this.btnDeviceName.Gravity = Gravity.CenterVertical;
                btnDeviceName.Y += this.chidrenYaxis;
            }
            //拥有状态功能
            if (this.hadStatuFunction == true)
@@ -116,7 +117,8 @@
                //状态
                this.btnStatu = new NormalViewControl(600, 50, true);
                btnStatu.X = Application.GetRealWidth(181);
                btnStatu.Y = Application.GetRealHeight(70) + this.chidrenYaxis;
                //当指定实际坐标时,这里需要的偏移量为2倍
                btnStatu.Y = Application.GetRealHeight(70) + this.chidrenYaxis * 2;
                btnStatu.TextSize = 10;
                btnStatu.TextColor = UserCenterColor.Current.TextGrayColor1;
                this.frameTable.AddChidren(btnStatu, ChidrenBindMode.BindEventOnly);
@@ -141,32 +143,28 @@
                var btnEditor = this.AddEditorControl();
                btnEditor.ButtonClickEvent += (sender, e) =>
                {
                    //关闭左滑菜单
                    this.HideMenu();
                    var detailInfo = new Device.CommonForm.DeviceDetailInfo { };
                    UserView.HomePage.Instance.AddChidren(detailInfo);
                    UserView.HomePage.Instance.PageIndex += 1;
                    detailInfo.Show(i_device, HdlRoomLogic.Current.CurrentRoom);
                    detailInfo.EditAction += (curDevice, curRoom) =>
                    var detailInfo = new MainPage.DeviceDetailInfoForm();
                    detailInfo.AddForm(i_device, HdlRoomLogic.Current.CurrentRoom);
                    detailInfo.FormCloseEvent += (curDevice, curRoom) =>
                    {
                        if (HdlRoomLogic.Current.CurrentRoom.IsLove == true)
                        {
                            //当前是喜爱房间时
                            if (HdlRoomLogic.Current.IsCollectInRoom(this.device) == false)
                            {
                                //房间改变了
                                this.RemoveFromParent();
                                //回调控件被移除的事件
                                this.RowNeedRemoveEvent?.Invoke();
                                //房间改变了
                                this.RemoveFromParent();
                                return;
                            }
                        }
                        else if (HdlRoomLogic.Current.CurrentRoom.Id != curRoom.Id)
                        {
                            //房间改变了
                            this.RemoveFromParent();
                            //回调控件被移除的事件
                            this.RowNeedRemoveEvent?.Invoke();
                            //房间改变了
                            this.RemoveFromParent();
                            return;
                        }
                        //刷新控件状态
@@ -189,9 +187,9 @@
                            //从房间中移除
                            HdlRoomLogic.Current.DeleteDevice(i_device);
                        }
                        this.RemoveFromParent();
                        //回调控件被移除的事件
                        this.RowNeedRemoveEvent?.Invoke();
                        this.RemoveFromParent();
                    };
                };
            }
@@ -233,6 +231,12 @@
            this.btnDeviceName.Text = Common.LocalDevice.Current.GetDeviceEpointName(i_device);
            //检测设备是否是打开状态
            bool isOpen = this.CheckIsOpenStatu(i_device);
            if (this.isHadOpenSwitch == true && i_device.HadReadDeviceStatu == false)
            {
                //如果这个卡片有开关功能,并且网关还没有回复之前,默认是关闭状态
                //等待网关回复后会重新刷新,不然一直是关闭状态
                isOpen = false;
            }
            this.SetRowOpenStatu(isOpen);
        }
@@ -326,7 +330,7 @@
            //如果这个函数被重写的话,则代表这个设备有开关功能
            this.isHadOpenSwitch = false;
            //默认用在线状态来判断
            return i_device.IsOnline == 1;
            return Common.LocalDevice.Current.CheckDeviceIsOnline(i_device);
        }
@@ -346,6 +350,8 @@
                //已经取消的收藏
                if (HdlRoomLogic.Current.IsCollectInRoom(device) == false)
                {
                    //回调控件被移除的事件
                    this.RowNeedRemoveEvent?.Invoke();
                    //移除这个控件
                    this.RemoveFromParent();
                    return;
@@ -357,6 +363,8 @@
                var nowRoom = HdlRoomLogic.Current.GetRoomByDevice(device);
                if (nowRoom == null || nowRoom.Id != HdlRoomLogic.Current.CurrentRoom.Id)
                {
                    //回调控件被移除的事件
                    this.RowNeedRemoveEvent?.Invoke();
                    //移除这个控件
                    this.RemoveFromParent();
                    return;