xm
2020-07-21 9a4b76398009cf76c508d61f7e48fb6f5cb7ac2d
ZigbeeApp/Shared/Phone/UserCenter/Residence/AddNewRoomForm.cs
@@ -18,7 +18,7 @@
        /// <summary>
        /// 列表控件
        /// </summary>
        private VerticalListControl listview = null;
        private FrameListControl listview = null;
        /// <summary>
        /// 楼层主键
        /// </summary>
@@ -54,35 +54,60 @@
            //清空bodyFrame
            this.ClearBodyFrame();
            var listBackControl = new VerticalFrameControl();
            listBackControl.Height = bodyFrameLayout.Height;
            bodyFrameLayout.AddChidren(listBackControl);
            //加一个白色背景
            var frameBack1 = new FrameLayout();
            frameBack1.Height = Application.GetRealHeight(450);
            frameBack1.Y = Application.GetRealHeight(196);
            frameBack1.BackgroundColor = UserCenterColor.Current.White;
            frameBack1.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight);
            listBackControl.frameTable.AddChidren(frameBack1);
            //初始化信息桌布
            var tableContr = new InformationEditorControl();
            this.listview = tableContr.InitControl(listBackControl.frameTable, Language.StringByID(R.MyInternationalizationString.uInfoEditor), 1175);
            //房间图片底部阴影
            var btnShadow = new PicViewControl(853, 593);
            btnShadow.Y = Application.GetRealHeight(58);
            btnShadow.Gravity = Gravity.CenterHorizontal;
            btnShadow.UnSelectedImagePath = "Room/RoomShadow.png";
            listBackControl.frameTable.AddChidren(btnShadow);
            //房间图片
            var btnPic = new ImageView();
            btnPic.Y = Application.GetRealHeight(60);
            btnPic.Width = Application.GetMinRealAverage(887);
            btnPic.Height = Application.GetMinRealAverage(444);
            btnPic.Width = this.GetPictrueRealSize(824);
            btnPic.Height = this.GetPictrueRealSize(549);
            btnPic.Radius = (uint)Application.GetRealHeight(17);
            btnPic.Gravity = Gravity.CenterHorizontal;
            btnPic.ImagePath = "RoomIcon/0.JPG";
            bodyFrameLayout.AddChidren(btnPic);
            var btnShadow = new PicViewControl(916, 487);
            btnShadow.Y = btnPic.Y;
            btnShadow.Gravity = Gravity.CenterHorizontal;
            btnShadow.UnSelectedImagePath = "Room/RoomShadow.png";
            bodyFrameLayout.AddChidren(btnShadow);
            btnShadow.MouseUpEventHandler += (sender, e) =>
            btnPic.ImagePath = "RoomIcon/0.jpg";
            listBackControl.frameTable.AddChidren(btnPic);
            //图片遮罩
            var btnZhezhao = new FrameLayout();
            btnZhezhao.Width = btnPic.Width;
            btnZhezhao.Height = btnPic.Height;
            btnZhezhao.Y = btnPic.Y;
            btnZhezhao.Gravity = Gravity.CenterHorizontal;
            btnZhezhao.Radius = (uint)Application.GetRealHeight(17);
            btnZhezhao.BackgroundColor = UserCenterColor.Current.PictrueZhezhaoColor;
            listBackControl.frameTable.AddChidren(btnZhezhao);
            btnZhezhao.MouseUpEventHandler += (sender, e) =>
            {
                //房间图片选择
                this.RoomPictrueSelect(btnPic);
            };
            //变更一下那个白色背景的Y轴,它到图片的中间位置
            frameBack1.Y = btnPic.Y + btnPic.Height / 2;
            this.newRoom = new Common.Room();
            newRoom.FloorId = this.floorKeys;
            newRoom.BackgroundImage = btnPic.ImagePath;
            newRoom.Humidity = -1000;
            newRoom.Temperatrue = -1000;
            //初始化桌布
            var tableContr = new InformationEditorControl();
            this.listview = tableContr.InitControl(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uInfoEditor), 562, 1175);
            //添加全部菜单
            this.AddAllMenuRow(tableContr, btnPic);
@@ -154,7 +179,7 @@
            };
            //初始化桌布完成
            tableContr.FinishInitControl(bodyFrameLayout, this.listview);
            tableContr.FinishInitControl();
            tableContr = null;
            //保存
            var btnFinish = new BottomClickButton();
@@ -180,6 +205,17 @@
                }
                newRoom.FloorId = this.floorKeys;
                if (newRoom.Humidity == -1000)
                {
                    newRoom.Humidity = 0;
                }
                if (newRoom.Temperatrue == -1000)
                {
                    newRoom.Temperatrue = 0;
                }
                //添加房间,主页需要重新刷新
                UserView.UserPage.Instance.RefreshAllForm = true;
                HdlRoomLogic.Current.AddRoom(newRoom);
                this.FinishEditorEvent?.Invoke();
@@ -239,6 +275,11 @@
            {
                //获取温度传感器
                if (device is ZigBee.Device.TemperatureSensor && ((ZigBee.Device.TemperatureSensor)device).SensorDiv == 1)
                {
                    listDevice.Add(device);
                }
                //PM2.5是温度和湿度合在同一个端点
                else if (device.Type == ZigBee.Device.DeviceType.PMSensor)
                {
                    listDevice.Add(device);
                }
@@ -349,6 +390,16 @@
                {
                    listDevice.Add(device);
                }
                //新风
                else if (device.Type == ZigBee.Device.DeviceType.FreshAirHumiditySensor)
                {
                    listDevice.Add(device);
                }
                //PM2.5是温度和湿度合在同一个端点
                else if (device.Type == ZigBee.Device.DeviceType.PMSensor)
                {
                    listDevice.Add(device);
                }
            }
            var listSelect = new List<string>() { newRoom.HumidityDevice };
            var form = new SelectDeviceForm();
@@ -404,7 +455,8 @@
                    {
                        HdlThreadLogic.Current.RunMain(() =>
                        {
                            if (data.AttriButeData == 0)
                            decimal humidity = (decimal)device.GetType().InvokeMember("Humidity", System.Reflection.BindingFlags.GetField, null, device, null);
                            if (humidity == 0)
                            {
                                //0
                                btnHumi.Text = "0.0%";
@@ -412,11 +464,8 @@
                            }
                            else
                            {
                                //小数点需要一位(湿度没有负数)
                                string strValue = data.AttriButeData.ToString();
                                strValue = strValue.Substring(0, strValue.Length - 1);
                                //记录湿度
                                this.newRoom.Humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                                this.newRoom.Humidity = humidity;
                                btnHumi.Text = this.newRoom.Humidity.ToString() + "%";
                            }
                        });
@@ -424,7 +473,7 @@
                }
            });
            //发送获取湿度的命令
            ((ZigBee.Device.TemperatureSensor)device).ReadTemperatureOrHumidity();
            device.GetType().InvokeMember("ReadTemperatureOrHumidity", System.Reflection.BindingFlags.InvokeMethod, null, device, null);
        }
        #endregion
@@ -442,11 +491,9 @@
            //默认图库
            menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.LocalPicture), () =>
            {
                var localPic = new Phone.Device.Room.AddRoomSelectPicByLocal();
                Shared.Phone.UserView.HomePage.Instance.AddChidren(localPic);
                Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                localPic.Show();
                localPic.action = (imgPath) =>
                var form = new SelectLocalRoomImageForm();
                form.AddForm();
                form.FinishSelectEvent = (imgPath) =>
                {
                    if (string.IsNullOrEmpty(imgPath) == true)
                    {