黄学彪
2019-11-25 160785587667cc0d927f85e44c139ec9dde13a9e
ZigbeeApp/Shared/Phone/UserCenter/Residence/AddNewRoomForm.cs
@@ -60,13 +60,17 @@
            btnPic.Height = Application.GetMinRealAverage(444);
            btnPic.Gravity = Gravity.CenterHorizontal;
            btnPic.Radius = 17;
            btnPic.ImagePath = "Room/r0.png";
            btnPic.ImagePath = "RoomIcon/0.JPG";
            bodyFrameLayout.AddChidren(btnPic);
            btnPic.MouseUpEventHandler += (sender, e) =>
            {
                //房间图片选择
                this.RoomPictrueSelect(btnPic);
            };
            //添加阴影特效
            var btnTemp = new ButtonBase();
            btnTemp.AddBottomShadow(btnPic, true);
            btnTemp = null;
            this.newRoom = new Common.Room();
            newRoom.FloorId = this.floorKeys;
@@ -163,13 +167,15 @@
                if (newRoom.BackgroundImageType == 1 || newRoom.BackgroundImageType == 2)
                {
                    //生成图片
                    string picName = $"Room_{DateTime.Now.ToString("yyyyMMddHHmmss")}";
                    string picName = $"RoomIcon_{DateTime.Now.ToString("yyyyMMddHHmmss")}.png";
                    string picFullName = System.IO.Path.Combine(Common.Config.Instance.FullPath, picName);
                    Shared.IO.FileUtils.WriteFileByBytes(picFullName, btnPic.ImageBytes);
                    newRoom.BackgroundImage = picFullName;
                    //备份
                    Phone.UserCenter.HdlAutoBackupLogic.AddOrEditorFile(picName);
                }
                newRoom.FloorId = this.floorKeys;
                var result = newRoom.AddRoom(newRoom);
                if (result == false)
                {
@@ -272,8 +278,8 @@
            //获取中...
            btnTemper.Text = Language.StringByID(R.MyInternationalizationString.uGetting);
            HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice");
            HdlDeviceAttributeLogic.Current.AddAttributeEvent("TemperatrueDevice", "DeviceStatusReport", (Action<ZigBee.Device.CommonDevice>)((report) =>
            HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice");
            HdlGatewayReceiveLogic.Current.AddAttributeEvent("TemperatrueDevice", ReceiveComandDiv.A设备属性上报, (Action<ZigBee.Device.CommonDevice>)((report) =>
            {
                string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report);
                if (newRoom.TemperatrueDevice != mainKeys || btnTemper == null)
@@ -281,7 +287,7 @@
                    return;
                }
                //移除掉事件
                HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice");
                HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice");
                foreach (var data in report.DeviceStatusReport.AttriBute)
                {
@@ -365,8 +371,8 @@
            //获取中...
            btnHumi.Text = Language.StringByID(R.MyInternationalizationString.uGetting);
            HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice");
            HdlDeviceAttributeLogic.Current.AddAttributeEvent("HumidityDevice", "DeviceStatusReport", (report) =>
            HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice");
            HdlGatewayReceiveLogic.Current.AddAttributeEvent("HumidityDevice", ReceiveComandDiv.A设备属性上报, (report) =>
            {
                string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report);
                if (newRoom.HumidityDevice != mainKeys || btnHumi == null)
@@ -374,7 +380,7 @@
                    return;
                }
                //移除掉事件
                HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice");
                HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice");
                foreach (var data in report.DeviceStatusReport.AttriBute)
                {
                    if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue)
@@ -425,7 +431,8 @@
                    }
                    this.newRoom.BackgroundImageType = 0;
                    this.newRoom.BackgroundImage = imgPath;
                    imageContr.ImagePath = imgPath;
                    imgPath = IO.FileUtils.GetImageFilePath(imgPath);
                    imageContr.ImageBytes = IO.FileUtils.ReadFile(imgPath);
                };
            });
            //拍照
@@ -468,14 +475,14 @@
        /// <summary>
        /// 界面关闭
        /// </summary>
        public override void CloseForm()
        public override void CloseFormBefore()
        {
            this.FinishEditorEvent = null;
            HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice");
            HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice");
            HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice");
            HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice");
            base.CloseForm();
            base.CloseFormBefore();
        }
        #endregion
@@ -511,7 +518,6 @@
                    return false;
                }
            }
            newRoom.FloorId = this.floorKeys;
            return true;
        }