| | |
| | | /// </summary> |
| | | private string ImagePath="SceneIcon/1.png"; |
| | | /// <summary> |
| | | /// 图片来源 0--本地图库 1--拍照 2--系统图库 |
| | | /// </summary> |
| | | public int IconPathType = 0; |
| | | /// <summary> |
| | | /// curRoom |
| | | /// </summary> |
| | | private Common.Room curRoom; |
| | |
| | | /// sceneTargetDevicesList |
| | | /// </summary> |
| | | private List<SceneTargetDeviceUI> sceneTargetDevicesList = new List<SceneTargetDeviceUI> { }; |
| | | |
| | | /// <summary> |
| | | /// 添加目标后的展示列表 |
| | | /// </summary> |
| | | public VerticalScrolViewLayout TargetListScrolView; |
| | | /// <summary> |
| | | /// 添加的执行目标的行高 |
| | | /// </summary> |
| | | private readonly int TargetListScrolView_RowHeight = 170; |
| | | /// <summary> |
| | | /// The confirm button. |
| | | /// </summary> |
| | | private CommonForm.CompleteButton confirmBtn; |
| | | |
| | | /// <summary> |
| | | /// 确定按钮最开始的坐标 |
| | | /// 是否修改 |
| | | /// </summary> |
| | | private readonly int ConfirmButton_Y = CommonPage.AppRealHeight - 300; |
| | | public bool isModify; |
| | | /// <summary> |
| | | /// 修改的场景 |
| | | /// </summary> |
| | | public SceneUI modifySceneUI; |
| | | /// <summary> |
| | | /// 记录编辑前的设备列表 |
| | | /// </summary> |
| | | public List<SceneTargetDeviceUI> modifySceneTargetDevicesList; |
| | | /// <summary> |
| | | /// modifyRoom |
| | | /// </summary> |
| | | public Common.Room modifyRoom; |
| | | |
| | | |
| | | #endregion |
| | | |
| | |
| | | public CategoryAddScene() |
| | | { |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; |
| | | Tag = "categoryAddScene"; |
| | | } |
| | | /// <summary> |
| | | /// RemoveFromParent |
| | |
| | | { |
| | | foreach (var targetDevice in sceneTargetDevicesList) |
| | | { |
| | | var targetRowLayout = new RowLayout() |
| | | { |
| | | Height = Application.GetRealHeight(160), |
| | | LineColor = ZigbeeColor.Current.GXCBackgroundColor, |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | TargetListScrolView.AddChidren(targetRowLayout); |
| | | string devImgPath = string.Empty; |
| | | string devNameText = string.Empty; |
| | | if (targetDevice.Type == 0) |
| | |
| | | if (targetDevice.DeviceUI == null || targetDevice.DeviceUI.CommonDevice == null) continue; |
| | | devImgPath = targetDevice.DeviceUI.IconPath; |
| | | devNameText = targetDevice.DeviceUI.CommonDevice.DeviceEpointName; |
| | | } |
| | | else if (targetDevice.Type == 1) |
| | | { |
| | | devImgPath = "Item/Timer.png"; |
| | | devNameText = $"{targetDevice.DelayTime} {Language.StringByID(R.MyInternationalizationString.Second)}"; |
| | | |
| | | var targetRow = new SceneTargetFunctionRow(23); |
| | | targetRowLayout.AddChidren(targetRow); |
| | | targetRow.Init(); |
| | | targetRow.SetIcon(devImgPath); |
| | | targetRow.SetNameText(devNameText); |
| | | targetRow.SetZoneText(targetDevice.DeviceUI.GetZone()); |
| | | targetRow.SetStatuText(targetDevice.GetDeviceStatu()); |
| | | } |
| | | else if (targetDevice.Type == 2) |
| | | { |
| | | devImgPath = "Item/Scene.png"; |
| | | devNameText = targetDevice.SceneName; |
| | | if(targetDevice.DelayTime<60) |
| | | { |
| | | devNameText = $"{targetDevice.DelayTime} {Language.StringByID(R.MyInternationalizationString.Second)}"; |
| | | } |
| | | else |
| | | { |
| | | devNameText = $"{targetDevice.DelayTime / 60} {Language.StringByID(R.MyInternationalizationString.Minute)} {targetDevice.DelayTime % 60} {Language.StringByID(R.MyInternationalizationString.Second)}"; |
| | | } |
| | | devNameText += Language.StringByID(R.MyInternationalizationString.Later); |
| | | var targetRow = new SceneTargetTimeRow(23); |
| | | targetRowLayout.AddChidren(targetRow); |
| | | targetRow.Init(); |
| | | targetRow.SetTitle(devNameText); |
| | | } |
| | | var targetRowLayout = new RowLayout() |
| | | else if (targetDevice.Type == 1) |
| | | { |
| | | Height = Application.GetRealHeight(160), |
| | | LineColor = ZigbeeColor.Current.GXCLineColor, |
| | | BackgroundColor=ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | TargetListScrolView.AddChidren(targetRowLayout); |
| | | devImgPath = "Scene/SceneIcon.png"; |
| | | devNameText = targetDevice.SceneName; |
| | | |
| | | var targetFL = new FrameLayout() |
| | | var targetRow = new SceneTargetFunctionRow(23); |
| | | targetRowLayout.AddChidren(targetRow); |
| | | targetRow.Init(); |
| | | targetRow.SetIcon(devImgPath); |
| | | targetRow.SetNameText(devNameText); |
| | | targetRow.SetZoneText(targetDevice.SceneUI.GetZone()); |
| | | } |
| | | |
| | | |
| | | var editBtn = new Button() |
| | | { |
| | | |
| | | BackgroundColor = ZigbeeColor.Current.GXCEditBackGroundColor, |
| | | TextID = R.MyInternationalizationString.Edit, |
| | | TextColor = ZigbeeColor.Current.GXCTextWhiteColor |
| | | }; |
| | | targetRowLayout.AddChidren(targetFL); |
| | | |
| | | var devIMG = new Button() |
| | | { |
| | | X = Application.GetRealWidth(CommonPage.XLeft), |
| | | Width = Application.GetMinRealAverage(110), |
| | | Height = Application.GetMinRealAverage(110), |
| | | UnSelectedImagePath = devImgPath, |
| | | Gravity = Gravity.CenterVertical |
| | | }; |
| | | targetRowLayout.AddChidren(devIMG); |
| | | var devName = new Button() |
| | | { |
| | | X = devIMG.Right, |
| | | Width = Application.GetRealWidth(500), |
| | | Height = Application.GetRealHeight(100), |
| | | Gravity = Gravity.CenterVertical, |
| | | Text = devNameText, |
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor, |
| | | TextAlignment = TextAlignment.CenterLeft |
| | | }; |
| | | targetRowLayout.AddChidren(devName); |
| | | var devTimer = new Button() |
| | | { |
| | | X = targetRowLayout.Width - Application.GetRealWidth(150), |
| | | Width = Application.GetMinRealAverage(110), |
| | | Height = Application.GetMinRealAverage(110), |
| | | UnSelectedImagePath = "Item/Timer.png", |
| | | Gravity = Gravity.CenterVertical |
| | | }; |
| | | /////******暂时先不加延时,安卓控件有问题*******//// |
| | | //targetRowLayout.AddChidren(devTimer); |
| | | var devRight = new Button() |
| | | targetRowLayout.AddRightView(editBtn); |
| | | //编辑设备 |
| | | editBtn.MouseUpEventHandler += detailMouseUpEventHandler; |
| | | var delBtn = new Button() |
| | | { |
| | | BackgroundColor = ZigbeeColor.Current.GXCRedColor, |
| | | TextID = R.MyInternationalizationString.Delete, |
| | | TextColor = ZigbeeColor.Current.GXCTextWhiteColor |
| | | }; |
| | | targetRowLayout.AddRightView(devRight); |
| | | targetRowLayout.AddRightView(delBtn); |
| | | //删除设备 |
| | | devRight.MouseUpEventHandler += (sender, e) => |
| | | delBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | sceneTargetDevicesList.Remove(targetDevice); |
| | | RefreshTargetListView(); |
| | |
| | | { |
| | | return; |
| | | } |
| | | if (targetDevice.DeviceUI.CommonDevice.Type == ZigBee.Device.DeviceType.OnOffOutput) |
| | | { |
| | | //开关灯 |
| | | var taskList = targetDevice.TaskList; |
| | | if (taskList.Count == 0) |
| | | { |
| | | return; |
| | | } |
| | | var detail = new CategorySceneSelectLightSetting(); |
| | | UserView.HomePage.Instance.AddChidren(detail); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | detail.Show(targetDevice.DeviceUI, targetDevice.SceneTargetDeviceUIID, taskList[0].Data1); |
| | | } |
| | | else if (targetDevice.DeviceUI.CommonDevice.Type == ZigBee.Device.DeviceType.AirSwitch) |
| | | { |
| | | //空气开关 |
| | | var taskList = targetDevice.TaskList; |
| | | if (taskList.Count == 0) |
| | | { |
| | | return; |
| | | } |
| | | var detail = new CategorySceneSelectAirSwitchSetting(); |
| | | UserView.HomePage.Instance.AddChidren(detail); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | detail.Show(targetDevice.DeviceUI, targetDevice.SceneTargetDeviceUIID, taskList[0].Data1); |
| | | } |
| | | else if (targetDevice.DeviceUI.CommonDevice.Type == ZigBee.Device.DeviceType.WindowCoveringDevice) |
| | | { |
| | | //卷帘 |
| | | var taskList = targetDevice.TaskList; |
| | | if (taskList.Count == 0) |
| | | { |
| | | return; |
| | | } |
| | | var detail = new CategorySceneSelectCurtainSetting(); |
| | | UserView.HomePage.Instance.AddChidren(detail); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | UserView.HomePage.Instance.ScrollEnabled = false; |
| | | detail.Show(targetDevice.DeviceUI, targetDevice.SceneTargetDeviceUIID, taskList[0].Data1, taskList[0].Data2); |
| | | } |
| | | else if (targetDevice.DeviceUI.CommonDevice.Type == ZigBee.Device.DeviceType.DimmableLight) |
| | | { |
| | | //调光灯 |
| | | var taskList = targetDevice.TaskList; |
| | | if (taskList.Count == 0) |
| | | { |
| | | return; |
| | | } |
| | | var detail = new CategorySceneSelectedDimmableLightSetting(); |
| | | UserView.HomePage.Instance.AddChidren(detail); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | UserView.HomePage.Instance.ScrollEnabled = false; |
| | | if (taskList[0].TaskType == 1) |
| | | { |
| | | detail.Show(targetDevice.DeviceUI, targetDevice.SceneTargetDeviceUIID, taskList[0].Data1, taskList[0].Data2); |
| | | } |
| | | else if (taskList[0].TaskType == 3) |
| | | { |
| | | detail.Show(targetDevice.DeviceUI, targetDevice.SceneTargetDeviceUIID, taskList[0].TaskType, taskList[0].Data1); |
| | | |
| | | var deviceView = new SelectDevice(); |
| | | UserView.HomePage.Instance.AddChidren(deviceView); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | deviceView.sceneTargetDevice = targetDevice; |
| | | deviceView.deviceUI = targetDevice.DeviceUI; |
| | | deviceView.Show(); |
| | | deviceView.selectedAction = (selectedDevice) => |
| | | { |
| | | var targetDeviceUI = sceneTargetDevicesList.Find((obj) => obj.SceneTargetDeviceUIID == selectedDevice.SceneTargetDeviceUIID); |
| | | if (targetDeviceUI != null) |
| | | { |
| | | targetDeviceUI.DeviceUI = selectedDevice.DeviceUI; |
| | | targetDeviceUI.TaskList = selectedDevice.TaskList; |
| | | } |
| | | |
| | | |
| | | } |
| | | RefreshTargetListView(); |
| | | }; |
| | | |
| | | } |
| | | //时间间隔 |
| | | else if (targetDevice.Type == 1) |
| | | else if (targetDevice.Type == 2) |
| | | { |
| | | var delayTimeView = new SelectDelayTime(); |
| | | UserView.HomePage.Instance.AddChidren(delayTimeView); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | delayTimeView.sceneTargetDevice = targetDevice; |
| | | delayTimeView.totalSecond = targetDevice.DelayTime; |
| | | delayTimeView.Show(); |
| | | delayTimeView.selectedTimeAction = (second) => |
| | | { |
| | |
| | | }; |
| | | } |
| | | //场景 |
| | | else if (targetDevice.Type == 2) |
| | | else if (targetDevice.Type == 1) |
| | | { |
| | | var sceneView = new CategorySceneSelectedScene(); |
| | | var sceneView = new SelectScene(); |
| | | UserView.HomePage.Instance.AddChidren(sceneView); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | sceneView.Show(sceneTargetDevicesList, 1, targetDevice.SceneTargetDeviceUIID); |
| | | sceneView.sceneTargetDevice = targetDevice; |
| | | sceneView.sceneUI = targetDevice.SceneUI; |
| | | sceneView.Show(); |
| | | sceneView.selectedAction = (selectedScene) => |
| | | { |
| | | var targetDeviceUI = sceneTargetDevicesList.Find((obj) => obj.SceneTargetDeviceUIID == selectedScene.SceneTargetDeviceUIID); |
| | | if (targetDeviceUI != null) |
| | | { |
| | | targetDeviceUI.SceneName = selectedScene.SceneName; |
| | | targetDevice.SceneUI = selectedScene.SceneUI; |
| | | targetDevice.ElseScenesId = selectedScene.ElseScenesId; |
| | | } |
| | | RefreshTargetListView(); |
| | | }; |
| | | } |
| | | } |
| | | devIMG.MouseUpEventHandler += detailMouseUpEventHandler; |
| | | devName.MouseUpEventHandler += detailMouseUpEventHandler; |
| | | targetRowLayout.MouseUpEventHandler += detailMouseUpEventHandler; |
| | | targetFL.MouseUpEventHandler += detailMouseUpEventHandler; |
| | | |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | var top = new TopFrameLayout(); |
| | | AddChidren(top); |
| | | top.InitTopview(); |
| | | top.SetTopTitle(R.MyInternationalizationString.AddScence); |
| | | if(isModify) |
| | | { |
| | | top.SetTopTitle(R.MyInternationalizationString.EditorScene); |
| | | } |
| | | else |
| | | { |
| | | top.SetTopTitle(R.MyInternationalizationString.AddScence); |
| | | } |
| | | top.backButton.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | RemoveFromParent(); |
| | |
| | | //添加目标后的展示列表 |
| | | TargetListScrolView = new VerticalScrolViewLayout() |
| | | { |
| | | Y = targetLine.Bottom, |
| | | Height = Application.GetRealHeight(730-127), |
| | | Y = Application.GetRealHeight(49+127), |
| | | Height = Application.GetRealHeight(730-127-49), |
| | | //BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | targetFL.AddChidren(TargetListScrolView); |
| | | |
| | | confirmBtn = new CommonForm.CompleteButton(1656, 907, 127); |
| | | AddChidren(confirmBtn); |
| | | |
| | | if(isModify) |
| | | { |
| | | backGround.UnSelectedImagePath = modifySceneUI.IconPath; |
| | | nameRow.SetTitle(modifySceneUI.Name); |
| | | zoneRow.SetTitle($"{Config.Instance.Home.GetFloorNameById(modifyRoom.FloorId)},{modifyRoom.Name}"); |
| | | IconPathType = modifySceneUI.IconPathType; |
| | | curRoom = modifyRoom; |
| | | sceneTargetDevicesList.AddRange(modifySceneTargetDevicesList); |
| | | } |
| | | |
| | | RefreshTargetListView(); |
| | | |
| | |
| | | Shared.Phone.UserView.HomePage.Instance.AddChidren(localPic); |
| | | Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; |
| | | localPic.Show(); |
| | | localPic.action = () => |
| | | localPic.action = (imgPath) => |
| | | { |
| | | backGround.UnSelectedImagePath = ImagePath; |
| | | IconPathType = 0; |
| | | backGround.UnSelectedImagePath = imgPath; |
| | | }; |
| | | |
| | | }; |
| | | backGround.MouseUpEventHandler += backGroundIMGHander; |
| | | |
| | | |
| | | //区域 |
| | | EventHandler<MouseEventArgs> zoneHander = (sender, e) => |
| | |
| | | selectedFunctionBtn.MouseUpEventHandler += (send, ee) => |
| | | { |
| | | selectFL.RemoveFromParent(); |
| | | var deviceTypeList = new CategorySceneSelectDevice(); |
| | | UserView.HomePage.Instance.AddChidren(deviceTypeList); |
| | | var deviceView = new SelectDevice(); |
| | | UserView.HomePage.Instance.AddChidren(deviceView); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | deviceTypeList.Show(sceneTargetDevicesList); |
| | | deviceView.beforeSceneTargetDeviceUIs = sceneTargetDevicesList; |
| | | deviceView.Show(); |
| | | deviceView.selectedAction = (selectedDevice) => |
| | | { |
| | | sceneTargetDevicesList.Add(selectedDevice); |
| | | RefreshTargetListView(); |
| | | }; |
| | | }; |
| | | //添加场景 |
| | | selectedSceneBtn.MouseUpEventHandler += (send, ee) => |
| | | { |
| | | selectFL.RemoveFromParent(); |
| | | var sceneView = new CategorySceneSelectedScene(); |
| | | var sceneView = new SelectScene(); |
| | | UserView.HomePage.Instance.AddChidren(sceneView); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | //if (Modify) |
| | | //{ |
| | | // sceneView.Show(sceneTargetDevicesList, -1, "", false, ModifySceneUI.Id); |
| | | //} |
| | | //else |
| | | //{ |
| | | // sceneView.Show(sceneTargetDevicesList); |
| | | //} |
| | | sceneView.beforeSceneTargetDeviceUIs = sceneTargetDevicesList; |
| | | sceneView.Show(); |
| | | sceneView.selectedAction = (selectedScene) => |
| | | { |
| | | sceneTargetDevicesList.Add(selectedScene); |
| | | RefreshTargetListView(); |
| | | }; |
| | | |
| | | }; |
| | | //添加时间间隔 |
| | | selectedTimerBtn.MouseUpEventHandler += (send, ee) => |
| | |
| | | return; |
| | | } |
| | | |
| | | //新增 |
| | | if (string.IsNullOrEmpty(nameRow.NameText.Text)) |
| | | if(isModify) |
| | | { |
| | | var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.SceneNameCannotBeNull), Language.StringByID(R.MyInternationalizationString.Close)); |
| | | alert.Show(); |
| | | alert.ResultEventHandler += (sendAlert, eAlert) => |
| | | if (string.IsNullOrEmpty(nameRow.NameText.Text)) |
| | | { |
| | | return; |
| | | }; |
| | | var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.SceneNameCannotBeNull), Language.StringByID(R.MyInternationalizationString.Close)); |
| | | alert.Show(); |
| | | alert.ResultEventHandler += (sendAlert, eAlert) => |
| | | { |
| | | return; |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | try |
| | | { |
| | | //改名 |
| | | 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) |
| | | { |
| | | |
| | | } |
| | | |
| | | CommonPage.Loading.Start(); |
| | | var memberDataList = new List<ZigBee.Device.Scene.AddSceneMemberData>(); |
| | | for (int i = 0; i < sceneTargetDevicesList.Count; i++) |
| | | { |
| | | var sceneTarget = sceneTargetDevicesList[i]; |
| | | |
| | | if (sceneTarget.Type == 0) |
| | | { |
| | | if (sceneTarget.DeviceUI == null || sceneTarget.DeviceUI.CommonDevice == null) |
| | | { |
| | | continue; |
| | | } |
| | | var memberData = new AddSceneMemberData |
| | | { |
| | | Type = 0, |
| | | ScenesId = 0, |
| | | DeviceAddr = sceneTarget.DeviceUI.CommonDevice.DeviceAddr, |
| | | Epoint = sceneTarget.DeviceUI.CommonDevice.DeviceEpoint, |
| | | TaskList = sceneTarget.TaskList, |
| | | DelayTime = 0, |
| | | MemberNumber = i+1 |
| | | }; |
| | | memberDataList.Add(memberData); |
| | | } |
| | | else if (sceneTarget.Type == 1) |
| | | { |
| | | var memberData = new AddSceneMemberData |
| | | { |
| | | Type = 1, |
| | | ScenesId = 0, |
| | | ElseScenesId = sceneTarget.ElseScenesId, |
| | | DelayTime = 0, |
| | | MemberNumber = i+1 |
| | | }; |
| | | memberDataList.Add(memberData); |
| | | } |
| | | else if (sceneTarget.Type == 2) |
| | | { |
| | | var memberData = new AddSceneMemberData |
| | | { |
| | | Type = 2, |
| | | ScenesId = 0, |
| | | DelayTime = sceneTarget.DelayTime, |
| | | MemberNumber = i+1 |
| | | }; |
| | | memberDataList.Add(memberData); |
| | | } |
| | | } |
| | | |
| | | var sceneRemoveMemberData = new SceneRemoveMemberData { }; |
| | | var removeSceneDeviceListInfoList = new List<RemoveSceneDeviceListInfo> { }; |
| | | for (int i = 0; i < modifySceneTargetDevicesList.Count; i++) |
| | | { |
| | | var sceneTarget = modifySceneTargetDevicesList[i]; |
| | | if (sceneTarget.Type == 0) |
| | | { |
| | | if (sceneTarget.DeviceUI == null || sceneTarget.DeviceUI.CommonDevice == null) |
| | | { |
| | | continue; |
| | | } |
| | | var removeDevice = new RemoveSceneDeviceListInfo |
| | | { |
| | | Type = 0, |
| | | DeviceAddr = sceneTarget.DeviceUI.CommonDevice.DeviceAddr, |
| | | Epoint = sceneTarget.DeviceUI.CommonDevice.DeviceEpoint, |
| | | MemberNumber = sceneTarget.DelayTimeSerialNumber |
| | | }; |
| | | removeSceneDeviceListInfoList.Add(removeDevice); |
| | | } |
| | | else if (sceneTarget.Type == 1) |
| | | { |
| | | var removeDevice = new ZigBee.Device.Scene.RemoveSceneDeviceListInfo |
| | | { |
| | | Type = 1, |
| | | ElseScenesId = sceneTarget.ElseScenesId, |
| | | MemberNumber = sceneTarget.DelayTimeSerialNumber |
| | | }; |
| | | removeSceneDeviceListInfoList.Add(removeDevice); |
| | | } |
| | | else |
| | | { |
| | | var removeDevice = new ZigBee.Device.Scene.RemoveSceneDeviceListInfo |
| | | { |
| | | Type = 2, |
| | | DelayTime=sceneTarget.DelayTime, |
| | | MemberNumber=sceneTarget.DelayTimeSerialNumber |
| | | }; |
| | | removeSceneDeviceListInfoList.Add(removeDevice); |
| | | } |
| | | } |
| | | sceneRemoveMemberData.DeviceList = removeSceneDeviceListInfoList; |
| | | sceneRemoveMemberData.ScenesId = modifySceneUI.Id; |
| | | var result = await curRoom.ModifyScene(modifySceneUI, sceneRemoveMemberData, memberDataList); |
| | | if (result == 1) |
| | | { |
| | | if (modifyRoom != curRoom) |
| | | { |
| | | modifyRoom.SceneUIList.Remove(modifySceneUI); |
| | | modifyRoom.SceneUIFilePathList.Remove(modifySceneUI.FileName); |
| | | curRoom.SceneUIList.Add(modifySceneUI); |
| | | curRoom.SceneUIFilePathList.Add(modifySceneUI.FileName); |
| | | modifyRoom.Save(); |
| | | curRoom.Save(); |
| | | } |
| | | RemoveFromParent(); |
| | | } |
| | | else if (result == 0) |
| | | { |
| | | //失败 |
| | | Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain); |
| | | } |
| | | else if (result == -1) |
| | | { |
| | | //已存在 |
| | | Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | System.Console.WriteLine($"分类添加场景出错{ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | try |
| | | //新增 |
| | | if (string.IsNullOrEmpty(nameRow.NameText.Text)) |
| | | { |
| | | if (Shared.Common.Room.AllRoomSceneUIList.Find(s => s.Name == nameRow.NameText.Text.Trim()) != null) |
| | | var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.SceneNameCannotBeNull), Language.StringByID(R.MyInternationalizationString.Close)); |
| | | alert.Show(); |
| | | alert.ResultEventHandler += (sendAlert, eAlert) => |
| | | { |
| | | Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); |
| | | return; |
| | | } |
| | | CommonPage.Loading.Start(); |
| | | var memberDataList = new List<ZigBee.Device.Scene.AddSceneMemberData>(); |
| | | //累加延时 |
| | | int AddedDelayTime = 0; |
| | | for (int i = 0; i < sceneTargetDevicesList.Count; i++) |
| | | { |
| | | var sceneTarget = sceneTargetDevicesList[i]; |
| | | SceneTargetDeviceUI beforeSceneTarget = null; |
| | | if (i - 1 >= 0) |
| | | { |
| | | beforeSceneTarget = sceneTargetDevicesList[i - 1]; |
| | | } |
| | | if (sceneTarget.Type == 0) |
| | | { |
| | | if (sceneTarget.DeviceUI == null || sceneTarget.DeviceUI.CommonDevice == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | if (beforeSceneTarget != null && beforeSceneTarget.Type == 1) |
| | | { |
| | | if (i - 1 >= 0) |
| | | { |
| | | for (int k = i - 1; k >= 0; k--) |
| | | { |
| | | if (sceneTargetDevicesList[k] == null || sceneTargetDevicesList[k].Type != 1) |
| | | { |
| | | break; |
| | | } |
| | | AddedDelayTime += sceneTargetDevicesList[k].DelayTime; |
| | | } |
| | | } |
| | | } |
| | | |
| | | var memberData = new ZigBee.Device.Scene.AddSceneMemberData |
| | | { |
| | | DeviceAddr = sceneTarget.DeviceUI.CommonDevice.DeviceAddr, |
| | | Type = 0, |
| | | ScenesId = 0, |
| | | Epoint = sceneTarget.DeviceUI.CommonDevice.DeviceEpoint, |
| | | TaskList = sceneTarget.TaskList, |
| | | DelayTime = AddedDelayTime |
| | | }; |
| | | memberDataList.Add(memberData); |
| | | } |
| | | else if (sceneTarget.Type == 2) |
| | | { |
| | | if (beforeSceneTarget != null && beforeSceneTarget.Type == 1) |
| | | { |
| | | if (i - 1 >= 0) |
| | | { |
| | | for (int k = i - 1; k >= 0; k--) |
| | | { |
| | | if (sceneTargetDevicesList[k] == null || sceneTargetDevicesList[k].Type != 1) |
| | | { |
| | | break; |
| | | } |
| | | AddedDelayTime += sceneTargetDevicesList[k].DelayTime; |
| | | } |
| | | } |
| | | } |
| | | var memberData = new ZigBee.Device.Scene.AddSceneMemberData |
| | | { |
| | | Type = 1, |
| | | ScenesId = 0, |
| | | ElseScenesId = sceneTarget.ElseScenesId, |
| | | DelayTime = AddedDelayTime |
| | | }; |
| | | memberDataList.Add(memberData); |
| | | } |
| | | } |
| | | |
| | | var result = await curRoom.AddScene(nameRow.NameText.Text, backGround.UnSelectedImagePath, memberDataList); |
| | | if (result == 1) |
| | | { |
| | | RemoveFromParent(); |
| | | } |
| | | else if (result == 0) |
| | | { |
| | | //失败 |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.AddSceneFail); |
| | | } |
| | | else if (result == -1) |
| | | { |
| | | //已存在 |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); |
| | | } |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | else |
| | | { |
| | | System.Console.WriteLine($"分类添加场景出错{ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | } |
| | | try |
| | | { |
| | | if (Common.Room.CurrentRoom.GetSameFloorScenes(curRoom.FloorId).Find(s => s.Name == nameRow.NameText.Text.Trim()) != null) |
| | | { |
| | | Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); |
| | | return; |
| | | } |
| | | CommonPage.Loading.Start(); |
| | | var memberDataList = new List<ZigBee.Device.Scene.AddSceneMemberData>(); |
| | | for (int i = 0; i < sceneTargetDevicesList.Count; i++) |
| | | { |
| | | var sceneTarget = sceneTargetDevicesList[i]; |
| | | |
| | | if (sceneTarget.Type == 0) |
| | | { |
| | | if (sceneTarget.DeviceUI == null || sceneTarget.DeviceUI.CommonDevice == null) |
| | | { |
| | | continue; |
| | | } |
| | | var memberData = new AddSceneMemberData |
| | | { |
| | | Type = 0, |
| | | ScenesId = 0, |
| | | DeviceAddr = sceneTarget.DeviceUI.CommonDevice.DeviceAddr, |
| | | Epoint = sceneTarget.DeviceUI.CommonDevice.DeviceEpoint, |
| | | TaskList = sceneTarget.TaskList, |
| | | DelayTime = 0, |
| | | MemberNumber = i+1 |
| | | }; |
| | | memberDataList.Add(memberData); |
| | | } |
| | | else if (sceneTarget.Type == 1) |
| | | { |
| | | var memberData = new AddSceneMemberData |
| | | { |
| | | Type = 1, |
| | | ScenesId = 0, |
| | | ElseScenesId = sceneTarget.ElseScenesId, |
| | | DelayTime = 0, |
| | | MemberNumber = i+1 |
| | | }; |
| | | memberDataList.Add(memberData); |
| | | } |
| | | else if (sceneTarget.Type == 2) |
| | | { |
| | | var memberData = new AddSceneMemberData |
| | | { |
| | | Type = 2, |
| | | ScenesId = 0, |
| | | DelayTime = sceneTarget.DelayTime, |
| | | MemberNumber = i+1 |
| | | }; |
| | | memberDataList.Add(memberData); |
| | | } |
| | | } |
| | | |
| | | var result = await curRoom.AddScene(nameRow.NameText.Text, backGround.UnSelectedImagePath, memberDataList); |
| | | if (result == 1) |
| | | { |
| | | RemoveFromParent(); |
| | | } |
| | | else if (result == 0) |
| | | { |
| | | //失败 |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.AddSceneFail); |
| | | } |
| | | else if (result == -1) |
| | | { |
| | | //已存在 |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | System.Console.WriteLine($"分类添加场景出错{ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | }; |
| | | #endregion |
| | | } |