using System; using System.Collections.Generic; using System.Globalization; using Shared.Common; using Shared.Phone.Device.Category; namespace Shared.Phone.Device.Room { /// /// Add room scene. /// public class AddRoomScene:FrameLayout { public static Shared.Common.Room CurrentRoom; public static string SceneText; public static string ImagePath; /// /// 图片来源 0--本地图库 1--拍照 2--系统图库 /// public int IconType = 0; ///添加目标后的展示列表 public VerticalScrolViewLayout TargetListScrolView; /// /// The scene target devices list. /// public static List sceneTargetDevicesList = new List { }; /// /// 添加的执行目标的行高 /// private readonly int TargetListScrolView_RowHeight = 170; /// /// The confirm button. /// private CommonForm.CompleteButton confirmBtn; /// /// 确定按钮最开始的坐标 /// private readonly int ConfirmButton_Y= CommonPage.AppRealHeight - 300; /// /// 确定按钮下移后的坐标 /// private readonly int ConfirmButton_Change_Y = CommonPage.AppRealHeight - 130; /// ///刷新添加目标后的展示列表 /// public void RefreshTargetListView() { TargetListScrolView.RemoveAll(); if (sceneTargetDevicesList.Count >= 2) { TargetListScrolView.Height = Application.GetRealHeight(TargetListScrolView_RowHeight * 3); confirmBtn.Y = Application.GetRealHeight(ConfirmButton_Change_Y); } else { TargetListScrolView.Height = Application.GetRealHeight(TargetListScrolView_RowHeight * 2); confirmBtn.Y = Application.GetRealHeight(ConfirmButton_Y); } if (sceneTargetDevicesList.Count > 0) { foreach (var targetDevice in sceneTargetDevicesList) { 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)}"; } else if (targetDevice.Type == 2) { devImgPath = "Item/Scene.png"; devNameText = targetDevice.SceneName; } var targetRowLayout = new RowLayout() { LineColor = ZigbeeColor.Current.GXCLineColor, Height = Application.GetRealHeight(170) }; TargetListScrolView.AddChidren(targetRowLayout); 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() { //UnSelectedImagePath = "Item/Delete.png", BackgroundColor = ZigbeeColor.Current.GXCRedColor, TextID = R.MyInternationalizationString.Delete, TextColor = ZigbeeColor.Current.GXCTextWhiteColor }; targetRowLayout.AddRightView(devRight); devTimer.MouseUpEventHandler += (sender, e) => { //计时 /////******暂时先不加延时,安卓控件有问题*******//// var tList = new List { }; for (int i = 1; i <= 60; i++) { tList.Add($"{i} {Language.StringByID(R.MyInternationalizationString.Second)}"); } //1-60秒 //PickerView.Show(tList, (obj) => //{ //targetDevice.DelayTime = int.Parse(obj.Split(' ')[0]); //}, Language.StringByID(R.MyInternationalizationString.Confrim)); }; devRight.MouseUpEventHandler += (sender, e) => { //删除设备 sceneTargetDevicesList.Remove(targetDevice); RefreshTargetListView(); }; //设备详细设置界面 void detailMouseUpEventHandler(object sender, MouseEventArgs e) { //设备 if (targetDevice.Type == 0) { if (targetDevice.DeviceUI == null || targetDevice.DeviceUI.CommonDevice == null) { 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,true); } 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, true); } 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,true); } } //时间间隔 else if (targetDevice.Type == 1) { var delayTimeView = new SelectDelayTime(); UserView.HomePage.Instance.AddChidren(delayTimeView); UserView.HomePage.Instance.PageIndex += 1; //delayTimeView.Show(1, targetDevice.SceneTargetDeviceUIID,-1,true); } //场景 else if (targetDevice.Type == 2) { var sceneView = new CategorySceneSelectedScene(); UserView.HomePage.Instance.AddChidren(sceneView); UserView.HomePage.Instance.PageIndex += 1; sceneView.Show(sceneTargetDevicesList, 1, targetDevice.SceneTargetDeviceUIID,true); } } devIMG.MouseUpEventHandler += detailMouseUpEventHandler; devName.MouseUpEventHandler += detailMouseUpEventHandler; targetRowLayout.MouseUpEventHandler += detailMouseUpEventHandler; } } } public override void RemoveFromParent() { AddRoomContent.instance?.RefreshBodyView(); base.RemoveFromParent(); } public AddRoomScene() { BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; Tag = "categoryAddScene"; } public void Show(Shared.Common.Room room) { CurrentRoom = room; #region topview var topBGView = new FrameLayout() { Height = Application.GetRealHeight(CommonPage.Navigation_Height), BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor }; AddChidren(topBGView); var topView = new FrameLayout() { Y = Application.GetRealHeight(CommonPage.NavigationTitle_Y), Height = Application.GetRealHeight(CommonPage.Navigation_Height - CommonPage.NavigationTitle_Y), BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor, }; AddChidren(topView); var title = new Button() { TextAlignment = TextAlignment.Center, TextID = R.MyInternationalizationString.AddScence, TextSize = 20, TextColor = ZigbeeColor.Current.GXCTextBlackColor, Width = Application.GetRealWidth(CommonPage.AppRealWidth - 500), Gravity = Gravity.CenterHorizontal }; topView.AddChidren(title); var back = new Button() { X = Application.GetRealWidth(CommonPage.Navigation_X), Height = Application.GetMinRealAverage(110), Width = Application.GetMinRealAverage(110), UnSelectedImagePath = "Item/Back.png", SelectedImagePath = "Item/BackSelected.png", Gravity = Gravity.CenterVertical }; topView.AddChidren(back); back.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); }; #endregion #region midFL var midFL = new FrameLayout() { Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height), Y = topView.Bottom, BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, }; this.AddChidren(midFL); #endregion #region 背景图 名称 区域 执行目标 var backGround = new Button() { Y = Application.GetRealHeight(50), Width = Application.GetMinRealAverage(CommonPage.AppRealWidth-CommonPage.XLeft*2), Height = Application.GetMinRealAverage(400), Gravity = Gravity.CenterHorizontal, Radius = CommonPage.BigFormRadius, UnSelectedImagePath = ImagePath }; midFL.AddChidren(backGround); //设备名称--场景名 var deviceNameFL = new FrameLayout() { Y = backGround.Bottom + Application.GetRealHeight(100), Height = Application.GetRealHeight(170), }; midFL.AddChidren(deviceNameFL); var deviceNameTip = new Button() { X = Application.GetRealWidth(50), Height = Application.GetRealHeight(70), Width = Application.GetRealWidth(300), TextAlignment = TextAlignment.CenterLeft, TextSize = 12, TextColor = ZigbeeColor.Current.GXCButtonTipColor, TextID = R.MyInternationalizationString.SceneName, }; deviceNameFL.AddChidren(deviceNameTip); var sceneNameET = new EditText() { X = Application.GetRealWidth(50), Y = deviceNameTip.Bottom, Height = Application.GetRealHeight(100) - 1, Width = Application.GetRealWidth(700), TextAlignment = TextAlignment.CenterLeft, TextSize = 20, PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputSceneName), PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor, TextColor = ZigbeeColor.Current.GXCTextBlackColor, }; deviceNameFL.AddChidren(sceneNameET); var deviceNameLine = new Button() { Y = sceneNameET.Bottom, Height = 1, BackgroundColor = ZigbeeColor.Current.GXCLineColor }; deviceNameFL.AddChidren(deviceNameLine); //zone var zoneFL = new FrameLayout() { Y = deviceNameFL.Bottom, Height = Application.GetRealHeight(170), }; midFL.AddChidren(zoneFL); var zoneTip = new Button() { X = Application.GetRealWidth(50), Height = Application.GetRealHeight(70), Width = Application.GetRealWidth(300), TextAlignment = TextAlignment.CenterLeft, TextSize = 12, TextColor = ZigbeeColor.Current.GXCButtonTipColor, TextID = R.MyInternationalizationString.BelongZone, }; zoneFL.AddChidren(zoneTip); var zone = new Button() { X = Application.GetRealWidth(50), Y = deviceNameTip.Bottom, Height = Application.GetRealHeight(100) - 1, Width = Application.GetRealWidth(500), TextAlignment = TextAlignment.CenterLeft, TextSize = 20, TextColor = ZigbeeColor.Current.GXCTextBlackColor, Text = room.Name, }; zoneFL.AddChidren(zone); var zoneRight = new Button() { X = Application.GetRealWidth(CommonPage.AppRealWidth - 150), Width = Application.GetMinRealAverage(110), Height = Application.GetMinRealAverage(110), UnSelectedImagePath = "Item/Next.png", Gravity = Gravity.CenterVertical }; //zoneFL.AddChidren(zoneRight); var zoneLine = new Button() { Y = zone.Bottom, Height = 1, BackgroundColor = ZigbeeColor.Current.GXCLineColor }; zoneFL.AddChidren(zoneLine); //添加执行目标 var targetFL = new FrameLayout() { Y = zoneFL.Bottom, Height = Application.GetRealHeight(170), }; var targetAddFL = new FrameLayout() { Y = zoneFL.Bottom, Height = Application.GetRealHeight(170), }; midFL.AddChidren(targetFL); var target = new Button() { X = Application.GetRealWidth(50), Height = Application.GetRealHeight(100) - 1, Width = Application.GetRealWidth(500), TextAlignment = TextAlignment.CenterLeft, TextSize = 20, TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextID=R.MyInternationalizationString.AddScentTargetAction, Gravity=Gravity.CenterVertical }; targetAddFL.AddChidren(target); var targetAdd = new Device.CommonForm.SelectedStatuButton() { X = Application.GetRealWidth(CommonPage.AppRealWidth - 150), Width = Application.GetMinRealAverage(72), Height = Application.GetMinRealAverage(72), UnSelectedImagePath = "Item/Add.png", SelectedImagePath="Item/AddSelected.png", Gravity = Gravity.CenterVertical }; targetFL.AddChidren(targetAdd); var targetLine = new Button() { Y = targetFL.Height-1, Height = 1, Width=Application.GetRealWidth(965), Gravity=Gravity.CenterHorizontal, BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2 }; targetFL.AddChidren(targetLine); //添加目标后的展示列表 TargetListScrolView = new VerticalScrolViewLayout() { Y = targetFL.Bottom, Height = Application.GetRealHeight(TargetListScrolView_RowHeight*2), BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; midFL.AddChidren(TargetListScrolView); confirmBtn = new CommonForm.CompleteButton(1,2,3) { TextID = R.MyInternationalizationString.ConfirmAdd, }; AddChidren(confirmBtn); RefreshTargetListView(); if (!string.IsNullOrEmpty(SceneText)) { sceneNameET.Text = SceneText; } #endregion #region event //记录输入场景名 sceneNameET.TextChangeEventHandler += (sender, e) => { SceneText = sceneNameET.Text.Trim(); }; //选择背景图 EventHandler backGroundIMGHander = (sender, e) => { var localPic = new CategorySceneSelectImgByLocal(); Shared.Phone.UserView.HomePage.Instance.AddChidren(localPic); Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; localPic.Show(); localPic.action = (imgPath) => { backGround.UnSelectedImagePath = imgPath; IconType = 0; }; //var selectDialog = new Dialog() //{ //}; //selectDialog.Show(); //var itemFL = new FrameLayout() //{ // Y = Application.GetRealHeight(1920 - 600), // Width = Application.GetRealWidth(900), // Height = Application.GetRealHeight(550), // Radius = CommonPage.BigFormRadius, // //BackgroundColor=ZigbeeColor.Current.GXCBackgroundColor, // Gravity = Gravity.CenterHorizontal //}; //selectDialog.AddChidren(itemFL); //var localPicBtn = new Button() //{ // Height = Application.GetRealHeight(130) - 1, // TextID = R.MyInternationalizationString.LocalPic, // TextColor = ZigbeeColor.Current.GXCTextBlackColor, // TextAlignment = TextAlignment.Center, // BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor //}; //itemFL.AddChidren(localPicBtn); //var localPicLine = new Button() //{ // Y = localPicBtn.Bottom, // Height = 1, // BackgroundColor = ZigbeeColor.Current.GXCLineColor, //}; //itemFL.AddChidren(localPicLine); //var takePhotoBtn = new Button() //{ // Y = localPicLine.Bottom, // Height = Application.GetRealHeight(130) - 1, // TextID = R.MyInternationalizationString.TakePhoto, // TextColor = ZigbeeColor.Current.GXCTextBlackColor, // TextAlignment = TextAlignment.Center, // BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor //}; //itemFL.AddChidren(takePhotoBtn); //var takePhotoLine = new Button() //{ // Y = takePhotoBtn.Bottom, // Height = 1, // BackgroundColor = ZigbeeColor.Current.GXCLineColor, //}; //itemFL.AddChidren(takePhotoLine); //var systemPicBtn = new Button() //{ // Y = takePhotoLine.Bottom, // Height = Application.GetRealHeight(130), // TextID = R.MyInternationalizationString.SystemPic, // TextColor = ZigbeeColor.Current.GXCTextBlackColor, // TextAlignment = TextAlignment.Center, // BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor //}; //itemFL.AddChidren(systemPicBtn); //var cancelBtn = new Button() //{ // Y = systemPicBtn.Bottom + Application.GetRealHeight(30), // Height = Application.GetRealHeight(150), // TextID = R.MyInternationalizationString.Cancel, // TextColor = ZigbeeColor.Current.GXCTextWhiteColor, // BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor, // TextAlignment = TextAlignment.Center, //}; //itemFL.AddChidren(cancelBtn); ////本地图库 //localPicBtn.MouseUpEventHandler += (send, ee) => //{ // selectDialog.Close(); // var localPic = new CategorySceneSelectImgByLocal(); // Shared.Phone.UserView.HomePage.Instance.AddChidren(localPic); // Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; // localPic.Show(); // localPic.action = () => // { // backGround.UnSelectedImagePath = ImagePath; // IconType = 0; // }; //}; ////拍照 //takePhotoBtn.MouseUpEventHandler += (send, ee) => //{ // var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); // selectDialog.Close(); // Camera.TakePicture((obj) => // { // if (obj == null) // { // return; // } // backGround.UnSelectedImagePath = $"ScenePicture{tradeTime}.png"; // ImagePath = $"{Config.Instance.HomeId}/{backGround.UnSelectedImagePath}"; // IconType = 1; // }, $"ScenePicture{tradeTime}.png"); //}; ////系统图库 //systemPicBtn.MouseUpEventHandler += (send, ee) => //{ // var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); // selectDialog.Close(); // Camera.SelectPicture((obj) => // { // if (obj == null) // { // return; // } // backGround.UnSelectedImagePath = $"ScenePicture{tradeTime}.png"; // ImagePath = $"{Config.Instance.HomeId}/{backGround.UnSelectedImagePath}"; // IconType = 2; // }, $"ScenePicture{tradeTime}.png"); //}; //cancelBtn.MouseUpEventHandler += (send, ee) => //{ // selectDialog.Close(); //}; }; backGround.MouseUpEventHandler += backGroundIMGHander; //区域 EventHandler zoneHander = (sender, e) => { }; zoneRight.MouseUpEventHandler += zoneHander; zoneFL.MouseUpEventHandler += zoneHander; zone.MouseUpEventHandler += zoneHander; //执行目标 EventHandler targetAddHander = (sender, e) => { int selectRow_Height = 130; var selectFL = new FrameLayout() { BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor }; AddChidren(selectFL); var itemFL = new FrameLayout() { Y =Application.GetRealHeight(CommonPage.AppRealHeight - selectRow_Height * 4-20), Height = Application.GetRealHeight(selectRow_Height * 4 + 20) }; selectFL.AddChidren(itemFL); var selectedFunctionBtn = new Device.CommonForm.SelectedStatuButton() { Height = Application.GetRealHeight(selectRow_Height) - 1, TextID = R.MyInternationalizationString.Function, TextColor = ZigbeeColor.Current.GXCTextBlackColor, BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, SelectedBackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor }; itemFL.AddChidren(selectedFunctionBtn); var selectedFunctionLine = new Button() { Y = selectedFunctionBtn.Bottom, Height = 1, BackgroundColor = ZigbeeColor.Current.GXCLineColor, }; itemFL.AddChidren(selectedFunctionLine); var selectedSceneBtn = new Device.CommonForm.SelectedStatuButton() { Y = selectedFunctionLine.Bottom, Height = Application.GetRealHeight(selectRow_Height) - 1, TextID = R.MyInternationalizationString.Scence, TextColor = ZigbeeColor.Current.GXCTextBlackColor, BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, SelectedBackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor }; itemFL.AddChidren(selectedSceneBtn); var selectedSceneLine = new Button() { Y = selectedSceneBtn.Bottom, Height = 1, BackgroundColor = ZigbeeColor.Current.GXCLineColor, }; itemFL.AddChidren(selectedSceneLine); var selectedTimerBtn = new Device.CommonForm.SelectedStatuButton() { Y = selectedSceneLine.Bottom, Height = Application.GetRealHeight(selectRow_Height) -1, TextID = R.MyInternationalizationString.TimeSpan, TextColor = ZigbeeColor.Current.GXCTextBlackColor, BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, SelectedBackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor }; itemFL.AddChidren(selectedTimerBtn); var cancelBtn = new Device.CommonForm.SelectedStatuButton() { Y = selectedTimerBtn.Bottom + Application.GetRealHeight(20), Height = Application.GetRealHeight(selectRow_Height), TextID = R.MyInternationalizationString.Cancel, TextColor = ZigbeeColor.Current.GXCTextBlackColor, BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, SelectedBackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor }; itemFL.AddChidren(cancelBtn); itemFL.Animate = Animate.DownToUp; //添加功能 selectedFunctionBtn.MouseUpEventHandler += (send, ee) => { selectFL.RemoveFromParent(); var deviceTypeList = new CategorySceneSelectDevice(); UserView.HomePage.Instance.AddChidren(deviceTypeList); UserView.HomePage.Instance.PageIndex += 1; deviceTypeList.Show(sceneTargetDevicesList,true); }; //添加场景 selectedSceneBtn.MouseUpEventHandler += (send, ee) => { selectFL.RemoveFromParent(); var sceneView = new CategorySceneSelectedScene(); UserView.HomePage.Instance.AddChidren(sceneView); UserView.HomePage.Instance.PageIndex += 1; sceneView.Show(sceneTargetDevicesList,-1,"",true); }; //添加时间间隔 selectedTimerBtn.MouseUpEventHandler += (send, ee) => { selectFL.RemoveFromParent(); var delayTimeView = new SelectDelayTime(); UserView.HomePage.Instance.AddChidren(delayTimeView); UserView.HomePage.Instance.PageIndex += 1; //delayTimeView.Show(-1,"",-1,true); }; cancelBtn.MouseUpEventHandler += (send, ee) => { selectFL.RemoveFromParent(); }; selectFL.MouseUpEventHandler += (send, ee) => { selectFL.RemoveFromParent(); }; }; targetAdd.MouseUpEventHandler += targetAddHander; targetFL.MouseUpEventHandler += targetAddHander; target.MouseUpEventHandler += targetAddHander; //确定添加目标 confirmBtn.MouseUpEventHandler += async (sender, e) => { if (string.IsNullOrEmpty(sceneNameET.Text)) { 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 { CommonPage.Loading.Start(); var memberDataList = new List(); //累加延时 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 (beforeSceneTarget != null && beforeSceneTarget.Type == 1) { { 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) { AddedDelayTime += beforeSceneTarget.DelayTime; } var memberData = new ZigBee.Device.Scene.AddSceneMemberData { Type = 1, ScenesId = 0, ElseScenesId = sceneTarget.ElseScenesId, DelayTime = AddedDelayTime }; memberDataList.Add(memberData); } } var result = await room.AddScene(sceneNameET.Text, backGround.UnSelectedImagePath, memberDataList, IconType); 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 } } }