| | |
| | | /// 克隆对象
|
| | | /// </summary>
|
| | | private Common.Room cloneRoom = null;
|
| | | /// <summary>
|
| | | /// 改变房间图片
|
| | | /// </summary>
|
| | | private bool changedRoomPic = false;
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | //房间图片选择
|
| | | this.RoomPictrueSelect(btnPic);
|
| | | };
|
| | | //添加阴影特效
|
| | | var btnTemp = new ButtonBase();
|
| | | btnTemp.AddBottomShadow(btnPic, true);
|
| | | btnTemp = null;
|
| | |
|
| | | //初始化桌布
|
| | | var tableContr = new InformationEditorControl();
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | | if (editorRoom.BackgroundImageType == 1 || editorRoom.BackgroundImageType == 2)
|
| | | //更改图片
|
| | | if (this.changedRoomPic == true)
|
| | | {
|
| | | //生成图片
|
| | | string picName = $"Room_{DateTime.Now.ToString("yyyyMMddHHmmss")}";
|
| | | string picFullName = System.IO.Path.Combine(Common.Config.Instance.FullPath, picName);
|
| | | Shared.IO.FileUtils.WriteFileByBytes(picFullName, btnPic.ImageBytes);
|
| | | editorRoom.BackgroundImage = picFullName;
|
| | | //备份
|
| | | HdlAutoBackupLogic.AddOrEditorFile(picName);
|
| | | if (editorRoom.BackgroundImageType == 1 || editorRoom.BackgroundImageType == 2)
|
| | | {
|
| | | //删除掉原来的自定义图片
|
| | | if (System.IO.File.Exists(editorRoom.BackgroundImage) == true)
|
| | | {
|
| | | System.IO.File.Delete(editorRoom.BackgroundImage);
|
| | | }
|
| | | //备份
|
| | | string[] MyArry = editorRoom.BackgroundImage.Split(new string[] { "/", @"\" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | HdlAutoBackupLogic.DeleteFile(MyArry[MyArry.Length - 1]);
|
| | | }
|
| | | //自定义图片
|
| | | if (cloneRoom.BackgroundImageType == 1 || cloneRoom.BackgroundImageType == 2)
|
| | | {
|
| | | //生成图片
|
| | | 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);
|
| | | cloneRoom.BackgroundImage = picFullName;
|
| | | //备份
|
| | | HdlAutoBackupLogic.AddOrEditorFile(picName);
|
| | | }
|
| | | }
|
| | |
|
| | | editorRoom.FloorId = cloneRoom.FloorId;
|
| | | editorRoom.Name = cloneRoom.Name;
|
| | | editorRoom.HumidityDevice = cloneRoom.HumidityDevice;
|
| | | editorRoom.TemperatrueDevice = cloneRoom.TemperatrueDevice;
|
| | | editorRoom.BackgroundImage = cloneRoom.BackgroundImage;
|
| | | editorRoom.BackgroundImageType = cloneRoom.BackgroundImageType;
|
| | | editorRoom.Save();
|
| | |
|
| | | FinishEditorEvent?.Invoke(this.cloneRoom.Name);
|
| | | FinishEditorEvent?.Invoke(this.editorRoom.Name);
|
| | | this.CloseForm();
|
| | | };
|
| | | }
|
| | |
| | | //获取中...
|
| | | 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 (cloneRoom.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 (cloneRoom.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)
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | | this.changedRoomPic = true;
|
| | | this.cloneRoom.BackgroundImageType = 0;
|
| | | this.cloneRoom.BackgroundImage = imgPath;
|
| | | imageContr.ImagePath = imgPath;
|
| | | imgPath = IO.FileUtils.GetImageFilePath(imgPath);
|
| | | imageContr.ImageBytes = IO.FileUtils.ReadFile(imgPath);
|
| | | };
|
| | | });
|
| | | //拍照
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | | this.changedRoomPic = true;
|
| | | this.cloneRoom.BackgroundImageType = 1;
|
| | | imageContr.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath);
|
| | | System.IO.File.Delete(imagePath);
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | | this.changedRoomPic = true;
|
| | | this.cloneRoom.BackgroundImageType = 2;
|
| | | imageContr.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath);
|
| | | System.IO.File.Delete(imagePath);
|
| | |
| | | /// <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;
|
| | | }
|
| | | }
|
| | | if (editorRoom.BackgroundImageType == 1 || editorRoom.BackgroundImageType == 2)
|
| | | {
|
| | | //删除掉原来的自定义图片
|
| | | if (System.IO.File.Exists(editorRoom.BackgroundImage) == true)
|
| | | {
|
| | | System.IO.File.Delete(editorRoom.BackgroundImage);
|
| | | }
|
| | | //备份
|
| | | string[] MyArry = editorRoom.BackgroundImage.Split(new string[] { "/", @"\" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | HdlAutoBackupLogic.DeleteFile(MyArry[MyArry.Length - 1]);
|
| | | }
|
| | | editorRoom.FloorId = cloneRoom.FloorId;
|
| | | editorRoom.Name = cloneRoom.Name;
|
| | | editorRoom.HumidityDevice = cloneRoom.HumidityDevice;
|
| | | editorRoom.TemperatrueDevice = cloneRoom.TemperatrueDevice;
|
| | | editorRoom.BackgroundImage = cloneRoom.BackgroundImage;
|
| | | editorRoom.BackgroundImageType = cloneRoom.BackgroundImageType;
|
| | | cloneRoom = null;
|
| | |
|
| | | return true;
|
| | | }
|