| | |
| | | using Shared.Phone.Device.CommonForm; |
| | | using Shared.Phone.Device.Room; |
| | | using Shared.Phone.UserCenter; |
| | | using ZigBee.Device;
|
| | | using static ZigBee.Device.Scene; |
| | | |
| | | namespace Shared.Phone.Device.Category |
| | |
| | | string devNameText = string.Empty; |
| | | if (targetDevice.Type == 0) |
| | | { |
| | | if (targetDevice.DeviceUI == null || targetDevice.DeviceUI.CommonDevice == null) continue; |
| | | if (targetDevice.DeviceUI == null ) continue; |
| | | devImgPath = targetDevice.DeviceUI.IconPath; |
| | | devNameText = targetDevice.DeviceUI.CommonDevice.DeviceEpointName; |
| | | devNameText = Common.LocalDevice.Current.GetDeviceEpointName(targetDevice.DeviceUI); |
| | | |
| | | var targetRow = new SceneTargetFunctionRow(13); |
| | | targetRow.Init(); |
| | | targetRow.SetIcon(devImgPath); |
| | | targetRow.SetNameText(devNameText); |
| | | targetRow.SetZoneText(targetDevice.DeviceUI.GetZone()); |
| | | targetRow.SetZoneText(HdlRoomLogic.Current.GetRoomNameByDevice(targetDevice.DeviceUI, ",")); |
| | | targetRow.SetStatuText(targetDevice.GetDeviceStatu()); |
| | | targetRowLayout.AddChidren(targetRow); |
| | | if (i == sceneTargetDevicesList.Count - 1) |
| | |
| | | targetRow.Init(); |
| | | targetRow.SetIcon(devImgPath); |
| | | targetRow.SetNameText(devNameText); |
| | | targetRow.SetZoneText(targetDevice.SceneUI.GetZone()); |
| | | targetRow.SetZoneText(HdlSceneLogic.Current.GetZoneById(targetDevice.SceneUI.Id)); |
| | | targetRowLayout.AddChidren(targetRow); |
| | | if (i == sceneTargetDevicesList.Count - 1) |
| | | { |
| | |
| | | { |
| | | if (targetDevice.Type == 0) |
| | | { |
| | | if (targetDevice.DeviceUI == null || targetDevice.DeviceUI.CommonDevice == null) |
| | | if (targetDevice.DeviceUI == null) |
| | | { |
| | | return; |
| | | } |
| | |
| | | }; |
| | | bodyFrameLayout.AddChidren(imgFL); |
| | | |
| | | var backGround1 = new ImageView() |
| | | { |
| | | Y = Application.GetRealHeight(46), |
| | | Width = Application.GetMinRealAverage(916), |
| | | Height = Application.GetMinRealAverage(487), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | ImagePath = "Room/Room_Rectangle.png" |
| | | }; |
| | | imgFL.AddChidren(backGround1); |
| | | |
| | | backGround = new ImageView() |
| | | { |
| | | Width = Application.GetMinRealAverage(930), |
| | | Height = Application.GetMinRealAverage(464), |
| | | Gravity = Gravity.Center, |
| | | Y = Application.GetRealHeight(46), |
| | | Width = Application.GetMinRealAverage(887), |
| | | Height = Application.GetMinRealAverage(444), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Radius = (uint)Application.GetMinRealAverage(CommonFormResouce.BigFormRadius), |
| | | ImagePath = "SceneIcon/3.jpg" |
| | | }; |
| | | imgFL.AddChidren(backGround); |
| | | backGround.SetViewShadow(true); |
| | | |
| | | var infoFL = new FrameLayout |
| | | { |
| | |
| | | |
| | | |
| | | confirmBtn = new CommonForm.CompleteButton(1656, 907, 127); |
| | | confirmBtn.TextID = R.MyInternationalizationString.Next; |
| | | confirmBtn.TextID = R.MyInternationalizationString.uFinish; |
| | | AddChidren(confirmBtn); |
| | | |
| | | if (isModify) |
| | |
| | | } |
| | | else |
| | | { |
| | | zoneRow.SetTitle($"{Config.Instance.Home.GetFloorNameById(modifyRoom.FloorId)},{modifyRoom.Name}"); |
| | | zoneRow.SetTitle($"{Config.Instance.Home.GetFloorNameById(modifyRoom.FloorId)},{modifyRoom.Name}"); |
| | | } |
| | | curRoom = modifyRoom; |
| | | sceneTargetDevicesList.AddRange(modifySceneTargetDevicesList); |
| | |
| | | //通过相机拍照裁剪 |
| | | CropImage.TakePicture((imagePath) => |
| | | {
|
| | | if (string.IsNullOrEmpty(imagePath)) |
| | | { |
| | | return; |
| | | } |
| | | if (isModify) |
| | | { |
| | | if (IconPathType != 0) |
| | |
| | | //从相册选择图片裁剪 |
| | | CropImage.SelectPicture((imagePath) => |
| | | {
|
| | | if (string.IsNullOrEmpty(imagePath)) |
| | | { |
| | | return; |
| | | } |
| | | if (isModify) |
| | | { |
| | | if (IconPathType != 0) |
| | |
| | | //区域 |
| | | EventHandler<MouseEventArgs> zoneHander = (sender, e) => |
| | | { |
| | | List<string> floorIds = new List<string> { }; |
| | | List<string> floorNames = new List<string> { }; |
| | | List<List<string>> roomNames = new List<List<string>> { }; |
| | | List<List<Common.Room>> rooms = new List<List<Common.Room>> { }; |
| | | List<Common.Room> rs = new List<Common.Room> { }; |
| | | List<string> rNames = new List<string> { }; |
| | | if (Config.Instance.Home.FloorDics.Count > 0) |
| | | var zone = new SelectZone(); |
| | | zone.Init(); |
| | | zone.ZoneAction += (selectRoom) => |
| | | { |
| | | foreach (var floor in Config.Instance.Home.FloorDics) |
| | | { |
| | | if (Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key).Count > 0) |
| | | { |
| | | floorIds.Add(floor.Key); |
| | | floorNames.Add(floor.Value); |
| | | |
| | | roomNames.Add(Common.Room.CurrentRoom.GetRoomNamesByFloorId(floor.Key)); |
| | | rooms.Add(Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key)); |
| | | } |
| | | } |
| | | PickerView.ShowSecondary(floorNames, roomNames, (index1, index2) => |
| | | { |
| | | curRoom = rooms[index1][index2]; |
| | | zoneRow.SetTitle($"{Config.Instance.Home.GetFloorNameById(floorIds[index1])} , {rooms[index1][index2].Name}"); |
| | | }, 0, 0, Language.StringByID(R.MyInternationalizationString.BelongZone), |
| | | Language.StringByID(R.MyInternationalizationString.Confrim), |
| | | Language.StringByID(R.MyInternationalizationString.Cancel)); |
| | | } |
| | | else |
| | | { |
| | | for (int i = 0; i < Common.Room.Lists.Count; i++) |
| | | { |
| | | var r = Common.Room.Lists[i]; |
| | | if (r.IsLove) |
| | | { |
| | | continue; |
| | | } |
| | | rs.Add(r); |
| | | rNames.Add(r.Name); |
| | | } |
| | | PickerView.Show(rNames, (index1) => |
| | | { |
| | | curRoom = rs[index1]; |
| | | zoneRow.SetTitle(rs[index1].Name); |
| | | }, 0, Language.StringByID(R.MyInternationalizationString.BelongZone), |
| | | Language.StringByID(R.MyInternationalizationString.Confrim), |
| | | Language.StringByID(R.MyInternationalizationString.Cancel)); |
| | | } |
| | | curRoom = selectRoom; |
| | | zoneRow.SetTitle(HdlRoomLogic.Current.GetZoneName(selectRoom)); |
| | | }; |
| | | }; |
| | | zoneRow.ClickBtn.MouseUpEventHandler += zoneHander; |
| | | |
| | |
| | | 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 (HdlSceneLogic.Current.GetSameFloorScenes(curRoom.FloorId).Find(s => s.Name == nameRow.NameText.Text.Trim()) != null) |
| | | { |
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneHadExist)); |
| | | return; |
| | |
| | | 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)); |
| | | |
| | | HdlAutoBackupLogic.DeleteFile(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)); |
| | | HdlAutoBackupLogic.AddOrEditorFile(fileName); |
| | | modifySceneUI.IconPath = fileName; |
| | | } |
| | | else |
| | |
| | | |
| | | if (sceneTarget.Type == 0) |
| | | { |
| | | if (sceneTarget.DeviceUI == null || sceneTarget.DeviceUI.CommonDevice == null) |
| | | if (sceneTarget.DeviceUI == null) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | { |
| | | Type = 0, |
| | | ScenesId = 0, |
| | | DeviceAddr = sceneTarget.DeviceUI.CommonDevice.DeviceAddr, |
| | | Epoint = sceneTarget.DeviceUI.CommonDevice.DeviceEpoint, |
| | | DeviceAddr = sceneTarget.DeviceUI.DeviceAddr, |
| | | Epoint = sceneTarget.DeviceUI.DeviceEpoint, |
| | | TaskList = sceneTarget.TaskList, |
| | | DelayTime = 0, |
| | | MemberNumber = i + 1 |
| | |
| | | var sceneTarget = modifySceneTargetDevicesList[i]; |
| | | if (sceneTarget.Type == 0) |
| | | { |
| | | if (sceneTarget.DeviceUI == null || sceneTarget.DeviceUI.CommonDevice == null) |
| | | if (sceneTarget.DeviceUI == null) |
| | | { |
| | | continue; |
| | | } |
| | | var removeDevice = new RemoveSceneDeviceListInfo |
| | | { |
| | | Type = 0, |
| | | DeviceAddr = sceneTarget.DeviceUI.CommonDevice.DeviceAddr, |
| | | Epoint = sceneTarget.DeviceUI.CommonDevice.DeviceEpoint, |
| | | DeviceAddr = sceneTarget.DeviceUI.DeviceAddr, |
| | | Epoint = sceneTarget.DeviceUI.DeviceEpoint, |
| | | MemberNumber = sceneTarget.DelayTimeSerialNumber |
| | | }; |
| | | removeSceneDeviceListInfoList.Add(removeDevice); |
| | |
| | | } |
| | | sceneRemoveMemberData.DeviceList = removeSceneDeviceListInfoList; |
| | | sceneRemoveMemberData.ScenesId = modifySceneUI.Id; |
| | | var result = await curRoom.ModifyScene(modifySceneUI, sceneRemoveMemberData, memberDataList); |
| | | var result = await HdlSceneLogic.Current.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.ListSceneId.Remove(modifySceneUI.Id); |
| | | curRoom.ListSceneId.Add(modifySceneUI.Id); |
| | | modifyRoom.Save(); |
| | | curRoom.Save(); |
| | | } |
| | |
| | | if (IconPathType == 1 || IconPathType == 2) |
| | | { |
| | | Shared.IO.FileUtils.WriteFileByBytes(System.IO.Path.Combine(Config.Instance.FullPath, fileName), backGround.ImageBytes); |
| | | HdlAutoBackupLogic.AddOrEditorFile(fileName); |
| | | imgPath = fileName; |
| | | } |
| | | else |
| | |
| | | |
| | | if (sceneTarget.Type == 0) |
| | | { |
| | | if (sceneTarget.DeviceUI == null || sceneTarget.DeviceUI.CommonDevice == null) |
| | | if (sceneTarget.DeviceUI == null) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | { |
| | | Type = 0, |
| | | ScenesId = 0, |
| | | DeviceAddr = sceneTarget.DeviceUI.CommonDevice.DeviceAddr, |
| | | Epoint = sceneTarget.DeviceUI.CommonDevice.DeviceEpoint, |
| | | DeviceAddr = sceneTarget.DeviceUI.DeviceAddr, |
| | | Epoint = sceneTarget.DeviceUI.DeviceEpoint, |
| | | TaskList = sceneTarget.TaskList, |
| | | DelayTime = 0, |
| | | MemberNumber = i+1 |
| | |
| | | } |
| | | } |
| | | |
| | | var result = await curRoom.AddScene(nameRow.NameText.Text, imgPath, memberDataList); |
| | | var result = await HdlSceneLogic.Current.AddScene(curRoom, nameRow.NameText.Text, imgPath, memberDataList, IconPathType); |
| | | if (result == 1) |
| | | { |
| | | AddAction?.Invoke(); |
| | |
| | | /// ShowSelectAction |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | private void ShowSelectAction(DeviceUI device, SceneTargetDeviceUI sceneTarget) |
| | | private void ShowSelectAction(CommonDevice device, SceneTargetDeviceUI sceneTarget) |
| | | { |
| | | var dialog = new FrameLayout() |
| | | { |
| | |
| | | dialog.RemoveFromParent(); |
| | | }; |
| | | |
| | | if (device.CommonDevice.Type == ZigBee.Device.DeviceType.OnOffOutput) |
| | | if (device.Type == ZigBee.Device.DeviceType.OnOffOutput) |
| | | { |
| | | SelectOnoffOutput(dialog, device, sceneTarget); |
| | | } |
| | | else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.AirSwitch) |
| | | else if (device.Type == ZigBee.Device.DeviceType.AirSwitch) |
| | | { |
| | | SelectOnoffOutput(dialog, device, sceneTarget); |
| | | } |
| | | else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.DimmableLight) |
| | | else if (device.Type == ZigBee.Device.DeviceType.DimmableLight) |
| | | { |
| | | SelectDimmableLight(dialog, device, sceneTarget); |
| | | } |
| | | else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.WindowCoveringDevice) |
| | | else if (device.Type == ZigBee.Device.DeviceType.WindowCoveringDevice) |
| | | { |
| | | SelectWindowCoveringDevice(dialog, device, sceneTarget); |
| | | } |
| | | else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.Thermostat) |
| | | else if (device.Type == ZigBee.Device.DeviceType.Thermostat) |
| | | { |
| | | SelectThermostat(dialog, device, sceneTarget); |
| | | } |
| | |
| | | /// <param name="dialog"></param> |
| | | /// <param name="device"></param> |
| | | /// <param name="sceneTarget"></param> |
| | | private void SelectOnoffOutput(FrameLayout dialog, DeviceUI device, SceneTargetDeviceUI sceneTarget) |
| | | private void SelectOnoffOutput(FrameLayout dialog, CommonDevice device, SceneTargetDeviceUI sceneTarget) |
| | | { |
| | | var selectFL = new FrameLayout |
| | | { |
| | |
| | | Gravity = Gravity.CenterHorizontal, |
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor, |
| | | TextSize = 16, |
| | | Text = device.CommonDevice.DeviceEpointName |
| | | Text = Common.LocalDevice.Current.GetDeviceEpointName(device) |
| | | }; |
| | | titleFL.AddChidren(deviceName); |
| | | |
| | |
| | | /// <param name="dialog"></param> |
| | | /// <param name="device"></param> |
| | | /// <param name="sceneTarget"></param> |
| | | private void SelectWindowCoveringDevice(FrameLayout dialog, DeviceUI device, SceneTargetDeviceUI sceneTarget) |
| | | private void SelectWindowCoveringDevice(FrameLayout dialog, CommonDevice device, SceneTargetDeviceUI sceneTarget) |
| | | { |
| | | var selectFL = new FrameLayout |
| | | { |
| | |
| | | Gravity = Gravity.CenterHorizontal, |
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor, |
| | | TextSize = 16, |
| | | Text = device.CommonDevice.DeviceEpointName |
| | | Text = Common.LocalDevice.Current.GetDeviceEpointName(device) |
| | | }; |
| | | titleFL.AddChidren(deviceName); |
| | | |
| | |
| | | dialog.RemoveFromParent(); |
| | | }; |
| | | |
| | | open.SeekBar.ProgressChanged += (sender, e) => |
| | | open.SeekBar.OnProgressChangedEvent += (sender, e) => |
| | | { |
| | | open.IsSelected = true; |
| | | shut.IsSelected = false; |
| | |
| | | { |
| | | open.IsSelected = true; |
| | | shut.IsSelected = false; |
| | | open.SetProgress(sceneTarget.TaskList[0].Data2); |
| | | open.SetSeekBarProgress(sceneTarget.TaskList[0].Data2); |
| | | } |
| | | } |
| | | |
| | |
| | | /// <param name="dialog"></param> |
| | | /// <param name="device"></param> |
| | | /// <param name="sceneTarget"></param> |
| | | private void SelectDimmableLight(FrameLayout dialog, DeviceUI device, SceneTargetDeviceUI sceneTarget) |
| | | private void SelectDimmableLight(FrameLayout dialog, CommonDevice device, SceneTargetDeviceUI sceneTarget) |
| | | { |
| | | var selectFL = new FrameLayout |
| | | { |
| | |
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor, |
| | | TextSize = 16, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Text = device.CommonDevice.DeviceEpointName |
| | | Text = Common.LocalDevice.Current.GetDeviceEpointName(device) |
| | | }; |
| | | titleFL.AddChidren(deviceName); |
| | | |
| | |
| | | dialog.RemoveFromParent(); |
| | | }; |
| | | |
| | | open.SeekBar.ProgressChanged += (sender, e) => |
| | | open.SeekBar.OnProgressChangedEvent += (sender, e) => |
| | | { |
| | | open.IsSelected = true; |
| | | shut.IsSelected = false; |
| | |
| | | { |
| | | open.IsSelected = true; |
| | | shut.IsSelected = false; |
| | | open.SetProgress(sceneTarget.TaskList[0].Data1); |
| | | open.SetSeekBarProgress(sceneTarget.TaskList[0].Data1); |
| | | } |
| | | } |
| | | |
| | |
| | | /// <param name="dialog"></param> |
| | | /// <param name="device"></param> |
| | | /// <param name="sceneTarget"></param> |
| | | private void SelectThermostat(FrameLayout dialog, DeviceUI device, SceneTargetDeviceUI sceneTarget) |
| | | private void SelectThermostat(FrameLayout dialog, CommonDevice device, SceneTargetDeviceUI sceneTarget) |
| | | { |
| | | /// 温度 |
| | | int tempId=0; |
| | |
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor, |
| | | TextSize = 16, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Text = device.CommonDevice.DeviceEpointName |
| | | Text = Common.LocalDevice.Current.GetDeviceEpointName(device) |
| | | }; |
| | | titleFL.AddChidren(deviceName); |
| | | |