陈嘉乐
2020-05-19 0e0584b87851c56745bf73b1a961b80613dd0721
ZigbeeApp/Shared/Phone/Category/CategoryMainForm.cs
@@ -131,7 +131,7 @@
            //应该是body吧
            this.bodyFrameLayout = new FrameLayout();
            bodyFrameLayout.Y = topFrameLayout.Bottom;
            bodyFrameLayout.Height = Application.GetRealHeight(1549);
            bodyFrameLayout.Height = this.Height - topFrameLayout.Bottom;
            bodyFrameLayout.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor;
            this.AddChidren(bodyFrameLayout);
@@ -162,7 +162,7 @@
                    floors.FloorAction += (floorId) =>
                    {
                        btnFloorName.Text = Config.Instance.Home.GetFloorNameById(floorId);
                        HdlRoomLogic.Current.CurrentRoom = HdlRoomLogic.Current.GetLoveRoom();
                        HdlRoomLogic.Current.NowCategoryRoom = HdlRoomLogic.Current.GetLoveRoom();
                        //刷新bodyView
                        this.RefreshBodyView();
                    };
@@ -182,7 +182,7 @@
            //目前不知道郭雪城的这个具体放在哪个的位置
            this.functionSceneAutoBodyView = new FrameLayout();
            functionSceneAutoBodyView.Y = frameSwitchBack.Bottom;
            functionSceneAutoBodyView.Height = Application.GetRealHeight(1423);
            functionSceneAutoBodyView.Height = bodyFrameLayout.Height - frameSwitchBack.Bottom;
            bodyFrameLayout.AddChidren(functionSceneAutoBodyView);
            //场景,功能,自动化的切换控件
@@ -276,16 +276,21 @@
        {
            //当前楼层的全部房间
            var lisrRoom = HdlRoomLogic.Current.GetRoomsByCurrentFloorIdAppendLoveRoom();
            if (HdlRoomLogic.Current.NowCategoryRoom == null)
            {
                //设置第一个为初始房间
                HdlRoomLogic.Current.NowCategoryRoom = lisrRoom[0];
            }
            //房间菜单控件
            var roomSwitchContr = new RoomDeviceGroupMenuControl(lisrRoom);
            roomSwitchContr.Y = Application.GetRealHeight(-55);
            this.functionSceneAutoBodyView.AddChidren(roomSwitchContr);
            //设置初始值
            roomSwitchContr.SetDefultIndex(HdlRoomLogic.Current.CurrentRoom.Id);
            roomSwitchContr.SetDefultIndex(HdlRoomLogic.Current.NowCategoryRoom.Id);
            //选择事件
            roomSwitchContr.SelectRoomEvent += (selectRoom) =>
            {
                HdlRoomLogic.Current.CurrentRoom = selectRoom;
                HdlRoomLogic.Current.NowCategoryRoom = selectRoom;
                //场景
                if (UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 0)
                {
@@ -334,7 +339,9 @@
            var dicGroupDevice = this.GetAllGroupDevice(room);
            if (dicGroupDevice.Count == 0)
            {
                this.ShowNoFunctionTip();
                //没有功能{0}请在个人中心--设备管理处添加
                string[] arryMsg = Language.StringByID(R.MyInternationalizationString.NoFunction).Split(new string[] { "{0}" }, StringSplitOptions.RemoveEmptyEntries);
                this.ShowNotDataImage(functionSceneBodyView, arryMsg);
                return;
            }
@@ -431,35 +438,6 @@
            }
        }
        /// <summary>
        /// 提示没有功能
        /// </summary>
        private void ShowNoFunctionTip()
        {
            var noFunction = new Button()
            {
                Y = Application.GetRealHeight(320),
                Width = this.GetPictrueRealSize(757),
                Height = this.GetPictrueRealSize(435),
                UnSelectedImagePath = "Item/NoFunction.png",
                Gravity = Gravity.CenterHorizontal
            };
            functionSceneBodyView.AddChidren(noFunction);
            var noFunctionTip = new Button()
            {
                Y = noFunction.Bottom + Application.GetRealHeight(32),
                Height = Application.GetRealHeight(200),
                Width = Application.GetRealWidth(700),
                Gravity = Gravity.CenterHorizontal,
                Text = Language.StringByID(R.MyInternationalizationString.NoFunction).Replace("{\\r\\n}", "\r\n"),
                TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor,
                TextAlignment = TextAlignment.Center,
                IsMoreLines = true
            };
            functionSceneBodyView.AddChidren(noFunctionTip);
        }
        #endregion
        #region ■ 初始化设备列表控件_________________
@@ -529,6 +507,11 @@
                    {
                        cardContr = new Controls.DeviceFreshAirRowControl();
                    }
                    // PM2.5
                    else if (device.Type == DeviceType.PMSensor)
                    {
                        cardContr = new Controls.DevicePmSensorRowControl();
                    }
                    //彩灯(调光器)
                    else if (device.Type == DeviceType.DimmableLight)
                    {
@@ -559,7 +542,7 @@
                    cardContr.chidrenYaxis = listView.rowSpace / 2;
                    //初始化卡片
                    listView.AddChidren(cardContr);
                    cardContr.InitControl(device);
                    cardContr.InitControl(device, HdlRoomLogic.Current.NowCategoryRoom);
                    //控件记录到缓存中
                    this.dicDeviceRowControl[LocalDevice.Current.GetDeviceMainKeys(device)] = cardContr;
                    //加缓存,然后发命令
@@ -610,6 +593,60 @@
        /// <param name="room"></param>
        private void RefreshSceneView(Room room)
        {
            //主人,管理员专用刷新控件
            VerticalListRefreshControl listview1 = null;
            //成员专用不能刷新的控件
            VerticalListControl listview2 = null;
            if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
            {
                //主人,管理员专用刷新控件
                listview1 = new VerticalListRefreshControl();
                functionSceneBodyView.AddChidren(listview1);
                //下拉刷新
                listview1.BeginHeaderRefreshingAction += () =>
                {
                    //如果当前是虚拟住宅,则只给个特效
                    if (Common.Config.Instance.Home.IsVirtually == true)
                    {
                        HdlThreadLogic.Current.RunThread(() =>
                        {
                            System.Threading.Thread.Sleep(1500);
                            HdlThreadLogic.Current.RunMain(() =>
                            {
                                listview1.EndHeaderRefreshing();
                            });
                        });
                        return;
                    }
                    HdlThreadLogic.Current.RunThread(() =>
                    {
                        //从网关刷新场景列表
                        bool result = HdlSceneLogic.Current.RefreshSceneUIList();
                        HdlThreadLogic.Current.RunMain(() =>
                        {
                            listview1.EndHeaderRefreshing();
                            if (result == true)
                            {
                                //在外面清空(特效的问题)
                                this.functionSceneBodyView.RemoveAll();
                                HdlThreadLogic.Current.RunMainInThread(() =>
                                {
                                    //刷新场景分支控件
                                    this.RefreshSceneView(room);
                                });
                            }
                        });
                    });
                };
            }
            else
            {
                //成员专用不能刷新的控件
                listview2 = new VerticalListControl();
                functionSceneBodyView.AddChidren(listview2);
            }
            var listScene = new List<SceneUI>();
            foreach (var sceneId in room.ListSceneId)
            {
@@ -621,26 +658,17 @@
            }
            if (listScene.Count == 0)
            {
                this.ShowNoSceneTip();
                //在滑动控件里面添加一个桌布
                var frameTable = new FrameLayout();
                listview1?.AddChidren(frameTable);
                listview2?.AddChidren(frameTable);
                //没有场景{0}请点击右上角添加
                string[] arryMsg = Language.StringByID(R.MyInternationalizationString.NoScene).Split(new string[] { "{0}" }, StringSplitOptions.RemoveEmptyEntries);
                this.ShowNotDataImage(frameTable, arryMsg);
                return;
            }
            var dicSceneContr = new Dictionary<int, SceneCategoryView>();
            //主人,管理员专用刷新控件
            VerticalListRefreshControl listview1 = null;
            //成员专用不能刷新的控件
            VerticalListControl listview2 = null;
            //if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
            //{
            //    listview1 = new VerticalListRefreshControl();
            //    functionSceneBodyView.AddChidren(listview1);
            //}
            //else
            {
                listview2 = new VerticalListControl();
                functionSceneBodyView.AddChidren(listview2);
            }
            foreach (var scene in listScene)
            {
                //场景卡片控件
@@ -759,36 +787,6 @@
            });
        }
        /// <summary>
        /// 显示没有场景
        /// </summary>
        private void ShowNoSceneTip()
        {
            var noFunction = new Button()
            {
                Y = Application.GetRealHeight(320),
                Width = this.GetPictrueRealSize(757),
                Height = this.GetPictrueRealSize(435),
                UnSelectedImagePath = "Item/NoFunction.png",
                Gravity = Gravity.CenterHorizontal
            };
            functionSceneBodyView.AddChidren(noFunction);
            var noScenceTip = new Button()
            {
                Y = noFunction.Bottom + Application.GetRealHeight(32),
                Height = Application.GetRealHeight(200),
                Width = Application.GetRealWidth(700),
                Gravity = Gravity.CenterHorizontal,
                Text = Language.StringByID(R.MyInternationalizationString.NoScene).Replace("{\\r\\n}", "\r\n"),
                TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor,
                TextAlignment = TextAlignment.Center,
                IsMoreLines = true
            };
            functionSceneBodyView.AddChidren(noScenceTip);
        }
        #endregion
        #region ■ 一般设备状态上报___________________
@@ -809,16 +807,9 @@
                    {
                        //刷新卡片信息
                        var locadevice = LocalDevice.Current.GetDevice(mainKeys);
                        if (report.DeviceStatusReport.CluterID == 513 && report.DeviceStatusReport.AttriBute[0].AttributeId == 28)
                        {
                            //空调是特殊的,它的开关是属性上报来着.已经接收到网关的反馈
                            this.dicDeviceRowControl[mainKeys].SetHadGetResponeResultStatu();
                        }
                        if (report.DeviceStatusReport.CluterID == 514 && report.DeviceStatusReport.AttriBute[0].AttributeId == 0)
                        {
                            //新风是特殊的,它的开关是属性上报来着.已经接收到网关的反馈
                            this.dicDeviceRowControl[mainKeys].SetHadGetResponeResultStatu();
                        }
                        //已经接收到网关的反馈 2020.05.09:删除Ack主题
                        this.dicDeviceRowControl[mainKeys].SetHadGetResponeResultStatu();
                        //刷新控件
                        this.dicDeviceRowControl[mainKeys].RefreshControlInfo(locadevice);
                    }
                }, ShowErrorMode.NO);
@@ -836,23 +827,6 @@
                        bool bolOnline = LocalDevice.Current.CheckDeviceIsOnline(report);
                        this.dicDeviceRowControl[mainKeys].SetRowOnlineStatu(bolOnline);
                        return;
                    }
                }, ShowErrorMode.NO);
            });
            //设备控制反馈上报
            HdlGatewayReceiveLogic.Current.AddAttributeEvent("UserHomeViewDeviceRespone", ReceiveComandDiv.A节点控制反馈, (report) =>
            {
                HdlThreadLogic.Current.RunMain(() =>
                {
                    string mainKeys = LocalDevice.Current.GetDeviceMainKeys(report);
                    if (this.dicDeviceRowControl.ContainsKey(mainKeys) == true)
                    {
                        //设备卡片
                        var deviceCardContr = this.dicDeviceRowControl[mainKeys];
                        //已经接收到网关的反馈
                        deviceCardContr.SetHadGetResponeResultStatu();
                    }
                }, ShowErrorMode.NO);
@@ -923,14 +897,9 @@
                    string path1 = string.Empty;
                    string path2 = string.Empty;
                    //获取图片
                    LocalDevice.Current.GetDeviceObjectIcon(typeInfo.ConcreteType, ref path1, ref path2);
                    LocalDevice.Current.GetDeviceFunctionTypeMenuIcon(typeInfo.ConcreteType, ref path1, ref path2);
                    dic[typeInfo.BeloneTextId].IconPath = path1;
                    dic[typeInfo.BeloneTextId].IconPathSelected = path2;
                    if (device.Type == DeviceType.FreshAir)
                    {
                        dic[typeInfo.BeloneTextId].IconPath = "Device/FreshAirEpoint.png";
                        dic[typeInfo.BeloneTextId].IconPathSelected = "Device/FreshAirEpointSelected.png";
                    }
                    dic[typeInfo.BeloneTextId].TextId = typeInfo.BeloneTextId;
                }
                dic[typeInfo.BeloneTextId].listDeviceKeys.Add(LocalDevice.Current.GetDeviceMainKeys(device));