| | |
| | | /// </summary> |
| | | public Common.Room modifyRoom; |
| | | |
| | | /// <summary> |
| | | /// OldBackgroundImagePath |
| | | /// </summary> |
| | | private string OldBackgroundImagePath; |
| | | /// <summary> |
| | | /// OldIconPathType |
| | | /// </summary> |
| | | public int OldIconPathType; |
| | | |
| | | #endregion |
| | | |
| | |
| | | //设备详细设置界面 |
| | | void detailMouseUpEventHandler(object sender, MouseEventArgs e) |
| | | { |
| | | //设备 |
| | | if (targetDevice.Type == 0) |
| | | { |
| | | if (targetDevice.DeviceUI == null || targetDevice.DeviceUI.CommonDevice == null) |
| | |
| | | }; |
| | | |
| | | } |
| | | //时间间隔 |
| | | else if (targetDevice.Type == 2) |
| | | { |
| | | var delayTimeView = new SelectDelayTime(); |
| | |
| | | RefreshTargetListView(); |
| | | }; |
| | | } |
| | | //场景 |
| | | else if (targetDevice.Type == 1) |
| | | { |
| | | var sceneView = new SelectScene(); |
| | |
| | | /// </summary> |
| | | private void Init() |
| | | { |
| | | //foreach (var floor in Config.Instance.Home.FloorDics) |
| | | //{ |
| | | // floorIds.Add(floor.Key); |
| | | // floorNames.Add(floor.Value); |
| | | // if(Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key).Count>0) |
| | | // { |
| | | // roomNames.Add(Common.Room.CurrentRoom.GetRoomNamesByFloorId(floor.Key)); |
| | | // rooms.Add(Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key)); |
| | | // } |
| | | //} |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | Height = Application.GetMinRealAverage(464), |
| | | Gravity = Gravity.Center, |
| | | Radius = (uint)Application.GetMinRealAverage(CommonFormResouce.BigFormRadius), |
| | | //UnSelectedImagePath = ImagePath |
| | | UnSelectedImagePath = "SceneIcon/3.jpg" |
| | | }; |
| | | imgFL.AddChidren(backGround); |
| | |
| | | }; |
| | | addTargetFL.AddChidren(targetLine); |
| | | |
| | | //添加目标后的展示列表 |
| | | TargetListScrolView = new VerticalScrolViewLayout() |
| | | { |
| | | Y = Application.GetRealHeight(49+127), |
| | | Height = Application.GetRealHeight(730-127-49), |
| | | //BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | targetFL.AddChidren(TargetListScrolView); |
| | | |
| | |
| | | |
| | | if(isModify) |
| | | { |
| | | backGround.UnSelectedImagePath = modifySceneUI.IconPath; |
| | | IconPathType = modifySceneUI.IconPathType; |
| | | OldIconPathType = modifySceneUI.IconPathType; |
| | | if (IconPathType != 0) |
| | | { |
| | | OldBackgroundImagePath = modifySceneUI.IconPath; |
| | | } |
| | | if (modifySceneUI.IconPathType==0) |
| | | { |
| | | backGround.UnSelectedImagePath = modifySceneUI.IconPath; |
| | | } |
| | | else |
| | | { |
| | | backGround.UnSelectedImagePath = System.IO.Path.Combine(Config.Instance.FullPath, modifySceneUI.IconPath); |
| | | } |
| | | nameRow.SetTitle(modifySceneUI.Name); |
| | | zoneRow.SetTitle($"{Config.Instance.Home.GetFloorNameById(modifyRoom.FloorId)},{modifyRoom.Name}"); |
| | | IconPathType = modifySceneUI.IconPathType; |
| | | curRoom = modifyRoom; |
| | | sceneTargetDevicesList.AddRange(modifySceneTargetDevicesList); |
| | | } |
| | |
| | | |
| | | #region event |
| | | |
| | | //选择背景图 |
| | | EventHandler<MouseEventArgs> backGroundIMGHander = (sender, e) => |
| | | { |
| | | if (curRoom != null && curRoom.IsSharedRoom) |
| | |
| | | { |
| | | selectFL.RemoveFromParent(); |
| | | var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); |
| | | var fileName = $"Scene_{tradeTime}"; |
| | | var fileName = $"SceneIcon_{tradeTime}"; |
| | | //通过相机拍照裁剪 |
| | | CropImage.TakePicture((imagePath) => |
| | | { |
| | |
| | | { |
| | | selectFL.RemoveFromParent(); |
| | | var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); |
| | | var fileName = $"Scene_{tradeTime}"; |
| | | var fileName = $"SceneIcon_{tradeTime}"; |
| | | //从相册选择图片裁剪 |
| | | CropImage.SelectPicture((imagePath) => |
| | | { |
| | |
| | | try |
| | | { |
| | | var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); |
| | | var fileName = $"Scene_{tradeTime}"; |
| | | //改名 |
| | | var fileName = $"SceneIcon_{tradeTime}"; |
| | | if (modifySceneUI.Name != nameRow.NameText.Text.Trim()) |
| | | { |
| | | if (Common.Room.CurrentRoom.GetSameFloorScenes(curRoom.FloorId).Find(s => s.Name == nameRow.NameText.Text.Trim()) != null) |
| | |
| | | Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); |
| | | return; |
| | | } |
| | | //修改名字 |
| | | var r = await ZigBee.Device.Scene.RenameSceneAsync(modifySceneUI.Id, nameRow.NameText.Text.Trim()); |
| | | var reName = r.sceneRenameResponseData.Result; |
| | | if (reName == 0) |
| | | { |
| | | //失败 |
| | | return; |
| | | } |
| | | else if (reName == 1) |
| | | { |
| | | //成功 |
| | | modifySceneUI.Name = nameRow.NameText.Text.Trim(); |
| | | |
| | | } |
| | | else if (reName == 2) |
| | | { |
| | | //没有该场景 |
| | | return; |
| | | } |
| | | } |
| | | //图片 |
| | | if(IconPathType==1 || IconPathType ==2) |
| | | if (OldIconPathType != 0) |
| | | { |
| | | Shared.IO.FileUtils.DeleteFile(System.IO.Path.Combine(Config.Instance.FullPath, OldBackgroundImagePath)); |
| | | } |
| | | if (IconPathType == 1 || IconPathType == 2) |
| | | { |
| | | Shared.IO.FileUtils.WriteFileByBytes(System.IO.Path.Combine(Config.Instance.FullPath, fileName), backGround.ImageBytes); |
| | | modifySceneUI.IconPath = System.IO.Path.Combine(Config.Instance.FullPath, fileName); |
| | | modifySceneUI.IconPath = fileName; |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | else if (result == 0) |
| | | { |
| | | //失败 |
| | | Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain); |
| | | } |
| | | else if (result == -1) |
| | | { |
| | | //已存在 |
| | | Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); |
| | | } |
| | | } |
| | |
| | | var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); |
| | | var fileName = $"SceneIcon_{tradeTime}.png"; |
| | | string imgPath; |
| | | //图片 |
| | | if (IconPathType == 1 || IconPathType == 2) |
| | | { |
| | | Shared.IO.FileUtils.WriteFileByBytes(System.IO.Path.Combine(Config.Instance.FullPath, fileName), backGround.ImageBytes); |
| | | imgPath = System.IO.Path.Combine(Config.Instance.FullPath, fileName); |
| | | imgPath = fileName; |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | else if (result == 0) |
| | | { |
| | | //失败 |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.AddSceneFail); |
| | | } |
| | | else if (result == -1) |
| | | { |
| | | //已存在 |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); |
| | | } |
| | | } |