| | |
| | | using Shared.Common; |
| | | using Shared.Phone.Device.CommonForm; |
| | | using Shared.Phone.Device.Room; |
| | | using Shared.Phone.UserCenter; |
| | | using static ZigBee.Device.Scene; |
| | | |
| | | namespace Shared.Phone.Device.Category |
| | |
| | | /// <summary> |
| | | /// 添加目标后的展示列表 |
| | | /// </summary> |
| | | public VerticalScrolViewLayout TargetListScrolView; |
| | | public FrameLayout TargetListScrolView; |
| | | /// <summary> |
| | | /// The confirm button. |
| | | /// </summary> |
| | |
| | | /// <summary> |
| | | /// selectedTimeAction |
| | | /// </summary> |
| | | public Action<SceneTargetDeviceUI> selectedAction; |
| | | |
| | | |
| | | private Action<SceneTargetDeviceUI> selectedAction; |
| | | /// <summary> |
| | | /// 修改场景action |
| | | /// </summary> |
| | | public Action<SceneUI, Common.Room> EditorAction; |
| | | /// <summary> |
| | | /// 添加场景action |
| | | /// </summary> |
| | | public Action AddAction; |
| | | |
| | | #endregion |
| | | |
| | |
| | | /// </summary> |
| | | public override void RemoveFromParent() |
| | | { |
| | | Category.instance?.RefreshBodyView(); |
| | | UserView.HomePage.Instance.ScrollEnabled = true; |
| | | base.RemoveFromParent(); |
| | | } |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public void RefreshTargetListView() |
| | | { |
| | | UserView.HomePage.Instance.ScrollEnabled = false; |
| | | TargetListScrolView.RemoveAll(); |
| | | TargetListScrolView.Height = Application.GetRealHeight(173); |
| | | var TargetListScrolBackView = new FrameLayout() |
| | | { |
| | | Height = Application.GetRealHeight(173), |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | TargetListScrolView.AddChidren(TargetListScrolBackView); |
| | | |
| | | if (sceneTargetDevicesList.Count > 0) |
| | | { |
| | | foreach (var targetDevice in sceneTargetDevicesList) |
| | | if (sceneTargetDevicesList.Count > 1) |
| | | { |
| | | TargetListScrolView.Height = Application.GetRealHeight(140 * sceneTargetDevicesList.Count) + Application.GetRealHeight(200); |
| | | TargetListScrolBackView.Height = Application.GetRealHeight(140 * sceneTargetDevicesList.Count + 13); |
| | | } |
| | | |
| | | for (int i = 0; i < sceneTargetDevicesList.Count; i++) |
| | | { |
| | | var targetDevice = sceneTargetDevicesList[i]; |
| | | var targetRowLayout = new RowLayout() |
| | | { |
| | | Height = Application.GetRealHeight(160), |
| | | LineColor = ZigbeeColor.Current.GXCBackgroundColor, |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | Y = Application.GetRealHeight(i * 140), |
| | | Height = Application.GetRealHeight(140), |
| | | LineColor = ZigbeeColor.Current.GXCClearColor, |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, |
| | | SubViewWidth = Application.GetRealWidth(184) |
| | | }; |
| | | TargetListScrolView.AddChidren(targetRowLayout); |
| | | string devImgPath = string.Empty; |
| | |
| | | devImgPath = targetDevice.DeviceUI.IconPath; |
| | | devNameText = targetDevice.DeviceUI.CommonDevice.DeviceEpointName; |
| | | |
| | | var targetRow = new SceneTargetFunctionRow(23); |
| | | targetRowLayout.AddChidren(targetRow); |
| | | var targetRow = new SceneTargetFunctionRow(13); |
| | | targetRow.Init(); |
| | | targetRow.SetIcon(devImgPath); |
| | | targetRow.SetNameText(devNameText); |
| | | targetRow.SetZoneText(targetDevice.DeviceUI.GetZone()); |
| | | targetRow.SetStatuText(targetDevice.GetDeviceStatu()); |
| | | targetRowLayout.AddChidren(targetRow); |
| | | if (i == sceneTargetDevicesList.Count - 1) |
| | | { |
| | | targetRow.HideLine(true); |
| | | } |
| | | } |
| | | else if (targetDevice.Type == 2) |
| | | { |
| | | devNameText = CommonFormResouce.GetTimeString(targetDevice.DelayTime); |
| | | devNameText += Language.StringByID(R.MyInternationalizationString.Later); |
| | | var targetRow = new SceneTargetTimeRow(23); |
| | | targetRowLayout.AddChidren(targetRow); |
| | | var targetRow = new SceneTargetTimeRow(13); |
| | | targetRow.Init(); |
| | | targetRow.SetTitle(devNameText); |
| | | targetRowLayout.AddChidren(targetRow); |
| | | if (i == sceneTargetDevicesList.Count - 1) |
| | | { |
| | | targetRow.HideLine(true); |
| | | } |
| | | } |
| | | else if (targetDevice.Type == 1) |
| | | { |
| | | devImgPath = "Scene/SceneIcon.png"; |
| | | devNameText = targetDevice.SceneName; |
| | | |
| | | var targetRow = new SceneTargetFunctionRow(23); |
| | | targetRowLayout.AddChidren(targetRow); |
| | | var targetRow = new SceneTargetFunctionRow(13); |
| | | targetRow.Init(); |
| | | targetRow.SetIcon(devImgPath); |
| | | targetRow.SetNameText(devNameText); |
| | | targetRow.SetZoneText(targetDevice.SceneUI.GetZone()); |
| | | targetRowLayout.AddChidren(targetRow); |
| | | if (i == sceneTargetDevicesList.Count - 1) |
| | | { |
| | | targetRow.HideLine(true); |
| | | } |
| | | } |
| | | |
| | | var editBtn = new Button() |
| | | { |
| | | BackgroundColor = ZigbeeColor.Current.GXCEditBackGroundColor, |
| | | TextID = R.MyInternationalizationString.Edit, |
| | | TextColor = ZigbeeColor.Current.GXCTextWhiteColor |
| | | }; |
| | | var editBtn = new RowLayoutEditButton(); |
| | | targetRowLayout.AddRightView(editBtn); |
| | | //编辑设备 |
| | | editBtn.MouseUpEventHandler += detailMouseUpEventHandler; |
| | | var delBtn = new Button() |
| | | { |
| | | BackgroundColor = ZigbeeColor.Current.GXCRedColor, |
| | | TextID = R.MyInternationalizationString.Delete, |
| | | TextColor = ZigbeeColor.Current.GXCTextWhiteColor |
| | | }; |
| | | var delBtn = new RowLayoutDeleteButton(); |
| | | targetRowLayout.AddRightView(delBtn); |
| | | //删除设备 |
| | | delBtn.MouseUpEventHandler += (sender, e) => |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (sceneTargetDevicesList.Count > 1) |
| | | { |
| | | var targetRowLayout = new RowLayout() |
| | | { |
| | | Height = Application.GetRealHeight(300), |
| | | LineColor = ZigbeeColor.Current.GXCBackgroundColor, |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | TargetListScrolView.AddChidren(targetRowLayout); |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | private void AddBodyView() |
| | | { |
| | | bodyFrameLayout = new FrameLayout() |
| | | var bodyScrolView=new VerticalScrolViewLayout() |
| | | { |
| | | Y = Application.GetRealHeight(184), |
| | | Height = Application.GetRealHeight(1737), |
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, |
| | | }; |
| | | AddChidren(bodyFrameLayout); |
| | | AddChidren(bodyScrolView); |
| | | |
| | | bodyFrameLayout = new FrameLayout() |
| | | { |
| | | Height = Application.GetRealHeight(1086+127), |
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, |
| | | }; |
| | | bodyScrolView.AddChidren(bodyFrameLayout); |
| | | |
| | | var imgFL = new FrameLayout |
| | | { |
| | |
| | | |
| | | var infoFL = new FrameLayout |
| | | { |
| | | Y = imgFL.Bottom + Application.GetRealHeight(23), |
| | | Height = Application.GetRealHeight(418), |
| | | Y = Application.GetRealHeight(588), |
| | | Height = Application.GetRealHeight(429), |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | bodyFrameLayout.AddChidren(infoFL); |
| | |
| | | TextColor = ZigbeeColor.Current.GXCTextDeepBlackColor, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextSize = 15, |
| | | IsBold=true |
| | | //IsBold=true |
| | | }; |
| | | infoFL.AddChidren(infoEdit); |
| | | |
| | |
| | | |
| | | var targetFL = new FrameLayout() |
| | | { |
| | | Y = infoFL.Bottom + Application.GetRealHeight(23), |
| | | Height = Application.GetRealHeight(730) |
| | | Y = Application.GetRealHeight(1040), |
| | | Height = Application.GetRealHeight(346) |
| | | }; |
| | | bodyFrameLayout.AddChidren(targetFL); |
| | | |
| | |
| | | }; |
| | | addTargetFL.AddChidren(targetLine); |
| | | |
| | | TargetListScrolView = new VerticalScrolViewLayout() |
| | | TargetListScrolView = new FrameLayout() |
| | | { |
| | | Y = Application.GetRealHeight(49+127), |
| | | Height = Application.GetRealHeight(730-127-49), |
| | | Height = Application.GetRealHeight(173) |
| | | }; |
| | | targetFL.AddChidren(TargetListScrolView); |
| | | bodyScrolView.AddChidren(TargetListScrolView); |
| | | |
| | | |
| | | |
| | | confirmBtn = new CommonForm.CompleteButton(1656, 907, 127); |
| | | confirmBtn.TextID = R.MyInternationalizationString.Next; |
| | |
| | | { |
| | | selectFL.RemoveFromParent(); |
| | | var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); |
| | | var fileName = $"SceneIcon_{tradeTime}"; |
| | | var fileName = $"SceneIcon_{tradeTime}.png"; |
| | | //通过相机拍照裁剪 |
| | | CropImage.TakePicture((imagePath) => |
| | | {
|
| | |
| | | if (IconPathType != 0) |
| | | { |
| | | Global.DeleteFilebyHomeId(backGround.ImagePath); |
| | | HdlAutoBackupLogic.DeleteFile(backGround.ImagePath); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | selectFL.RemoveFromParent(); |
| | | var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); |
| | | var fileName = $"SceneIcon_{tradeTime}"; |
| | | var fileName = $"SceneIcon_{tradeTime}.png"; |
| | | //从相册选择图片裁剪 |
| | | CropImage.SelectPicture((imagePath) => |
| | | {
|
| | |
| | | if (IconPathType != 0) |
| | | { |
| | | Global.DeleteFilebyHomeId(backGround.ImagePath); |
| | | HdlAutoBackupLogic.DeleteFile(backGround.ImagePath); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | if (curRoom.IsSharedRoom) |
| | | { |
| | | RemoveFromParent(); |
| | | RoomCommon.ShowTipRoomIsShared(); |
| | | return; |
| | | } |
| | | |
| | |
| | | { |
| | | 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; |
| | | }; |
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.SceneNameCannotBeNull)); |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | try |
| | | { |
| | | var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); |
| | | var fileName = $"SceneIcon_{tradeTime}"; |
| | | var fileName = $"SceneIcon_{tradeTime}.png"; |
| | | if (modifySceneUI.Name != nameRow.NameText.Text.Trim()) |
| | | { |
| | | if (Common.Room.CurrentRoom.GetSameFloorScenes(curRoom.FloorId).Find(s => s.Name == nameRow.NameText.Text.Trim()) != null) |
| | |
| | | if (OldIconPathType != 0) |
| | | { |
| | | Shared.IO.FileUtils.DeleteFile(System.IO.Path.Combine(Config.Instance.FullPath, OldBackgroundImagePath)); |
| | | HdlAutoBackupLogic.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); |
| | | HdlAutoBackupLogic.AddOrEditorFile(System.IO.Path.Combine(Config.Instance.FullPath, fileName)); |
| | | modifySceneUI.IconPath = fileName; |
| | | } |
| | | else |
| | |
| | | Epoint = sceneTarget.DeviceUI.CommonDevice.DeviceEpoint, |
| | | TaskList = sceneTarget.TaskList, |
| | | DelayTime = 0, |
| | | MemberNumber = i+1 |
| | | MemberNumber = i + 1 |
| | | }; |
| | | memberDataList.Add(memberData); |
| | | } |
| | |
| | | ScenesId = 0, |
| | | ElseScenesId = sceneTarget.ElseScenesId, |
| | | DelayTime = 0, |
| | | MemberNumber = i+1 |
| | | MemberNumber = i + 1 |
| | | }; |
| | | memberDataList.Add(memberData); |
| | | } |
| | |
| | | Type = 2, |
| | | ScenesId = 0, |
| | | DelayTime = sceneTarget.DelayTime, |
| | | MemberNumber = i+1 |
| | | MemberNumber = i + 1 |
| | | }; |
| | | memberDataList.Add(memberData); |
| | | } |
| | |
| | | var removeDevice = new ZigBee.Device.Scene.RemoveSceneDeviceListInfo |
| | | { |
| | | Type = 2, |
| | | DelayTime=sceneTarget.DelayTime, |
| | | MemberNumber=sceneTarget.DelayTimeSerialNumber |
| | | DelayTime = sceneTarget.DelayTime, |
| | | MemberNumber = sceneTarget.DelayTimeSerialNumber |
| | | }; |
| | | removeSceneDeviceListInfoList.Add(removeDevice); |
| | | } |
| | |
| | | modifyRoom.Save(); |
| | | curRoom.Save(); |
| | | } |
| | | EditorAction?.Invoke(modifySceneUI, curRoom); |
| | | RemoveFromParent(); |
| | | } |
| | | else if (result == 0) |
| | | { |
| | | Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain); |
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.FailedPleaseTryAgain)); |
| | | } |
| | | else if (result == -1) |
| | | { |
| | | Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); |
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneHadExist)); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | //新增 |
| | | 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; |
| | | }; |
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.SceneNameCannotBeNull)); |
| | | return; |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | imgPath = backGround.ImagePath; |
| | | } |
| | | if (Common.Room.CurrentRoom.GetSameFloorScenes(curRoom.FloorId).Find(s => s.Name == nameRow.NameText.Text.Trim()) != null) |
| | | { |
| | | Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); |
| | | return; |
| | | } |
| | | //if (Common.Room.CurrentRoom.GetSameFloorScenes(curRoom.FloorId).Find(s => s.Name == nameRow.NameText.Text.Trim()) != null) |
| | | //{ |
| | | // CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneHadExist)); |
| | | // return; |
| | | //} |
| | | CommonPage.Loading.Start(); |
| | | var memberDataList = new List<ZigBee.Device.Scene.AddSceneMemberData>(); |
| | | for (int i = 0; i < sceneTargetDevicesList.Count; i++) |
| | |
| | | var result = await curRoom.AddScene(nameRow.NameText.Text, imgPath, memberDataList); |
| | | if (result == 1) |
| | | { |
| | | AddAction?.Invoke(); |
| | | RemoveFromParent(); |
| | | } |
| | | else if (result == 0) |
| | | { |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.AddSceneFail); |
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.AddSceneFail)); |
| | | } |
| | | else if (result == -1) |
| | | { |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); |
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneHadExist)); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |