| | |
| | | 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;
|
| | |
| | | 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)
|
| | | {
|
| | |
| | | //获取中...
|
| | | 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)
|
| | |
| | | return;
|
| | | }
|
| | | //移除掉事件
|
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice");
|
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice");
|
| | |
|
| | | foreach (var data in report.DeviceStatusReport.AttriBute)
|
| | | {
|
| | |
| | | //获取中...
|
| | | 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)
|
| | |
| | | return;
|
| | | }
|
| | | //移除掉事件
|
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice");
|
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice");
|
| | | foreach (var data in report.DeviceStatusReport.AttriBute)
|
| | | {
|
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue)
|
| | |
| | | }
|
| | | this.newRoom.BackgroundImageType = 0;
|
| | | this.newRoom.BackgroundImage = imgPath;
|
| | | imageContr.ImagePath = imgPath;
|
| | | imgPath = IO.FileUtils.GetImageFilePath(imgPath);
|
| | | imageContr.ImageBytes = IO.FileUtils.ReadFile(imgPath);
|
| | | };
|
| | | });
|
| | | //拍照
|
| | |
| | | /// <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
|
| | |
| | | return false;
|
| | | }
|
| | | }
|
| | | newRoom.FloorId = this.floorKeys;
|
| | |
|
| | | return true;
|
| | | }
|