| | |
| | | /// bodyFrameLayout |
| | | /// </summary> |
| | | private FrameLayout bodyFrameLayout; |
| | | |
| | | /// <summary> |
| | | /// floorIds |
| | | /// </summary> |
| | | List<string> floorIds = new List<string> { }; |
| | | /// <summary> |
| | | /// floorNames |
| | | /// </summary> |
| | | List<string> floorNames = new List<string> { }; |
| | | /// <summary> |
| | | /// roomNames |
| | | /// </summary> |
| | | List<List<string>> roomNames = new List<List<string>> { }; |
| | | /// <summary> |
| | | /// roomNames |
| | | /// </summary> |
| | | List<List<Common.Room>> rooms = new List<List<Common.Room>> { }; |
| | | |
| | | |
| | | #endregion |
| | | |
| | | public static string ImagePath; |
| | | public static string SceneText; |
| | | |
| | | public Common.Room curRoom; |
| | | |
| | | public static List<SceneTargetDeviceUI> sceneTargetDevicesList = new List<SceneTargetDeviceUI> { }; |
| | | /// <summary> |
| | | /// 记录编辑前的设备列表 |
| | | /// ImagePath |
| | | /// </summary> |
| | | public static List<SceneTargetDeviceUI> beforeSceneTargetDevicesList = new List<SceneTargetDeviceUI> { }; |
| | | public static bool Modify = false; |
| | | public static SceneUI ModifySceneUI = null; |
| | | private string ImagePath="SceneIcon/1.png"; |
| | | /// <summary> |
| | | /// 图片来源 0--本地图库 1--拍照 2--系统图库 |
| | | /// curRoom |
| | | /// </summary> |
| | | public static int IconType = 0; |
| | | private Common.Room curRoom; |
| | | /// <summary> |
| | | /// sceneTargetDevicesList |
| | | /// </summary> |
| | | private List<SceneTargetDeviceUI> sceneTargetDevicesList = new List<SceneTargetDeviceUI> { }; |
| | | |
| | | /// <summary> |
| | | /// 添加目标后的展示列表 |
| | |
| | | /// 确定按钮最开始的坐标 |
| | | /// </summary> |
| | | private readonly int ConfirmButton_Y = CommonPage.AppRealHeight - 300; |
| | | /// <summary> |
| | | /// 确定按钮下移后的坐标 |
| | | /// </summary> |
| | | private readonly int ConfirmButton_Change_Y = CommonPage.AppRealHeight - 130; |
| | | /// <summary> |
| | | /// 记录更改前的房间 |
| | | /// </summary> |
| | | private Shared.Common.Room oldRoom; |
| | | |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// CategoryAddScene |
| | | /// </summary> |
| | | public CategoryAddScene() |
| | | { |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; |
| | | Tag = "categoryAddScene"; |
| | | } |
| | | /// <summary> |
| | | /// RemoveFromParent |
| | | /// </summary> |
| | | public override void RemoveFromParent() |
| | | { |
| | | Category.instance?.RefreshBodyView(); |
| | |
| | | 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) |
| | | { |
| | |
| | | } |
| | | var targetRowLayout = new RowLayout() |
| | | { |
| | | Height = Application.GetRealHeight(160), |
| | | LineColor = ZigbeeColor.Current.GXCLineColor, |
| | | Height = Application.GetRealHeight(170) |
| | | BackgroundColor=ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | TargetListScrolView.AddChidren(targetRowLayout); |
| | | |
| | |
| | | TextColor = ZigbeeColor.Current.GXCTextWhiteColor |
| | | }; |
| | | targetRowLayout.AddRightView(devRight); |
| | | //延时 |
| | | devTimer.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | /////******暂时先不加延时,安卓控件有问题*******//// |
| | | var tList = new List<string> { }; |
| | | 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) => |
| | | { |
| | |
| | | //时间间隔 |
| | | else if (targetDevice.Type == 1) |
| | | { |
| | | var delayTimeView = new CategorySceneSelectedDelayTime(); |
| | | var delayTimeView = new SelectDelayTime(); |
| | | UserView.HomePage.Instance.AddChidren(delayTimeView); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | delayTimeView.Show(1, targetDevice.SceneTargetDeviceUIID); |
| | | delayTimeView.sceneTargetDevice = targetDevice; |
| | | delayTimeView.Show(); |
| | | delayTimeView.selectedTimeAction = (second) => |
| | | { |
| | | var targetDeviceUI = sceneTargetDevicesList.Find((obj) => obj.SceneTargetDeviceUIID == second.SceneTargetDeviceUIID); |
| | | if (targetDeviceUI != null) |
| | | { |
| | | targetDeviceUI.DelayTime = second.DelayTime; |
| | | } |
| | | RefreshTargetListView(); |
| | | }; |
| | | } |
| | | //场景 |
| | | else if (targetDevice.Type == 2) |
| | |
| | | /// <summary> |
| | | /// Show this instance. |
| | | /// </summary> |
| | | public void Show(Common.Room room=null) |
| | | public void Show() |
| | | { |
| | | Init(); |
| | | |
| | | curRoom = room; |
| | | |
| | | AddTop(); |
| | | |
| | |
| | | |
| | | #region Add____________________________________ |
| | | |
| | | /// <summary> |
| | | /// Init |
| | | /// </summary> |
| | | private void Init() |
| | | { |
| | | |
| | | foreach (var floor in Config.Instance.Home.FloorDics) |
| | | { |
| | | floorIds.Add(floor.Key); |
| | | floorNames.Add(floor.Value); |
| | | roomNames.Add(Common.Room.CurrentRoom.GetRoomNamesByFloorId(floor.Key)); |
| | | rooms.Add(Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key)); |
| | | 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)); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | RemoveFromParent(); |
| | | }; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | var infoEdit = new Button |
| | | { |
| | | X=Application.GetRealWidth(CommonFormResouce.X_Left), |
| | | X = Application.GetRealWidth(CommonFormResouce.X_Left), |
| | | Height = Application.GetRealHeight(130), |
| | | Width=Application.GetRealWidth(700), |
| | | Width = Application.GetRealWidth(700), |
| | | TextID = R.MyInternationalizationString.EditInfo, |
| | | TextColor = ZigbeeColor.Current.GXCTextDeepBlackColor, |
| | | TextAlignment=TextAlignment.CenterLeft, |
| | | TextSize=14 |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextSize = 14 |
| | | }; |
| | | infoFL.AddChidren(infoEdit); |
| | | |
| | | |
| | | var nameRow = new DeviceInfoEditRow(130); |
| | | nameRow.Init(); |
| | | nameRow.SetTipTitle(R.MyInternationalizationString.SceneName); |
| | | nameRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.SceneName)}:"); |
| | | nameRow.SetPlaceHoldText(R.MyInternationalizationString.PleaseInputSceneName); |
| | | infoFL.AddChidren(nameRow); |
| | | |
| | | var zoneRow = new DeviceInfoRow(257); |
| | | zoneRow.Init(); |
| | | zoneRow.SetTipTitle(R.MyInternationalizationString.BelongZone); |
| | | zoneRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongZone)}:"); |
| | | //zoneRow.SetTitle(curRoom.Name); |
| | | infoFL.AddChidren(zoneRow); |
| | | |
| | | zoneRow.HideLine(false); |
| | | |
| | | var targetFL = new FrameLayout() |
| | | { |
| | | Y = infoFL.Bottom + Application.GetRealHeight(23), |
| | | Height = Application.GetRealHeight(730) |
| | | }; |
| | | bodyFrameLayout.AddChidren(targetFL); |
| | | |
| | | var targetBG = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(334), |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | bodyFrameLayout.AddChidren(targetFL); |
| | | targetFL.AddChidren(targetBG); |
| | | |
| | | var addTargetFL = new FrameLayout |
| | | { |
| | | Y=Application.GetRealHeight(46), |
| | | Height = Application.GetRealHeight(127), |
| | | }; |
| | | targetFL.AddChidren(addTargetFL); |
| | | |
| | | var target = new Button() |
| | | { |
| | | X = Application.GetRealWidth(CommonFormResouce.X_Left), |
| | | Y = Application.GetRealHeight(46), |
| | | Height = Application.GetRealHeight(127) - 1, |
| | | Width = Application.GetRealWidth(600), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor, |
| | | TextID = R.MyInternationalizationString.AddScentTargetAction, |
| | | Gravity = Gravity.CenterVertical |
| | | }; |
| | | targetFL.AddChidren(target); |
| | | addTargetFL.AddChidren(target); |
| | | |
| | | var targetAdd = new SelectedStatuButton() |
| | | var targetAdd = new Button |
| | | { |
| | | X = Application.GetRealWidth(950), |
| | | Y = Application.GetRealHeight(46), |
| | | Width = Application.GetMinRealAverage(72), |
| | | Height = Application.GetMinRealAverage(72), |
| | | Gravity=Gravity.CenterVertical, |
| | | UnSelectedImagePath = "Item/Add.png", |
| | | SelectedImagePath = "Item/AddSelected.png", |
| | | }; |
| | | targetFL.AddChidren(targetAdd); |
| | | addTargetFL.AddChidren(targetAdd); |
| | | var targetLine = new Button() |
| | | { |
| | | Y = target.Bottom, |
| | | Height = 1, |
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2 |
| | | }; |
| | | targetFL.AddChidren(targetLine); |
| | | addTargetFL.AddChidren(targetLine); |
| | | |
| | | //添加目标后的展示列表 |
| | | TargetListScrolView = new VerticalScrolViewLayout() |
| | | { |
| | | Y = targetLine.Bottom, |
| | | Height = Application.GetRealHeight(173), |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | Height = Application.GetRealHeight(730-127), |
| | | //BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | targetFL.AddChidren(TargetListScrolView); |
| | | |
| | |
| | | |
| | | RefreshTargetListView(); |
| | | |
| | | #region 背景图 名称 区域 执行目标 |
| | | |
| | | |
| | | |
| | | if (!string.IsNullOrEmpty(SceneText)) |
| | | { |
| | | nameRow.NameText.Text = SceneText; |
| | | } |
| | | if (curRoom != null) |
| | | { |
| | | |
| | | } |
| | | if (Modify) |
| | | { |
| | | //title.TextID = R.MyInternationalizationString.ModifyScene; |
| | | oldRoom = curRoom; |
| | | if (ModifySceneUI != null && ModifySceneUI.IsSharedScene) |
| | | { |
| | | nameRow.NameText.Enable = false; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region event |
| | | //记录输入场景名 |
| | | nameRow.NameText.TextChangeEventHandler += (sender, e) => |
| | | { |
| | | SceneText = nameRow.NameText.Text.Trim(); |
| | | }; |
| | | |
| | | |
| | | //选择背景图 |
| | | EventHandler<MouseEventArgs> backGroundIMGHander = (sender, e) => |
| | | { |
| | | if (curRoom == null) |
| | | { |
| | | RoomCommon.ShowTipNoRoom(); |
| | | return; |
| | | } |
| | | if (curRoom.IsSharedRoom) |
| | | { |
| | | RoomCommon.ShowTipRoomIsShared(); |
| | | return; |
| | | } |
| | | |
| | | |
| | | var localPic = new CategorySceneSelectImgByLocal(); |
| | | Shared.Phone.UserView.HomePage.Instance.AddChidren(localPic); |
| | | Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; |
| | |
| | | localPic.action = () => |
| | | { |
| | | backGround.UnSelectedImagePath = ImagePath; |
| | | IconType = 0; |
| | | }; |
| | | |
| | | |
| | | }; |
| | | backGround.MouseUpEventHandler += backGroundIMGHander; |
| | | |
| | | |
| | | //区域 |
| | | EventHandler<MouseEventArgs> zoneHander = (sender, e) => |
| | | { |
| | | if (curRoom.IsSharedRoom) |
| | | { |
| | | RoomCommon.ShowTipRoomIsShared(); |
| | | return; |
| | | } |
| | | |
| | | PickerView.ShowSecondary(floorNames, roomNames, (index1,index2) => |
| | | PickerView.ShowSecondary(floorNames, roomNames, (index1, index2) => |
| | | { |
| | | curRoom = rooms[index1][index2]; |
| | | zoneRow.NameText.Text = $"{Config.Instance.Home.GetFloorNameById(floorIds[index1])} , {rooms[index1][index2].Name}"; |
| | | }, 0,0, Language.StringByID(R.MyInternationalizationString.BelongFloor), Language.StringByID(R.MyInternationalizationString.Confrim), Language.StringByID(R.MyInternationalizationString.Cancel)); |
| | | }, 0, 0, Language.StringByID(R.MyInternationalizationString.BelongFloor), Language.StringByID(R.MyInternationalizationString.Confrim), Language.StringByID(R.MyInternationalizationString.Cancel)); |
| | | }; |
| | | zoneRow.NextBtn.MouseUpEventHandler += zoneHander; |
| | | zoneRow.TipBtn.MouseUpEventHandler += zoneHander; |
| | |
| | | //执行目标-添加执行设备 |
| | | EventHandler<MouseEventArgs> targetAddHander = (sender, e) => |
| | | { |
| | | |
| | | if (curRoom == null) |
| | | { |
| | | RoomCommon.ShowTipNoRoom(); |
| | | return; |
| | | } |
| | | if (curRoom.IsSharedRoom) |
| | | { |
| | | RoomCommon.ShowTipRoomIsShared(); |
| | | return; |
| | | } |
| | | |
| | | int selectRow_Height = 130; |
| | | int selectRow_Height = 150; |
| | | int selectRow_Width = 1034; |
| | | var selectFL = new FrameLayout() |
| | | { |
| | | BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor |
| | |
| | | |
| | | var itemFL = new FrameLayout() |
| | | { |
| | | Y = Application.GetRealHeight(CommonPage.AppRealHeight - selectRow_Height * 4 - 20), |
| | | Height = Application.GetRealHeight(selectRow_Height * 4 + 20) |
| | | Y = Application.GetRealHeight(1276), |
| | | Height = Application.GetRealHeight(450), |
| | | Width = Application.GetRealWidth(selectRow_Width), |
| | | Gravity=Gravity.CenterHorizontal, |
| | | Radius = (uint)Application.GetRealHeight(17), |
| | | BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor |
| | | }; |
| | | selectFL.AddChidren(itemFL); |
| | | |
| | | var selectedFunctionBtn = new Device.CommonForm.SelectedStatuButton() |
| | | var selectedFunctionBtn = new Button() |
| | | { |
| | | Height = Application.GetRealHeight(selectRow_Height) - 1, |
| | | TextID = R.MyInternationalizationString.Function, |
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor, |
| | | TextAlignment = TextAlignment.Center, |
| | | BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, |
| | | SelectedBackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor |
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4 |
| | | }; |
| | | itemFL.AddChidren(selectedFunctionBtn); |
| | | var selectedFunctionLine = new Button() |
| | | { |
| | | Y = selectedFunctionBtn.Bottom, |
| | | Height = 1, |
| | | BackgroundColor = ZigbeeColor.Current.GXCLineColor, |
| | | BackgroundColor = ZigbeeColor.Current.GXCLineColor |
| | | }; |
| | | itemFL.AddChidren(selectedFunctionLine); |
| | | |
| | | var selectedSceneBtn = new Device.CommonForm.SelectedStatuButton() |
| | | var selectedSceneBtn = new Button() |
| | | { |
| | | 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 |
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4 |
| | | }; |
| | | itemFL.AddChidren(selectedSceneBtn); |
| | | var selectedSceneLine = new Button() |
| | |
| | | }; |
| | | itemFL.AddChidren(selectedSceneLine); |
| | | |
| | | var selectedTimerBtn = new Device.CommonForm.SelectedStatuButton() |
| | | var selectedTimerBtn = new Button() |
| | | { |
| | | 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 |
| | | TextID = R.MyInternationalizationString.Delay, |
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4 |
| | | }; |
| | | 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; |
| | | var cancelBtn = new Button() |
| | | { |
| | | Y = Application.GetRealHeight(1742), |
| | | Height = Application.GetRealHeight(selectRow_Height), |
| | | Width = Application.GetRealWidth(selectRow_Width), |
| | | Gravity=Gravity.CenterHorizontal, |
| | | TextID = R.MyInternationalizationString.Cancel, |
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4, |
| | | BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, |
| | | Radius = (uint)Application.GetRealHeight(17) |
| | | }; |
| | | selectFL.AddChidren(cancelBtn); |
| | | |
| | | //添加功能 |
| | | selectedFunctionBtn.MouseUpEventHandler += (send, ee) => |
| | | { |
| | |
| | | var sceneView = new CategorySceneSelectedScene(); |
| | | UserView.HomePage.Instance.AddChidren(sceneView); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | if (Modify) |
| | | { |
| | | sceneView.Show(sceneTargetDevicesList, -1, "", false, ModifySceneUI.Id); |
| | | } |
| | | else |
| | | { |
| | | sceneView.Show(sceneTargetDevicesList); |
| | | } |
| | | //if (Modify) |
| | | //{ |
| | | // sceneView.Show(sceneTargetDevicesList, -1, "", false, ModifySceneUI.Id); |
| | | //} |
| | | //else |
| | | //{ |
| | | // sceneView.Show(sceneTargetDevicesList); |
| | | //} |
| | | }; |
| | | //添加时间间隔 |
| | | selectedTimerBtn.MouseUpEventHandler += (send, ee) => |
| | | { |
| | | selectFL.RemoveFromParent(); |
| | | var delayTimeView = new CategorySceneSelectedDelayTime(); |
| | | var delayTimeView = new SelectDelayTime(); |
| | | UserView.HomePage.Instance.AddChidren(delayTimeView); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | delayTimeView.Show(); |
| | | delayTimeView.selectedTimeAction = (second) => |
| | | { |
| | | sceneTargetDevicesList.Add(second); |
| | | RefreshTargetListView(); |
| | | }; |
| | | }; |
| | | |
| | | cancelBtn.MouseUpEventHandler += (send, ee) => |
| | | { |
| | | selectFL.RemoveFromParent(); |
| | |
| | | targetAdd.MouseUpEventHandler += targetAddHander; |
| | | targetFL.MouseUpEventHandler += targetAddHander; |
| | | target.MouseUpEventHandler += targetAddHander; |
| | | addTargetFL.MouseUpEventHandler += targetAddHander; |
| | | //确定添加目标 |
| | | confirmBtn.MouseUpEventHandler += async (sender, e) => |
| | | { |
| | | if (curRoom == null) |
| | | { |
| | | RoomCommon.ShowTipNoRoom(); |
| | | return; |
| | | } |
| | | if (curRoom.IsSharedRoom) |
| | | { |
| | | RemoveFromParent(); |
| | | return; |
| | | } |
| | | if (Modify) |
| | | |
| | | //新增 |
| | | if (string.IsNullOrEmpty(nameRow.NameText.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(); |
| | | //修改--先判断场景名是否改变,再移除设备,再添加设备 |
| | | ModifySceneUI.IconPath = ImagePath; |
| | | if (ModifySceneUI.Name != nameRow.NameText.Text.Trim()) |
| | | if (Shared.Common.Room.AllRoomSceneUIList.Find(s => s.Name == nameRow.NameText.Text.Trim()) != null) |
| | | { |
| | | if (Shared.Common.Room.AllRoomSceneUIList.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; |
| | | } |
| | | Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); |
| | | return; |
| | | } |
| | | //修改设备 |
| | | var memberDataList = new List<AddSceneMemberData>(); |
| | | 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) |
| | |
| | | } |
| | | if (sceneTarget.Type == 0) |
| | | { |
| | | if (sceneTarget.DeviceUI == null || sceneTarget.DeviceUI.CommonDevice == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | if (beforeSceneTarget != null && beforeSceneTarget.Type == 1) |
| | | { |
| | | if (i - 1 >= 0) |
| | |
| | | } |
| | | } |
| | | } |
| | | if (sceneTarget.DeviceUI == null || sceneTarget.DeviceUI.CommonDevice == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var memberData = new ZigBee.Device.Scene.AddSceneMemberData |
| | | { |
| | | DeviceAddr = sceneTarget.DeviceUI.CommonDevice.DeviceAddr, |
| | |
| | | memberDataList.Add(memberData); |
| | | } |
| | | } |
| | | var sceneRemoveMemberData = new SceneRemoveMemberData { }; |
| | | var removeSceneDeviceListInfoList = new List<RemoveSceneDeviceListInfo> { }; |
| | | for (int i = 0; i < beforeSceneTargetDevicesList.Count; i++) |
| | | { |
| | | //合并延时 |
| | | var sceneTarget = beforeSceneTargetDevicesList[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, |
| | | }; |
| | | removeSceneDeviceListInfoList.Add(removeDevice); |
| | | } |
| | | else if (sceneTarget.Type == 2) |
| | | { |
| | | var removeDevice = new ZigBee.Device.Scene.RemoveSceneDeviceListInfo |
| | | { |
| | | Type = 1, |
| | | ElseScenesId = sceneTarget.ElseScenesId |
| | | }; |
| | | removeSceneDeviceListInfoList.Add(removeDevice); |
| | | } |
| | | } |
| | | sceneRemoveMemberData.DeviceList = removeSceneDeviceListInfoList; |
| | | sceneRemoveMemberData.ScenesId = ModifySceneUI.Id; |
| | | var result = await curRoom.ModifyScene(ModifySceneUI, sceneRemoveMemberData, memberDataList); |
| | | |
| | | var result = await curRoom.AddScene(nameRow.NameText.Text, backGround.UnSelectedImagePath, memberDataList); |
| | | if (result == 1) |
| | | { |
| | | if (oldRoom != curRoom) |
| | | { |
| | | oldRoom.SceneUIList.Remove(ModifySceneUI); |
| | | oldRoom.SceneUIFilePathList.Remove(ModifySceneUI.FileName); |
| | | curRoom.SceneUIList.Add(ModifySceneUI); |
| | | curRoom.SceneUIFilePathList.Add(ModifySceneUI.FileName); |
| | | oldRoom.Save(); |
| | | curRoom.Save(); |
| | | } |
| | | |
| | | RemoveFromParent(); |
| | | } |
| | | else if (result == 0) |
| | | { |
| | | //失败 |
| | | Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain); |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.AddSceneFail); |
| | | } |
| | | else if (result == -1) |
| | | { |
| | | //已存在 |
| | | Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | } |
| | | } |
| | | //新增 |
| | | else |
| | | { |
| | | if (string.IsNullOrEmpty(nameRow.NameText.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 |
| | | { |
| | | if (Shared.Common.Room.AllRoomSceneUIList.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>(); |
| | | //累加延时 |
| | | 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) |
| | | { |
| | | System.Console.WriteLine($"分类添加场景出错{ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | }; |
| | | #endregion |
| | | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | } |
| | | } |