xm
2020-07-21 9a4b76398009cf76c508d61f7e48fb6f5cb7ac2d
ZigbeeApp/Shared/Phone/MainPage/HomeMainPageForm.cs
old mode 100755 new mode 100644
@@ -16,6 +16,10 @@
        #region ■ 变量声明___________________________
        /// <summary>
        /// The instance.
        /// </summary>
        public static HomeMainPageForm Instance;
        /// <summary>
        /// 整个界面的上下滑动控件
        /// </summary>
        private VerticalFrameControl listBodyContr = null;
@@ -49,8 +53,11 @@
        /// </summary>
        public void ShowForm()
        {
            //先初始化左滑房间列表界面(在反射里面初始化)
            if (ListRoomViewFrom.Instance == null) { }
            this.FormID = "HomeMainPageForm";
            Instance = this;
            //先初始化左滑房间列表界面(在反射里面初始化)
            if (LeftListRoomViewFrom.Instance == null) { }
            //整个背景的上下滑动控件
            if (this.listBodyContr == null)
@@ -67,6 +74,9 @@
                listBodyContr.RecoverTableHeight();
            }
            //初始化默认楼层ID
            this.InitDefultFloorId();
            //初始化头部控件
            this.InitTopFrameLayoutControl();
            //初始化中间控件
@@ -75,8 +85,6 @@
            this.AddNormalDeviceReportEvent();
            //添加传感器状态上报事件
            this.AddSensorDeviceReportEvent();
            //将当前的画面保存到内存当中
            UserCenterLogic.AddActionForm(this);
        }
        /// <summary>
@@ -85,7 +93,7 @@
        private void InitTopFrameLayoutControl()
        {
            //头部容器
            base.topFrameLayout = new FrameLayout();
            base.topFrameLayout = new NormalFrameLayout();
            topFrameLayout.Y = Application.GetRealHeight(60);
            topFrameLayout.Height = Application.GetRealHeight(127);
            topFrameLayout.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor;
@@ -124,6 +132,9 @@
                    this.ShowSelectFloorForm(btnFloorName);
                };
            }
            //可视对讲快捷方式
            //Shared.Phone.Device.VideoIntercom.VideoMachine.AccountSupportVideo(topFrameLayout);
            //安防快捷方式
            if (UserCenterResourse.ResidenceOption.SafetyShortcut)
            {
@@ -165,7 +176,8 @@
                    selectHouse.Init();
                    selectHouse.HouseAction = (houseId) =>
                    {
                        ChangeResidence(House.GetHouseByHouseId(houseId));
                        //切换住宅
                        this.ChangeResidence(HdlResidenceLogic.Current.GetHouseByHouseId(houseId));
                    };
                }
            };
@@ -250,7 +262,7 @@
            }
            //功能和场景bodyView
            this.bodyFrameLayout = new FrameLayout();
            this.bodyFrameLayout = new NormalFrameLayout();
            bodyFrameLayout.Y = functionSceneView.Bottom;
            bodyFrameLayout.Height = this.listBodyContr.frameTable.Height - functionSceneView.Bottom;
            bodyFrameLayout.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor;
@@ -397,10 +409,9 @@
            roomPageView.SetLeftAndRightImageView(mLeftImageView, mRightImageView);
            //当前房间
            var listRoom = HdlRoomLogic.Current.GetRoomsByCurrentFloorIdAppendLoveRoom();
            var listRoom = HdlRoomLogic.Current.GetRoomsByFloorIdAppendLoveRoom(Config.Instance.Home.CurrentFloorId);
            if (HdlRoomLogic.Current.NowMainPageRoom == null)
            {
                //设置第一个为初始房间
                HdlRoomLogic.Current.NowMainPageRoom = listRoom[0];
            }
            var curIndex = 0;
@@ -500,7 +511,7 @@
                //当没有绑定有网关,左滑时,点击房间列表,则不鸟它
                return;
            }
            var listRoom = HdlRoomLogic.Current.GetRoomsByCurrentFloorIdAppendLoveRoom();
            var listRoom = HdlRoomLogic.Current.GetRoomsByFloorIdAppendLoveRoom(Config.Instance.Home.CurrentFloorId);
            for (int i = 0; i < listRoom.Count; i++)
            {
                if (room.Id == listRoom[i].Id)
@@ -516,7 +527,7 @@
            //重置一下楼层名字
            if (this.btnFloorName != null)
            {
                btnFloorName.Text = HdlResidenceLogic.Current.GetFloorNameById(Config.Instance.Home.CurrentFloorId);
                btnFloorName.Text = Config.Instance.Home.GetCurrentFloorName;
            }
        }
@@ -634,6 +645,11 @@
                    else if (device.Type == DeviceType.DoorLock)
                    {
                        cardContr = new Controls.DeviceDoorLockCardControl();
                    }
                    //色温灯
                    else if (device.Type == DeviceType.ColorTemperatureLight)
                    {
                        cardContr = new Controls.DeviceColorTemperatureCardControl();
                    }
                    //无法识别
                    else
@@ -1045,36 +1061,21 @@
        /// <param name="home">Home.</param>
        private void ChangeResidence(House home)
        {
            try
            HdlThreadLogic.Current.RunThread(() =>
            {
                CommonPage.Loading.Start();
                new System.Threading.Thread(async () =>
                {
                    Config.Instance.HomeId = home.Id;
                    Config.Instance.Home = House.GetHouseByFilePath(home.FileName);
                    Global.CreateHomeDirectory(home.Id);
                    Config.Instance.Save();
                    //刷新个人中心的内存及线程
                    await UserCenterLogic.InitUserCenterMenmoryAndThread();
                this.ShowProgressBar();
                    Application.RunOnMainThread(() =>
                    {
                        //刷新界面
                        this.ShowForm();
                //切换住宅
                HdlResidenceLogic.Current.SwitchResidence(home.Id);
                        CommonPage.Loading.Hide();
                    });
                })
                { IsBackground = true }.Start();
            }
            catch (Exception ex)
            {
                Application.RunOnMainThread(() =>
                HdlThreadLogic.Current.RunMain(() =>
                {
                    CommonPage.Loading.Hide();
                    Console.WriteLine(ex.Message);
                    //刷新界面
                    this.ShowForm();
                    this.CloseProgressBar();
                });
            }
            });
        }
        #endregion
@@ -1100,7 +1101,11 @@
                        //已经接收到网关的反馈 2020.05.09:删除Ack主题
                        this.dicDeviceCardControl[mainKeys].SetHadGetResponeResultStatu();
                        //刷新控件
                        this.dicDeviceCardControl[mainKeys].RefreshControlInfo(locadevice);
                        if (locadevice.Type != DeviceType.IASZone)
                        {
                            //传感器不需要属性上报(但是那个球型传感器居然会属性上报)
                            this.dicDeviceCardControl[mainKeys].RefreshControlInfo(locadevice);
                        }
                    }
                }, ShowErrorMode.NO);
            });
@@ -1141,10 +1146,8 @@
                    string mainKeys = LocalDevice.Current.GetDeviceMainKeys(report);
                    if (this.dicDeviceCardControl.ContainsKey(mainKeys) == true)
                    {
                        //本地设备对象
                        var locadevice = LocalDevice.Current.GetDevice(mainKeys);
                        //刷新卡片信息
                        this.dicDeviceCardControl[mainKeys].RefreshControlInfo(locadevice);
                        //开启卡片闪烁特效
                        this.dicDeviceCardControl[mainKeys].StartCardLightAppeal();
                    }
                }, ShowErrorMode.NO);
@@ -1161,13 +1164,16 @@
        private void ShowSelectFloorForm(NormalViewControl btnFloor)
        {
            var floorFL = new Category.SelectFloorForm();
            floorFL.CurFloorId = Config.Instance.Home.CurrentFloorId;
            this.AddChidren(floorFL);
            floorFL.Init(35, 153);
            floorFL.changeFloor = true;
            floorFL.FloorAction = (floorId) =>
            {
                btnFloor.Text = Config.Instance.Home.GetFloorNameById(floorId);
                btnFloor.Text = HdlResidenceLogic.Current.GetFloorNameById(floorId);
                Config.Instance.Home.CurrentFloorId = floorId;
                HdlRoomLogic.Current.NowMainPageRoom = HdlRoomLogic.Current.GetLoveRoom();
                //分类界面需要刷新
                UserView.UserPage.Instance.RefreshCategoryForm = true;
                this.ShowForm();
            };
        }
@@ -1181,8 +1187,10 @@
        /// </summary>
        public override void CloseFormBefore()
        {
            //把静态变量的这个东西置空
            Instance = null;
            HdlGatewayReceiveLogic.Current.RemoveEvent("UserHomeViewDeviceOnline");
            HdlGatewayReceiveLogic.Current.RemoveEvent("UserHomeViewDeviceRespone");
            HdlGatewayReceiveLogic.Current.RemoveEvent("UserHomeViewDeviceStatus");
            HdlGatewayReceiveLogic.Current.RemoveEvent("UserHomeViewSensor");
@@ -1207,6 +1215,23 @@
            return true;
        }
        /// <summary>
        /// 初始化默认楼层ID
        /// </summary>
        private void InitDefultFloorId()
        {
            if (Config.Instance.Home.CurrentFloorId != string.Empty)
            {
                return;
            }
            var dicFloor = HdlRoomLogic.Current.GetFloorSortList();
            foreach (var floorId in dicFloor.Keys)
            {
                Config.Instance.Home.CurrentFloorId = floorId;
                break;
            }
        }
        #endregion
        #region ■ 界面重新激活事件___________________