| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Globalization; |
| | | using Shared.Common; |
| | | using Shared.Phone.Device.CommonForm; |
| | | using Shared.Phone.Device.Room; |
| | | using static ZigBee.Device.Scene; |
| | | |
| | | namespace Shared.Phone.Device.Category |
| | | { |
| | | public class CategoryAddScene : FrameLayout |
| | | { |
| | | #region ◆ 变量____________________________ |
| | | /// <summary> |
| | | /// bodyFrameLayout |
| | | /// </summary> |
| | | private FrameLayout bodyFrameLayout; |
| | | |
| | | #endregion |
| | | |
| | | public static string ImagePath; |
| | | public static string SceneText; |
| | | |
| | | public static Shared.Common.Room CurrentRoom; |
| | | |
| | | public static List<SceneTargetDeviceUI> sceneTargetDevicesList = new List<SceneTargetDeviceUI> { }; |
| | | /// <summary> |
| | | /// 记录编辑前的设备列表 |
| | | /// </summary> |
| | | public static List<SceneTargetDeviceUI> beforeSceneTargetDevicesList = new List<SceneTargetDeviceUI> { }; |
| | | public static bool Modify = false; |
| | | public static SceneUI ModifySceneUI = null; |
| | | /// <summary> |
| | | /// 图片来源 0--本地图库 1--拍照 2--系统图库 |
| | | /// </summary> |
| | | public static int IconType = 0; |
| | | |
| | | /// <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; |
| | | /// <summary> |
| | | /// 确定按钮下移后的坐标 |
| | | /// </summary> |
| | | private readonly int ConfirmButton_Change_Y = CommonPage.AppRealHeight - 130; |
| | | /// <summary> |
| | | /// 记录更改前的房间 |
| | | /// </summary> |
| | | private Shared.Common.Room oldRoom; |
| | | |
| | | public CategoryAddScene() |
| | | { |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; |
| | | Tag = "categoryAddScene"; |
| | | } |
| | | public override void RemoveFromParent() |
| | | { |
| | | Category.instance?.RefreshBodyView(); |
| | | base.RemoveFromParent(); |
| | | } |
| | | /// <summary> |
| | | ///刷新添加目标后的展示列表 |
| | | /// </summary> |
| | | 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 targetFL = new FrameLayout() |
| | | { |
| | | |
| | | }; |
| | | 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() |
| | | { |
| | | BackgroundColor = ZigbeeColor.Current.GXCRedColor, |
| | | TextID = R.MyInternationalizationString.Delete, |
| | | 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) => |
| | | { |
| | | 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); |
| | | } |
| | | 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); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | //时间间隔 |
| | | else if (targetDevice.Type == 1) |
| | | { |
| | | var delayTimeView = new CategorySceneSelectedDelayTime(); |
| | | UserView.HomePage.Instance.AddChidren(delayTimeView); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | delayTimeView.Show(1, targetDevice.SceneTargetDeviceUIID); |
| | | } |
| | | //场景 |
| | | 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); |
| | | } |
| | | } |
| | | devIMG.MouseUpEventHandler += detailMouseUpEventHandler; |
| | | devName.MouseUpEventHandler += detailMouseUpEventHandler; |
| | | targetRowLayout.MouseUpEventHandler += detailMouseUpEventHandler; |
| | | targetFL.MouseUpEventHandler += detailMouseUpEventHandler; |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// Show this instance. |
| | | /// </summary> |
| | | public void Show() |
| | | { |
| | | AddTop(); |
| | | |
| | | AddBodyView(); |
| | | |
| | | } |
| | | |
| | | #region Add____________________________________ |
| | | |
| | | /// <summary> |
| | | /// AddTop |
| | | /// </summary> |
| | | public void AddTop() |
| | | { |
| | | var top = new TopFrameLayout(); |
| | | AddChidren(top); |
| | | top.InitTopview(); |
| | | top.SetTopTitle(R.MyInternationalizationString.AddScence); |
| | | top.backButton.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | RemoveFromParent(); |
| | | }; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// AddBodyView |
| | | /// </summary> |
| | | public void AddBodyView() |
| | | { |
| | | bodyFrameLayout = new FrameLayout() |
| | | { |
| | | Y = Application.GetRealHeight(184), |
| | | Height = Application.GetRealHeight(1737), |
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, |
| | | }; |
| | | AddChidren(bodyFrameLayout); |
| | | |
| | | var imgFL = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(556), |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | bodyFrameLayout.AddChidren(imgFL); |
| | | |
| | | var backGround = new Button() |
| | | { |
| | | Width = Application.GetRealWidth(930), |
| | | Height = Application.GetRealHeight(464), |
| | | Gravity = Gravity.Center, |
| | | Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius), |
| | | UnSelectedImagePath = ImagePath |
| | | }; |
| | | imgFL.AddChidren(backGround); |
| | | |
| | | var infoFL = new FrameLayout |
| | | { |
| | | Y = imgFL.Bottom + Application.GetRealHeight(23), |
| | | Height = Application.GetRealHeight(418), |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | bodyFrameLayout.AddChidren(infoFL); |
| | | |
| | | var infoEdit = new Button |
| | | { |
| | | X=Application.GetRealWidth(CommonFormResouce.X_Left), |
| | | Height = Application.GetRealHeight(130), |
| | | Width=Application.GetRealWidth(700), |
| | | TextID = R.MyInternationalizationString.EditInfo, |
| | | TextColor = ZigbeeColor.Current.GXCTextDeepBlackColor, |
| | | TextAlignment=TextAlignment.CenterLeft, |
| | | TextSize=14 |
| | | }; |
| | | infoFL.AddChidren(infoEdit); |
| | | |
| | | |
| | | var nameRow = new DeviceInfoEditRow(130); |
| | | nameRow.Init(); |
| | | nameRow.SetTipTitle(R.MyInternationalizationString.SceneName); |
| | | nameRow.SetPlaceHoldText(R.MyInternationalizationString.PleaseInputSceneName); |
| | | infoFL.AddChidren(nameRow); |
| | | |
| | | var zoneRow = new DeviceInfoRow(257); |
| | | zoneRow.Init(); |
| | | zoneRow.SetTipTitle(R.MyInternationalizationString.BelongZone); |
| | | zoneRow.SetTitle(CurrentRoom.Name); |
| | | infoFL.AddChidren(zoneRow); |
| | | |
| | | var targetFL = new FrameLayout() |
| | | { |
| | | Y = infoFL.Bottom + Application.GetRealHeight(23), |
| | | Height = Application.GetRealHeight(334), |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | bodyFrameLayout.AddChidren(targetFL); |
| | | |
| | | 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, |
| | | }; |
| | | targetFL.AddChidren(target); |
| | | |
| | | var targetAdd = new SelectedStatuButton() |
| | | { |
| | | X = Application.GetRealWidth(950), |
| | | Y = Application.GetRealHeight(46), |
| | | Width = Application.GetMinRealAverage(72), |
| | | Height = Application.GetMinRealAverage(72), |
| | | UnSelectedImagePath = "Item/Add.png", |
| | | SelectedImagePath = "Item/AddSelected.png", |
| | | }; |
| | | targetFL.AddChidren(targetAdd); |
| | | var targetLine = new Button() |
| | | { |
| | | Y = target.Bottom, |
| | | Height = 1, |
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2 |
| | | }; |
| | | targetFL.AddChidren(targetLine); |
| | | |
| | | //添加目标后的展示列表 |
| | | TargetListScrolView = new VerticalScrolViewLayout() |
| | | { |
| | | Y = targetLine.Bottom, |
| | | Height = Application.GetRealHeight(173), |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | targetFL.AddChidren(TargetListScrolView); |
| | | |
| | | confirmBtn = new CommonForm.CompleteButton(1656, 907, 127); |
| | | AddChidren(confirmBtn); |
| | | |
| | | RefreshTargetListView(); |
| | | |
| | | #region 背景图 名称 区域 执行目标 |
| | | |
| | | |
| | | |
| | | if (!string.IsNullOrEmpty(SceneText)) |
| | | { |
| | | nameRow.NameText.Text = SceneText; |
| | | } |
| | | if (CurrentRoom != null) |
| | | { |
| | | |
| | | } |
| | | if (Modify) |
| | | { |
| | | //title.TextID = R.MyInternationalizationString.ModifyScene; |
| | | oldRoom = CurrentRoom; |
| | | 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 (CurrentRoom.IsSharedRoom) |
| | | { |
| | | RoomCommon.ShowTipRoomIsShared(); |
| | | return; |
| | | } |
| | | |
| | | 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; |
| | | }; |
| | | |
| | | |
| | | }; |
| | | backGround.MouseUpEventHandler += backGroundIMGHander; |
| | | //区域 |
| | | EventHandler<MouseEventArgs> zoneHander = (sender, e) => |
| | | { |
| | | if (CurrentRoom.IsSharedRoom) |
| | | { |
| | | RoomCommon.ShowTipRoomIsShared(); |
| | | return; |
| | | } |
| | | var selectRoom = new CategorySceneSelectRoomList(); |
| | | UserView.HomePage.Instance.AddChidren(selectRoom); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | selectRoom.SelectedRoomAction = (room) => |
| | | { |
| | | CurrentRoom = room; |
| | | zoneRow.NameText.Text = CurrentRoom.Name; |
| | | }; |
| | | selectRoom.Show(); |
| | | }; |
| | | zoneRow.NextBtn.MouseUpEventHandler += zoneHander; |
| | | zoneRow.TipBtn.MouseUpEventHandler += zoneHander; |
| | | zoneRow.MouseUpEventHandler += zoneHander; |
| | | //执行目标-添加执行设备 |
| | | EventHandler<MouseEventArgs> targetAddHander = (sender, e) => |
| | | { |
| | | if (CurrentRoom.IsSharedRoom) |
| | | { |
| | | RoomCommon.ShowTipRoomIsShared(); |
| | | return; |
| | | } |
| | | |
| | | 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, |
| | | TextAlignment = TextAlignment.Center, |
| | | 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); |
| | | }; |
| | | //添加场景 |
| | | selectedSceneBtn.MouseUpEventHandler += (send, ee) => |
| | | { |
| | | selectFL.RemoveFromParent(); |
| | | 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); |
| | | } |
| | | }; |
| | | //添加时间间隔 |
| | | selectedTimerBtn.MouseUpEventHandler += (send, ee) => |
| | | { |
| | | selectFL.RemoveFromParent(); |
| | | var delayTimeView = new CategorySceneSelectedDelayTime(); |
| | | UserView.HomePage.Instance.AddChidren(delayTimeView); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | delayTimeView.Show(); |
| | | }; |
| | | 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 (CurrentRoom.IsSharedRoom) |
| | | { |
| | | RemoveFromParent(); |
| | | return; |
| | | } |
| | | if (Modify) |
| | | { |
| | | 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) |
| | | { |
| | | 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; |
| | | } |
| | | } |
| | | //修改设备 |
| | | var memberDataList = new List<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 (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; |
| | | } |
| | | } |
| | | } |
| | | if (sceneTarget.DeviceUI == null || sceneTarget.DeviceUI.CommonDevice == null) |
| | | { |
| | | continue; |
| | | } |
| | | 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 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 CurrentRoom.ModifyScene(ModifySceneUI, sceneRemoveMemberData, memberDataList); |
| | | if (result == 1) |
| | | { |
| | | if (oldRoom != CurrentRoom) |
| | | { |
| | | oldRoom.SceneUIList.Remove(ModifySceneUI); |
| | | oldRoom.SceneUIFilePathList.Remove(ModifySceneUI.FileName); |
| | | CurrentRoom.SceneUIList.Add(ModifySceneUI); |
| | | CurrentRoom.SceneUIFilePathList.Add(ModifySceneUI.FileName); |
| | | oldRoom.Save(); |
| | | CurrentRoom.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 |
| | | { |
| | | 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 CurrentRoom.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 |
| | | } |
| | | } |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Globalization;
|
| | | using Shared.Common;
|
| | | 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
|
| | | {
|
| | | public class CategoryAddScene : FrameLayout
|
| | | {
|
| | | #region ◆ 变量____________________________
|
| | | /// <summary>
|
| | | /// 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>> { };
|
| | | /// <summary>
|
| | | /// ImagePath
|
| | | /// </summary>
|
| | | private string ImagePath = "SceneIcon/1.png";
|
| | | /// <summary>
|
| | | /// 图片来源 0--本地图库 1--拍照 2--系统图库
|
| | | /// </summary>
|
| | | public int IconPathType = 0;
|
| | | /// <summary>
|
| | | /// curRoom
|
| | | /// </summary>
|
| | | private Common.Room curRoom;
|
| | | /// <summary>
|
| | | /// sceneTargetDevicesList
|
| | | /// </summary>
|
| | | private List<SceneTargetDeviceUI> sceneTargetDevicesList = new List<SceneTargetDeviceUI> { };
|
| | | /// <summary>
|
| | | /// 添加目标后的展示列表
|
| | | /// </summary>
|
| | | public FrameLayout TargetListScrolView;
|
| | | /// <summary>
|
| | | /// The confirm button.
|
| | | /// </summary>
|
| | | private CommonForm.CompleteButton confirmBtn;
|
| | |
|
| | | /// <summary>
|
| | | /// backGround
|
| | | /// </summary>
|
| | | private ImageView backGround;
|
| | |
|
| | | /// <summary>
|
| | | /// 是否修改
|
| | | /// </summary>
|
| | | public bool isModify;
|
| | | /// <summary>
|
| | | /// 修改的场景
|
| | | /// </summary>
|
| | | public SceneUI modifySceneUI;
|
| | | /// <summary>
|
| | | /// 记录编辑前的设备列表
|
| | | /// </summary>
|
| | | public List<SceneTargetDeviceUI> modifySceneTargetDevicesList;
|
| | | /// <summary>
|
| | | /// modifyRoom
|
| | | /// </summary>
|
| | | public Common.Room modifyRoom;
|
| | |
|
| | | /// <summary>
|
| | | /// OldBackgroundImagePath
|
| | | /// </summary>
|
| | | private string OldBackgroundImagePath;
|
| | | /// <summary>
|
| | | /// OldIconPathType
|
| | | /// </summary>
|
| | | public int OldIconPathType;
|
| | |
|
| | | /// <summary>
|
| | | /// selectedTimeAction
|
| | | /// </summary>
|
| | | private Action<SceneTargetDeviceUI> selectedAction;
|
| | | /// <summary>
|
| | | /// 修改场景action
|
| | | /// </summary>
|
| | | public Action<SceneUI, Common.Room> EditorAction;
|
| | | /// <summary>
|
| | | /// 添加场景action
|
| | | /// </summary>
|
| | | public Action AddAction;
|
| | |
|
| | | #endregion
|
| | |
|
| | | /// <summary>
|
| | | /// CategoryAddScene
|
| | | /// </summary>
|
| | | public CategoryAddScene()
|
| | | {
|
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
|
| | | }
|
| | | /// <summary>
|
| | | /// RemoveFromParent
|
| | | /// </summary>
|
| | | public override void RemoveFromParent()
|
| | | {
|
| | | 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)
|
| | | {
|
| | | 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()
|
| | | {
|
| | | 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;
|
| | | string devNameText = string.Empty;
|
| | | if (targetDevice.Type == 0)
|
| | | {
|
| | | if (targetDevice.DeviceUI == null) continue;
|
| | | devImgPath = targetDevice.DeviceUI.IconPath;
|
| | | devNameText = Common.LocalDevice.Current.GetDeviceEpointName(targetDevice.DeviceUI);
|
| | |
|
| | | var targetRow = new SceneTargetFunctionRow(13);
|
| | | targetRow.Init();
|
| | | targetRow.SetIcon(devImgPath);
|
| | | targetRow.SetNameText(devNameText);
|
| | | targetRow.SetZoneText(HdlRoomLogic.Current.GetRoomNameByDevice(targetDevice.DeviceUI, ","));
|
| | | 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(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(13);
|
| | | targetRow.Init();
|
| | | targetRow.SetIcon(devImgPath);
|
| | | targetRow.SetNameText(devNameText);
|
| | | targetRow.SetZoneText(HdlSceneLogic.Current.GetZoneById(targetDevice.SceneUI.Id));
|
| | | targetRowLayout.AddChidren(targetRow);
|
| | | if (i == sceneTargetDevicesList.Count - 1)
|
| | | {
|
| | | targetRow.HideLine(true);
|
| | | }
|
| | | }
|
| | |
|
| | | var editBtn = new RowLayoutEditButton();
|
| | | targetRowLayout.AddRightView(editBtn);
|
| | | //编辑设备
|
| | | editBtn.MouseUpEventHandler += detailMouseUpEventHandler;
|
| | | var delBtn = new RowLayoutDeleteButton();
|
| | | targetRowLayout.AddRightView(delBtn);
|
| | | //删除设备
|
| | | delBtn.MouseUpEventHandler += (sender, e) =>
|
| | | {
|
| | | sceneTargetDevicesList.Remove(targetDevice);
|
| | | RefreshTargetListView();
|
| | | };
|
| | |
|
| | | //设备详细设置界面
|
| | | void detailMouseUpEventHandler(object sender, MouseEventArgs e)
|
| | | {
|
| | | if (targetDevice.Type == 0)
|
| | | {
|
| | | if (targetDevice.DeviceUI == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | ShowSelectAction(targetDevice.DeviceUI, targetDevice);
|
| | | 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 == 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) =>
|
| | | {
|
| | | var targetDeviceUI = sceneTargetDevicesList.Find((obj) => obj.SceneTargetDeviceUIID == second.SceneTargetDeviceUIID);
|
| | | if (targetDeviceUI != null)
|
| | | {
|
| | | targetDeviceUI.DelayTime = second.DelayTime;
|
| | | }
|
| | | RefreshTargetListView();
|
| | | };
|
| | | }
|
| | | else if (targetDevice.Type == 1)
|
| | | {
|
| | | var sceneView = new SelectScene();
|
| | | UserView.HomePage.Instance.AddChidren(sceneView);
|
| | | UserView.HomePage.Instance.PageIndex += 1;
|
| | | sceneView.sceneTargetDevice = targetDevice;
|
| | | sceneView.sceneUI = targetDevice.SceneUI;
|
| | | sceneView.currentSceneUI = modifySceneUI;
|
| | | 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();
|
| | | };
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | /// <summary>
|
| | | /// Show this instance.
|
| | | /// </summary>
|
| | | public void Show()
|
| | | {
|
| | | Init();
|
| | |
|
| | | AddTop();
|
| | |
|
| | | AddBodyView();
|
| | |
|
| | | }
|
| | |
|
| | | #region Add____________________________________
|
| | |
|
| | | /// <summary>
|
| | | /// Init
|
| | | /// </summary>
|
| | | private void Init()
|
| | | {
|
| | |
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// AddTop
|
| | | /// </summary>
|
| | | private void AddTop()
|
| | | {
|
| | | var top = new TopFrameLayout();
|
| | | AddChidren(top);
|
| | | top.InitTopview();
|
| | | if (isModify)
|
| | | {
|
| | | top.SetTopTitle(R.MyInternationalizationString.EditorScene);
|
| | | }
|
| | | else
|
| | | {
|
| | | top.SetTopTitle(R.MyInternationalizationString.AddScence);
|
| | | }
|
| | | top.backButton.MouseUpEventHandler += (sender, e) =>
|
| | | {
|
| | | RemoveFromParent();
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// AddBodyView
|
| | | /// </summary>
|
| | | private void AddBodyView()
|
| | | {
|
| | | var bodyScrolView = new VerticalScrolViewLayout()
|
| | | {
|
| | | Y = Application.GetRealHeight(184),
|
| | | Height = Application.GetRealHeight(1737),
|
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor,
|
| | | };
|
| | | AddChidren(bodyScrolView);
|
| | |
|
| | | bodyFrameLayout = new FrameLayout()
|
| | | {
|
| | | Height = Application.GetRealHeight(1086 + 127),
|
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor,
|
| | | };
|
| | | bodyScrolView.AddChidren(bodyFrameLayout);
|
| | |
|
| | | var imgFL = new FrameLayout
|
| | | {
|
| | | Height = Application.GetRealHeight(559),
|
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
|
| | | };
|
| | | 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()
|
| | | {
|
| | | Y = Application.GetRealHeight(46),
|
| | | Width = Application.GetMinRealAverage(887),
|
| | | Height = Application.GetMinRealAverage(444),
|
| | | Gravity = Gravity.CenterHorizontal,
|
| | | Radius = (uint)Application.GetMinRealAverage(CommonFormResouce.BigFormRadius),
|
| | | ImagePath = "SceneIcon/3.png"
|
| | | };
|
| | | imgFL.AddChidren(backGround);
|
| | |
|
| | | var infoFL = new FrameLayout
|
| | | {
|
| | | Y = imgFL.Bottom + Application.GetRealHeight(23),
|
| | | Height = Application.GetRealHeight(418),
|
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
|
| | | };
|
| | | bodyFrameLayout.AddChidren(infoFL);
|
| | |
|
| | | var infoEdit = new Button
|
| | | {
|
| | | X = Application.GetRealWidth(CommonFormResouce.X_Left),
|
| | | Height = Application.GetRealHeight(130),
|
| | | Width = Application.GetRealWidth(700),
|
| | | TextID = R.MyInternationalizationString.EditInfo,
|
| | | TextColor = ZigbeeColor.Current.GXCTextDeepBlackColor,
|
| | | TextAlignment = TextAlignment.CenterLeft,
|
| | | TextSize = 15,
|
| | | //IsBold=true
|
| | | };
|
| | | infoFL.AddChidren(infoEdit);
|
| | |
|
| | |
|
| | | var nameRow = new DeviceInfoEditRow(130);
|
| | | nameRow.Init();
|
| | | nameRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.SceneName)}:");
|
| | | nameRow.SetPlaceHoldText(R.MyInternationalizationString.PleaseInputSceneName);
|
| | | infoFL.AddChidren(nameRow);
|
| | |
|
| | | var zoneRow = new DeviceInfoRow(257);
|
| | | zoneRow.Y = nameRow.Bottom + Application.GetRealHeight(14);
|
| | | zoneRow.Init();
|
| | | zoneRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongZone)}:");
|
| | | //zoneRow.SetTitle(curRoom.Name);
|
| | | infoFL.AddChidren(zoneRow);
|
| | | zoneRow.HideLine(true);
|
| | |
|
| | | var targetFL = new FrameLayout()
|
| | | {
|
| | | Y = infoFL.Bottom + Application.GetRealHeight(23),
|
| | | Height = Application.GetRealHeight(346)
|
| | | };
|
| | | bodyFrameLayout.AddChidren(targetFL);
|
| | |
|
| | | var targetBG = new FrameLayout
|
| | | {
|
| | | Height = Application.GetRealHeight(334),
|
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
|
| | | };
|
| | | 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),
|
| | | Height = Application.GetRealHeight(127) - 1,
|
| | | Width = Application.GetRealWidth(600),
|
| | | TextAlignment = TextAlignment.CenterLeft,
|
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
| | | TextID = R.MyInternationalizationString.AddScentTargetAction,
|
| | | Gravity = Gravity.CenterVertical,
|
| | | TextSize = 15
|
| | | };
|
| | | addTargetFL.AddChidren(target);
|
| | |
|
| | | 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",
|
| | | };
|
| | | addTargetFL.AddChidren(targetAdd);
|
| | | var targetLine = new Button()
|
| | | {
|
| | | Y = target.Bottom,
|
| | | Height = 1,
|
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2
|
| | | };
|
| | | addTargetFL.AddChidren(targetLine);
|
| | |
|
| | | TargetListScrolView = new FrameLayout()
|
| | | {
|
| | | Height = Application.GetRealHeight(173)
|
| | | };
|
| | | bodyScrolView.AddChidren(TargetListScrolView);
|
| | |
|
| | |
|
| | |
|
| | | confirmBtn = new CommonForm.CompleteButton(1656, 907, 127);
|
| | | confirmBtn.TextID = R.MyInternationalizationString.uFinish;
|
| | | AddChidren(confirmBtn);
|
| | |
|
| | | if (isModify)
|
| | | {
|
| | | IconPathType = modifySceneUI.IconPathType;
|
| | | OldIconPathType = modifySceneUI.IconPathType;
|
| | | if (IconPathType != 0)
|
| | | {
|
| | | OldBackgroundImagePath = modifySceneUI.IconPath;
|
| | | }
|
| | | if (modifySceneUI.IconPathType == 0)
|
| | | {
|
| | | backGround.ImagePath = modifySceneUI.IconPath;
|
| | | }
|
| | | else
|
| | | {
|
| | | backGround.ImagePath = System.IO.Path.Combine(Config.Instance.FullPath, modifySceneUI.IconPath);
|
| | | }
|
| | | nameRow.SetTitle(modifySceneUI.Name);
|
| | | if (Config.Instance.Home.FloorDics.Count == 0)
|
| | | {
|
| | | zoneRow.SetTitle($"{modifyRoom.Name}");
|
| | | }
|
| | | else
|
| | | {
|
| | | zoneRow.SetTitle($"{Config.Instance.Home.GetFloorNameById(modifyRoom.FloorId)},{modifyRoom.Name}");
|
| | | }
|
| | | curRoom = modifyRoom;
|
| | | sceneTargetDevicesList.AddRange(modifySceneTargetDevicesList);
|
| | | }
|
| | |
|
| | | RefreshTargetListView();
|
| | |
|
| | | #region event
|
| | |
|
| | | EventHandler<MouseEventArgs> backGroundIMGHander = (sender, e) =>
|
| | | {
|
| | | if (curRoom != null && curRoom.IsSharedRoom)
|
| | | {
|
| | | RoomCommon.ShowTipRoomIsShared();
|
| | | return;
|
| | | }
|
| | |
|
| | | int selectRow_Height = 150;
|
| | | int selectRow_Width = 1034;
|
| | | var selectFL = new FrameLayout()
|
| | | {
|
| | | BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor
|
| | | };
|
| | | AddChidren(selectFL);
|
| | |
|
| | | var itemFL = new FrameLayout()
|
| | | {
|
| | | Y = Application.GetRealHeight(1276),
|
| | | Height = Application.GetRealHeight(450),
|
| | | Width = Application.GetRealWidth(selectRow_Width),
|
| | | Gravity = Gravity.CenterHorizontal,
|
| | | Radius = (uint)Application.GetRealHeight(35),
|
| | | BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor
|
| | | };
|
| | | selectFL.AddChidren(itemFL);
|
| | | //itemFL.Animate = Animate.DownToUp;
|
| | |
|
| | | var selectLocalPicture = new Button()
|
| | | {
|
| | | Height = Application.GetRealHeight(selectRow_Height) - 1,
|
| | | TextID = R.MyInternationalizationString.LocalPicture,
|
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4,
|
| | | TextSize = 17
|
| | | };
|
| | | itemFL.AddChidren(selectLocalPicture);
|
| | | var selectLocalLine = new Button()
|
| | | {
|
| | | Y = selectLocalPicture.Bottom,
|
| | | Height = 1,
|
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2
|
| | | };
|
| | | itemFL.AddChidren(selectLocalLine);
|
| | |
|
| | | var selectPhotographBtn = new Button()
|
| | | {
|
| | | Y = selectLocalLine.Bottom,
|
| | | Height = Application.GetRealHeight(selectRow_Height) - 1,
|
| | | TextID = R.MyInternationalizationString.Photograph,
|
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4,
|
| | | TextSize = 17
|
| | | };
|
| | | itemFL.AddChidren(selectPhotographBtn);
|
| | | var selectPhotographLine = new Button()
|
| | | {
|
| | | Y = selectPhotographBtn.Bottom,
|
| | | Height = 1,
|
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2,
|
| | | };
|
| | | itemFL.AddChidren(selectPhotographLine);
|
| | |
|
| | | var selectAblumsBtn = new Button()
|
| | | {
|
| | | Y = selectPhotographLine.Bottom,
|
| | | Height = Application.GetRealHeight(selectRow_Height) - 1,
|
| | | TextID = R.MyInternationalizationString.MyAblums,
|
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4,
|
| | | TextSize = 17
|
| | | };
|
| | | itemFL.AddChidren(selectAblumsBtn);
|
| | |
|
| | | 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(35),
|
| | | TextSize = 17
|
| | | };
|
| | | selectFL.AddChidren(cancelBtn);
|
| | |
|
| | | selectLocalPicture.MouseUpEventHandler += (send, ee) =>
|
| | | {
|
| | | selectFL.RemoveFromParent();
|
| | | var localPic = new CategorySceneSelectImgByLocal();
|
| | | Shared.Phone.UserView.HomePage.Instance.AddChidren(localPic);
|
| | | Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
|
| | | localPic.Show();
|
| | | localPic.action = (imgPath) =>
|
| | | {
|
| | | IconPathType = 0;
|
| | | backGround.ImageBytes = null;
|
| | | backGround.ImagePath = imgPath;
|
| | | };
|
| | | };
|
| | | selectPhotographBtn.MouseUpEventHandler += (send, ee) =>
|
| | | {
|
| | | selectFL.RemoveFromParent();
|
| | | var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
|
| | | var fileName = $"SceneIcon_{tradeTime}.png";
|
| | | //通过相机拍照裁剪
|
| | | CropImage.TakePicture((imagePath) =>
|
| | | {
|
| | | if (string.IsNullOrEmpty(imagePath))
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (isModify)
|
| | | {
|
| | | if (IconPathType != 0)
|
| | | {
|
| | | Global.DeleteFilebyHomeId(backGround.ImagePath);
|
| | | HdlAutoBackupLogic.DeleteFile(backGround.ImagePath);
|
| | | }
|
| | | }
|
| | |
|
| | | IconPathType = 1;
|
| | | backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath);
|
| | | backGround.ImagePath = imagePath;
|
| | | System.IO.File.Delete(imagePath);
|
| | |
|
| | | }, fileName, 2, 1);
|
| | | };
|
| | |
|
| | | selectAblumsBtn.MouseUpEventHandler += (send, ee) =>
|
| | | {
|
| | | selectFL.RemoveFromParent();
|
| | | var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
|
| | | var fileName = $"SceneIcon_{tradeTime}.png";
|
| | | //从相册选择图片裁剪
|
| | | CropImage.SelectPicture((imagePath) =>
|
| | | {
|
| | | if (string.IsNullOrEmpty(imagePath))
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (isModify)
|
| | | {
|
| | | if (IconPathType != 0)
|
| | | {
|
| | | Global.DeleteFilebyHomeId(backGround.ImagePath);
|
| | | HdlAutoBackupLogic.DeleteFile(backGround.ImagePath);
|
| | | }
|
| | | }
|
| | |
|
| | | IconPathType = 2;
|
| | | backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath);
|
| | | backGround.ImagePath = imagePath;
|
| | | System.IO.File.Delete(imagePath);
|
| | |
|
| | | }, fileName, 2, 1);
|
| | | };
|
| | |
|
| | | cancelBtn.MouseUpEventHandler += (send, ee) =>
|
| | | {
|
| | | selectFL.RemoveFromParent();
|
| | | };
|
| | | selectFL.MouseUpEventHandler += (send, ee) =>
|
| | | {
|
| | | selectFL.RemoveFromParent();
|
| | | };
|
| | | };
|
| | | backGround.MouseUpEventHandler += backGroundIMGHander;
|
| | |
|
| | | //区域
|
| | | EventHandler<MouseEventArgs> zoneHander = (sender, e) =>
|
| | | {
|
| | | var zone = new SelectZone();
|
| | | zone.Init();
|
| | | zone.ZoneAction += (selectRoom) =>
|
| | | {
|
| | | curRoom = selectRoom;
|
| | | zoneRow.SetTitle(HdlRoomLogic.Current.GetZoneName(selectRoom));
|
| | | };
|
| | | };
|
| | | zoneRow.ClickBtn.MouseUpEventHandler += zoneHander;
|
| | |
|
| | | //执行目标-添加执行设备
|
| | | EventHandler<MouseEventArgs> targetAddHander = (sender, e) =>
|
| | | {
|
| | |
|
| | | //if (curRoom == null)
|
| | | //{
|
| | | // RoomCommon.ShowTipNoRoom();
|
| | | // return;
|
| | | //}
|
| | | if (curRoom != null)
|
| | | {
|
| | | if (curRoom.IsSharedRoom)
|
| | | {
|
| | | RoomCommon.ShowTipRoomIsShared();
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | int selectRow_Height = 150;
|
| | | int selectRow_Width = 1034;
|
| | | var selectFL = new FrameLayout()
|
| | | {
|
| | | BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor
|
| | | };
|
| | | AddChidren(selectFL);
|
| | |
|
| | | var itemFL = new FrameLayout()
|
| | | {
|
| | | Y = Application.GetRealHeight(1276),
|
| | | Height = Application.GetRealHeight(450),
|
| | | Width = Application.GetRealWidth(selectRow_Width),
|
| | | Gravity = Gravity.CenterHorizontal,
|
| | | Radius = (uint)Application.GetRealHeight(35),
|
| | | BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor
|
| | | };
|
| | | selectFL.AddChidren(itemFL);
|
| | | //itemFL.Animate = Animate.DownToUp;
|
| | |
|
| | | var selectedFunctionBtn = new Button()
|
| | | {
|
| | | Height = Application.GetRealHeight(selectRow_Height) - 1,
|
| | | TextID = R.MyInternationalizationString.Function,
|
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4,
|
| | | TextSize = 17
|
| | | };
|
| | | itemFL.AddChidren(selectedFunctionBtn);
|
| | | var selectedFunctionLine = new Button()
|
| | | {
|
| | | Y = selectedFunctionBtn.Bottom,
|
| | | Height = 1,
|
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2
|
| | | };
|
| | | itemFL.AddChidren(selectedFunctionLine);
|
| | |
|
| | | var selectedSceneBtn = new Button()
|
| | | {
|
| | | Y = selectedFunctionLine.Bottom,
|
| | | Height = Application.GetRealHeight(selectRow_Height) - 1,
|
| | | TextID = R.MyInternationalizationString.Scence,
|
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4,
|
| | | TextSize = 17
|
| | | };
|
| | | itemFL.AddChidren(selectedSceneBtn);
|
| | | var selectedSceneLine = new Button()
|
| | | {
|
| | | Y = selectedSceneBtn.Bottom,
|
| | | Height = 1,
|
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2,
|
| | | };
|
| | | itemFL.AddChidren(selectedSceneLine);
|
| | |
|
| | | var selectedTimerBtn = new Button()
|
| | | {
|
| | | Y = selectedSceneLine.Bottom,
|
| | | Height = Application.GetRealHeight(selectRow_Height) - 1,
|
| | | TextID = R.MyInternationalizationString.Delay,
|
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4,
|
| | | TextSize = 17
|
| | | };
|
| | | itemFL.AddChidren(selectedTimerBtn);
|
| | |
|
| | |
|
| | | 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(35),
|
| | | TextSize = 17
|
| | | };
|
| | | selectFL.AddChidren(cancelBtn);
|
| | |
|
| | | //添加功能
|
| | | selectedFunctionBtn.MouseUpEventHandler += (send, ee) =>
|
| | | {
|
| | | selectFL.RemoveFromParent();
|
| | | var deviceView = new SelectDevice();
|
| | | UserView.HomePage.Instance.AddChidren(deviceView);
|
| | | UserView.HomePage.Instance.PageIndex += 1;
|
| | | deviceView.beforeSceneTargetDeviceUIs = sceneTargetDevicesList;
|
| | | deviceView.Show();
|
| | | deviceView.selectedAction = (selectedDevice) =>
|
| | | {
|
| | | sceneTargetDevicesList.Add(selectedDevice);
|
| | | RefreshTargetListView();
|
| | | };
|
| | | };
|
| | | //添加场景
|
| | | selectedSceneBtn.MouseUpEventHandler += (send, ee) =>
|
| | | {
|
| | | selectFL.RemoveFromParent();
|
| | | var sceneView = new SelectScene();
|
| | | UserView.HomePage.Instance.AddChidren(sceneView);
|
| | | UserView.HomePage.Instance.PageIndex += 1;
|
| | | sceneView.beforeSceneTargetDeviceUIs = sceneTargetDevicesList;
|
| | | sceneView.currentSceneUI = modifySceneUI;
|
| | | sceneView.Show();
|
| | | sceneView.selectedAction = (selectedScene) =>
|
| | | {
|
| | | sceneTargetDevicesList.Add(selectedScene);
|
| | | RefreshTargetListView();
|
| | | };
|
| | |
|
| | | };
|
| | | //添加时间间隔
|
| | | selectedTimerBtn.MouseUpEventHandler += (send, ee) =>
|
| | | {
|
| | | selectFL.RemoveFromParent();
|
| | | 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();
|
| | | };
|
| | | selectFL.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)
|
| | | {
|
| | | RoomCommon.ShowTipRoomIsShared();
|
| | | return;
|
| | | }
|
| | |
|
| | | if (isModify)
|
| | | {
|
| | | if (string.IsNullOrEmpty(nameRow.NameText.Text))
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.SceneNameCannotBeNull));
|
| | | return;
|
| | | }
|
| | | else
|
| | | {
|
| | | try
|
| | | {
|
| | | var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
|
| | | var fileName = $"SceneIcon_{tradeTime}.png";
|
| | | if (modifySceneUI.Name != nameRow.NameText.Text.Trim())
|
| | | {
|
| | | if (HdlSceneLogic.Current.GetSameFloorScenes(curRoom.FloorId).Find(s => s.Name == nameRow.NameText.Text.Trim()) != null)
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(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 (OldIconPathType != 0)
|
| | | {
|
| | | Shared.IO.FileUtils.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(fileName);
|
| | | modifySceneUI.IconPath = fileName;
|
| | | }
|
| | | else
|
| | | {
|
| | | modifySceneUI.IconPath = backGround.ImagePath;
|
| | | }
|
| | | modifySceneUI.IconPathType = IconPathType;
|
| | |
|
| | | 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)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | var memberData = new AddSceneMemberData
|
| | | {
|
| | | Type = 0,
|
| | | ScenesId = 0,
|
| | | DeviceAddr = sceneTarget.DeviceUI.DeviceAddr,
|
| | | Epoint = sceneTarget.DeviceUI.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)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | var removeDevice = new RemoveSceneDeviceListInfo
|
| | | {
|
| | | Type = 0,
|
| | | DeviceAddr = sceneTarget.DeviceUI.DeviceAddr,
|
| | | Epoint = sceneTarget.DeviceUI.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 HdlSceneLogic.Current.ModifyScene(modifySceneUI, sceneRemoveMemberData, memberDataList);
|
| | | if (result == 1)
|
| | | {
|
| | | if (modifyRoom != curRoom)
|
| | | {
|
| | | modifyRoom.ListSceneId.Remove(modifySceneUI.Id);
|
| | | curRoom.ListSceneId.Add(modifySceneUI.Id);
|
| | | modifyRoom.Save();
|
| | | curRoom.Save();
|
| | | }
|
| | | EditorAction?.Invoke(modifySceneUI, curRoom);
|
| | | RemoveFromParent();
|
| | | }
|
| | | else if (result == 0)
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.FailedPleaseTryAgain));
|
| | | }
|
| | | else if (result == -1)
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneHadExist));
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | System.Console.WriteLine($"分类添加场景出错{ex.Message}");
|
| | | }
|
| | | finally
|
| | | {
|
| | | CommonPage.Loading.Hide();
|
| | | }
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | //新增
|
| | | if (string.IsNullOrEmpty(nameRow.NameText.Text))
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.SceneNameCannotBeNull));
|
| | | return;
|
| | | }
|
| | | else
|
| | | {
|
| | | try
|
| | | {
|
| | | var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
|
| | | var fileName = $"SceneIcon_{tradeTime}.png";
|
| | | string imgPath;
|
| | | 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
|
| | | {
|
| | | imgPath = backGround.ImagePath;
|
| | | }
|
| | | //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 sceneTarget = sceneTargetDevicesList[i];
|
| | |
|
| | | if (sceneTarget.Type == 0)
|
| | | {
|
| | | if (sceneTarget.DeviceUI == null)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | var memberData = new AddSceneMemberData
|
| | | {
|
| | | Type = 0,
|
| | | ScenesId = 0,
|
| | | DeviceAddr = sceneTarget.DeviceUI.DeviceAddr,
|
| | | Epoint = sceneTarget.DeviceUI.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 HdlSceneLogic.Current.AddScene(curRoom, nameRow.NameText.Text, imgPath, memberDataList, IconPathType);
|
| | | if (result == 1)
|
| | | {
|
| | | AddAction?.Invoke();
|
| | | RemoveFromParent();
|
| | | }
|
| | | else if (result == 0)
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.AddSceneFail));
|
| | | }
|
| | | else if (result == -1)
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneHadExist));
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | System.Console.WriteLine($"分类添加场景出错{ex.Message}");
|
| | | }
|
| | | finally
|
| | | {
|
| | | CommonPage.Loading.Hide();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | };
|
| | | #endregion
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region 编辑设备____________________________________
|
| | |
|
| | | /// <summary>
|
| | | /// ShowSelectAction
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | private void ShowSelectAction(CommonDevice device, SceneTargetDeviceUI sceneTarget)
|
| | | {
|
| | | var dialog = new FrameLayout()
|
| | | {
|
| | | BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor
|
| | | };
|
| | | AddChidren(dialog);
|
| | |
|
| | | dialog.MouseUpEventHandler += (sender, e) =>
|
| | | {
|
| | | dialog.RemoveFromParent();
|
| | | };
|
| | |
|
| | | if (device.Type == ZigBee.Device.DeviceType.OnOffOutput)
|
| | | {
|
| | | SelectOnoffOutput(dialog, device, sceneTarget);
|
| | | }
|
| | | else if (device.Type == ZigBee.Device.DeviceType.AirSwitch)
|
| | | {
|
| | | SelectOnoffOutput(dialog, device, sceneTarget);
|
| | | }
|
| | | else if (device.Type == ZigBee.Device.DeviceType.DimmableLight)
|
| | | {
|
| | | SelectDimmableLight(dialog, device, sceneTarget);
|
| | | }
|
| | | else if (device.Type == ZigBee.Device.DeviceType.WindowCoveringDevice)
|
| | | {
|
| | | SelectWindowCoveringDevice(dialog, device, sceneTarget);
|
| | | }
|
| | | else if (device.Type == ZigBee.Device.DeviceType.Thermostat)
|
| | | {
|
| | | SelectThermostat(dialog, device, sceneTarget);
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 灯光
|
| | | /// </summary>
|
| | | /// <param name="dialog"></param>
|
| | | /// <param name="device"></param>
|
| | | /// <param name="sceneTarget"></param>
|
| | | private void SelectOnoffOutput(FrameLayout dialog, CommonDevice device, SceneTargetDeviceUI sceneTarget)
|
| | | {
|
| | | var selectFL = new FrameLayout
|
| | | {
|
| | | Y = Application.GetRealHeight(1391),
|
| | | Height = Application.GetRealHeight(530),
|
| | | };
|
| | | dialog.AddChidren(selectFL);
|
| | | //selectFL.Animate = Animate.DownToUp;
|
| | |
|
| | | var titleBG = new FrameLayout
|
| | | {
|
| | | Height = Application.GetRealHeight(138 * 2),
|
| | | Radius = (uint)Application.GetRealHeight(58),
|
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
|
| | | };
|
| | | selectFL.AddChidren(titleBG);
|
| | |
|
| | | var titleFL = new FrameLayout
|
| | | {
|
| | | Height = Application.GetRealHeight(138),
|
| | | };
|
| | | selectFL.AddChidren(titleFL);
|
| | |
|
| | | var line = new Button
|
| | | {
|
| | | Y = titleFL.Height - 1,
|
| | | Height = 1,
|
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2
|
| | | };
|
| | | titleFL.AddChidren(line);
|
| | |
|
| | | var cancleBtn = new Button
|
| | | {
|
| | | X = Application.GetRealWidth(80),
|
| | | Width = Application.GetRealWidth(200),
|
| | | TextColor = ZigbeeColor.Current.GXCTextGrayColor,
|
| | | TextSize = 14,
|
| | | TextAlignment = TextAlignment.CenterLeft,
|
| | | TextID = R.MyInternationalizationString.Cancel
|
| | | };
|
| | | titleFL.AddChidren(cancleBtn);
|
| | |
|
| | | var deviceName = new Button
|
| | | {
|
| | | Width = Application.GetRealWidth(600),
|
| | | Gravity = Gravity.CenterHorizontal,
|
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
| | | TextSize = 16,
|
| | | Text = Common.LocalDevice.Current.GetDeviceEpointName(device)
|
| | | };
|
| | | titleFL.AddChidren(deviceName);
|
| | |
|
| | | var comfrimBtn = new Button
|
| | | {
|
| | | X = Application.GetRealWidth(800),
|
| | | Width = Application.GetRealWidth(200),
|
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor2,
|
| | | TextSize = 14,
|
| | | TextAlignment = TextAlignment.CenterRight,
|
| | | TextID = R.MyInternationalizationString.Complete
|
| | | };
|
| | | titleFL.AddChidren(comfrimBtn);
|
| | |
|
| | | var itemFL = new FrameLayout
|
| | | {
|
| | | Y = titleFL.Bottom,
|
| | | Height = Application.GetRealHeight(392),
|
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
|
| | | };
|
| | | selectFL.AddChidren(itemFL);
|
| | |
|
| | | var open = new SelectSceneStatuRow(0, 60);
|
| | | itemFL.AddChidren(open);
|
| | | open.Init();
|
| | | open.SetTitle(R.MyInternationalizationString.Open);
|
| | | open.IsSelected = true;
|
| | |
|
| | |
|
| | | var shut = new SelectSceneStatuRow(0, 60 + 127 + 30);
|
| | | itemFL.AddChidren(shut);
|
| | | shut.Init();
|
| | | shut.hideLine(true);
|
| | | shut.SetTitle(R.MyInternationalizationString.Shut);
|
| | |
|
| | | open.ClickButton.MouseUpEventHandler += (sender, e) =>
|
| | | {
|
| | | open.IsSelected = true;
|
| | | shut.IsSelected = false;
|
| | | };
|
| | |
|
| | | shut.ClickButton.MouseUpEventHandler += (sender, e) =>
|
| | | {
|
| | | open.IsSelected = false;
|
| | | shut.IsSelected = true;
|
| | | };
|
| | |
|
| | | cancleBtn.MouseUpEventHandler = (sender, e) =>
|
| | | {
|
| | | dialog.RemoveAll();
|
| | | dialog.RemoveFromParent();
|
| | | };
|
| | |
|
| | | if (sceneTarget.TaskList.Count > 0)
|
| | | {
|
| | | if (sceneTarget.TaskList[0].Data1 == 1)
|
| | | {
|
| | | open.IsSelected = true;
|
| | | shut.IsSelected = false;
|
| | | }
|
| | | else
|
| | | {
|
| | | open.IsSelected = false;
|
| | | shut.IsSelected = true;
|
| | | }
|
| | | }
|
| | |
|
| | | comfrimBtn.MouseUpEventHandler = (sender, e) =>
|
| | | {
|
| | | var taskList = new List<ZigBee.Device.Scene.TaskListInfo> { };
|
| | | int taskType = 1;
|
| | | int data1 = 0;
|
| | | int data2 = 0;
|
| | |
|
| | | if (open.IsSelected)
|
| | | {
|
| | | //开
|
| | | data1 = 1;
|
| | | data2 = 0;
|
| | | }
|
| | | else
|
| | | {
|
| | | //关
|
| | | data1 = 0;
|
| | | data2 = 0;
|
| | | }
|
| | | var taskInfo = new ZigBee.Device.Scene.TaskListInfo
|
| | | {
|
| | | TaskType = taskType,
|
| | | Data1 = data1,
|
| | | Data2 = data2
|
| | | };
|
| | | taskList.Add(taskInfo);
|
| | |
|
| | | sceneTarget.TaskList = taskList;
|
| | | sceneTarget.DeviceUI = device;
|
| | | selectedAction?.Invoke(sceneTarget);
|
| | | dialog.RemoveFromParent();
|
| | | };
|
| | | }
|
| | | /// <summary>
|
| | | /// 窗帘
|
| | | /// </summary>
|
| | | /// <param name="dialog"></param>
|
| | | /// <param name="device"></param>
|
| | | /// <param name="sceneTarget"></param>
|
| | | private void SelectWindowCoveringDevice(FrameLayout dialog, CommonDevice device, SceneTargetDeviceUI sceneTarget)
|
| | | {
|
| | | var selectFL = new FrameLayout
|
| | | {
|
| | | Y = Application.GetRealHeight(1169),
|
| | | Height = Application.GetRealHeight(752),
|
| | | };
|
| | | dialog.AddChidren(selectFL);
|
| | | //selectFL.Animate = Animate.DownToUp;
|
| | |
|
| | | var titleBG = new FrameLayout
|
| | | {
|
| | | Height = Application.GetRealHeight(138 * 2),
|
| | | Radius = (uint)Application.GetRealHeight(58),
|
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
|
| | | };
|
| | | selectFL.AddChidren(titleBG);
|
| | |
|
| | | var titleFL = new FrameLayout
|
| | | {
|
| | | Height = Application.GetRealHeight(138),
|
| | | };
|
| | | selectFL.AddChidren(titleFL);
|
| | |
|
| | | var line = new Button
|
| | | {
|
| | | Y = titleFL.Height - 1,
|
| | | Height = 1,
|
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2
|
| | | };
|
| | | titleFL.AddChidren(line);
|
| | |
|
| | | var cancleBtn = new Button
|
| | | {
|
| | | X = Application.GetRealWidth(80),
|
| | | Width = Application.GetRealWidth(200),
|
| | | TextColor = ZigbeeColor.Current.GXCTextGrayColor,
|
| | | TextSize = 14,
|
| | | TextAlignment = TextAlignment.CenterLeft,
|
| | | TextID = R.MyInternationalizationString.Cancel
|
| | | };
|
| | | titleFL.AddChidren(cancleBtn);
|
| | |
|
| | | var deviceName = new Button
|
| | | {
|
| | | Width = Application.GetRealWidth(600),
|
| | | Gravity = Gravity.CenterHorizontal,
|
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
| | | TextSize = 16,
|
| | | Text = Common.LocalDevice.Current.GetDeviceEpointName(device)
|
| | | };
|
| | | titleFL.AddChidren(deviceName);
|
| | |
|
| | | var comfrimBtn = new Button
|
| | | {
|
| | | X = Application.GetRealWidth(800),
|
| | | Width = Application.GetRealWidth(200),
|
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor2,
|
| | | TextSize = 14,
|
| | | TextAlignment = TextAlignment.CenterRight,
|
| | | TextID = R.MyInternationalizationString.Complete
|
| | | };
|
| | | titleFL.AddChidren(comfrimBtn);
|
| | |
|
| | | var itemFL = new FrameLayout
|
| | | {
|
| | | Y = titleFL.Bottom,
|
| | | Height = Application.GetRealHeight(613),
|
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
|
| | | };
|
| | | selectFL.AddChidren(itemFL);
|
| | |
|
| | | var open = new SelectDeviceWithSeekBarRow(0, 60);
|
| | | itemFL.AddChidren(open);
|
| | | open.Init();
|
| | | open.SetTitle(R.MyInternationalizationString.Open);
|
| | | open.IsSelected = true;
|
| | |
|
| | | var shut = new SelectSceneStatuRow(0, 60 + 348 + 30);
|
| | | itemFL.AddChidren(shut);
|
| | | shut.Init();
|
| | | shut.hideLine(true);
|
| | | shut.SetTitle(R.MyInternationalizationString.Shut);
|
| | |
|
| | | open.ClickButton.MouseUpEventHandler += (sender, e) =>
|
| | | {
|
| | | open.IsSelected = true;
|
| | | shut.IsSelected = false;
|
| | | };
|
| | |
|
| | | shut.ClickButton.MouseUpEventHandler += (sender, e) =>
|
| | | {
|
| | | open.IsSelected = false;
|
| | | shut.IsSelected = true;
|
| | | };
|
| | |
|
| | | cancleBtn.MouseUpEventHandler = (sender, e) =>
|
| | | {
|
| | | dialog.RemoveAll();
|
| | | dialog.RemoveFromParent();
|
| | | };
|
| | |
|
| | | open.SeekBar.OnProgressChangedEvent += (sender, e) =>
|
| | | {
|
| | | open.IsSelected = true;
|
| | | shut.IsSelected = false;
|
| | | open.SetSeekBarTitle();
|
| | | };
|
| | |
|
| | | if (sceneTarget.TaskList.Count > 0)
|
| | | {
|
| | | if (sceneTarget.TaskList[0].Data1 == 1)
|
| | | {
|
| | | open.IsSelected = false;
|
| | | shut.IsSelected = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | open.IsSelected = true;
|
| | | shut.IsSelected = false;
|
| | | open.SetSeekBarProgress(sceneTarget.TaskList[0].Data2);
|
| | | }
|
| | | }
|
| | |
|
| | | comfrimBtn.MouseUpEventHandler = (sender, e) =>
|
| | | {
|
| | | var taskList = new List<ZigBee.Device.Scene.TaskListInfo> { };
|
| | |
|
| | | int taskType = 6;
|
| | | int data1 = 0;
|
| | | int data2 = 0;
|
| | |
|
| | | if (shut.IsSelected)
|
| | | {
|
| | | //关
|
| | | data1 = 1;
|
| | | data2 = 0;
|
| | | }
|
| | | else
|
| | | {
|
| | | //百分比
|
| | | data1 = 5;
|
| | | data2 = open.SeekBar.Progress;
|
| | | }
|
| | |
|
| | | var taskInfo = new ZigBee.Device.Scene.TaskListInfo
|
| | | {
|
| | | TaskType = taskType,
|
| | | Data1 = data1,
|
| | | Data2 = data2
|
| | | };
|
| | | taskList.Add(taskInfo);
|
| | |
|
| | | sceneTarget.TaskList = taskList;
|
| | | sceneTarget.DeviceUI = device;
|
| | | selectedAction?.Invoke(sceneTarget);
|
| | | dialog.RemoveFromParent();
|
| | | };
|
| | | }
|
| | | /// <summary>
|
| | | /// 调光灯
|
| | | /// </summary>
|
| | | /// <param name="dialog"></param>
|
| | | /// <param name="device"></param>
|
| | | /// <param name="sceneTarget"></param>
|
| | | private void SelectDimmableLight(FrameLayout dialog, CommonDevice device, SceneTargetDeviceUI sceneTarget)
|
| | | {
|
| | | var selectFL = new FrameLayout
|
| | | {
|
| | | Y = Application.GetRealHeight(1169),
|
| | | Height = Application.GetRealHeight(752),
|
| | | };
|
| | | dialog.AddChidren(selectFL);
|
| | | //selectFL.Animate = Animate.DownToUp;
|
| | |
|
| | | var titleBG = new FrameLayout
|
| | | {
|
| | | Height = Application.GetRealHeight(138 * 2),
|
| | | Radius = (uint)Application.GetRealHeight(58),
|
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
|
| | | };
|
| | | selectFL.AddChidren(titleBG);
|
| | |
|
| | | var titleFL = new FrameLayout
|
| | | {
|
| | | Height = Application.GetRealHeight(138),
|
| | | };
|
| | | selectFL.AddChidren(titleFL);
|
| | |
|
| | | var line = new Button
|
| | | {
|
| | | Y = titleFL.Height - 1,
|
| | | Height = 1,
|
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2
|
| | | };
|
| | | titleFL.AddChidren(line);
|
| | |
|
| | | var cancleBtn = new Button
|
| | | {
|
| | | X = Application.GetRealWidth(80),
|
| | | Width = Application.GetRealWidth(200),
|
| | | TextColor = ZigbeeColor.Current.GXCTextGrayColor,
|
| | | TextSize = 14,
|
| | | TextAlignment = TextAlignment.CenterLeft,
|
| | | TextID = R.MyInternationalizationString.Cancel
|
| | | };
|
| | | titleFL.AddChidren(cancleBtn);
|
| | |
|
| | | var deviceName = new Button
|
| | | {
|
| | | Width = Application.GetRealWidth(600),
|
| | | Gravity = Gravity.CenterHorizontal,
|
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
| | | TextSize = 16,
|
| | | TextAlignment = TextAlignment.CenterLeft,
|
| | | Text = Common.LocalDevice.Current.GetDeviceEpointName(device)
|
| | | };
|
| | | titleFL.AddChidren(deviceName);
|
| | |
|
| | | var comfrimBtn = new Button
|
| | | {
|
| | | X = Application.GetRealWidth(800),
|
| | | Width = Application.GetRealWidth(200),
|
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor2,
|
| | | TextSize = 14,
|
| | | TextAlignment = TextAlignment.CenterRight,
|
| | | TextID = R.MyInternationalizationString.Complete
|
| | | };
|
| | | titleFL.AddChidren(comfrimBtn);
|
| | |
|
| | | var itemFL = new FrameLayout
|
| | | {
|
| | | Y = titleFL.Bottom,
|
| | | Height = Application.GetRealHeight(613),
|
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
|
| | | };
|
| | | selectFL.AddChidren(itemFL);
|
| | |
|
| | | var open = new SelectDeviceWithSeekBarRow(0, 60);
|
| | | itemFL.AddChidren(open);
|
| | | open.Init(254);
|
| | | open.SetTitle(R.MyInternationalizationString.Open);
|
| | | open.IsSelected = true;
|
| | |
|
| | | var shut = new SelectSceneStatuRow(0, 60 + 348 + 30);
|
| | | itemFL.AddChidren(shut);
|
| | | shut.Init();
|
| | | shut.hideLine(true);
|
| | | shut.SetTitle(R.MyInternationalizationString.Shut);
|
| | |
|
| | | open.ClickButton.MouseUpEventHandler += (sender, e) =>
|
| | | {
|
| | | open.IsSelected = true;
|
| | | shut.IsSelected = false;
|
| | | };
|
| | |
|
| | | shut.ClickButton.MouseUpEventHandler += (sender, e) =>
|
| | | {
|
| | | open.IsSelected = false;
|
| | | shut.IsSelected = true;
|
| | | };
|
| | |
|
| | | cancleBtn.MouseUpEventHandler = (sender, e) =>
|
| | | {
|
| | | dialog.RemoveAll();
|
| | | dialog.RemoveFromParent();
|
| | | };
|
| | |
|
| | | open.SeekBar.OnProgressChangedEvent += (sender, e) =>
|
| | | {
|
| | | open.IsSelected = true;
|
| | | shut.IsSelected = false;
|
| | | open.SetSeekBarTitle();
|
| | | };
|
| | |
|
| | | if (sceneTarget.TaskList.Count > 0)
|
| | | {
|
| | | if (sceneTarget.TaskList[0].Data1 == 0)
|
| | | {
|
| | | open.IsSelected = false;
|
| | | shut.IsSelected = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | open.IsSelected = true;
|
| | | shut.IsSelected = false;
|
| | | open.SetSeekBarProgress(sceneTarget.TaskList[0].Data1);
|
| | | }
|
| | | }
|
| | |
|
| | | comfrimBtn.MouseUpEventHandler = (sender, e) =>
|
| | | {
|
| | | var taskList = new List<ZigBee.Device.Scene.TaskListInfo> { };
|
| | |
|
| | | int taskType = 3;
|
| | | int data1 = 0;
|
| | | int data2 = 0;
|
| | |
|
| | | if (shut.IsSelected)
|
| | | {
|
| | | //关
|
| | | data1 = 0;
|
| | | data2 = 0;
|
| | | }
|
| | | else
|
| | | {
|
| | | //百分比
|
| | | data1 = open.SeekBar.Progress;
|
| | | data2 = 0;
|
| | | }
|
| | |
|
| | | var taskInfo = new ZigBee.Device.Scene.TaskListInfo
|
| | | {
|
| | | TaskType = taskType,
|
| | | Data1 = data1,
|
| | | Data2 = data2
|
| | | };
|
| | | taskList.Add(taskInfo);
|
| | |
|
| | | sceneTarget.TaskList = taskList;
|
| | | sceneTarget.DeviceUI = device;
|
| | | selectedAction?.Invoke(sceneTarget);
|
| | | dialog.RemoveFromParent();
|
| | | };
|
| | | }
|
| | | /// <summary>
|
| | | /// 空调
|
| | | /// </summary>
|
| | | /// <param name="dialog"></param>
|
| | | /// <param name="device"></param>
|
| | | /// <param name="sceneTarget"></param>
|
| | | private void SelectThermostat(FrameLayout dialog, CommonDevice device, SceneTargetDeviceUI sceneTarget)
|
| | | {
|
| | | /// 温度
|
| | | int tempId = 0;
|
| | | /// 模式
|
| | | int modelId = 0;
|
| | | /// 风速
|
| | | int fanid = 0;
|
| | |
|
| | | var selectFL = new FrameLayout
|
| | | {
|
| | | Y = Application.GetRealHeight(815),
|
| | | Height = Application.GetRealHeight(1106),
|
| | | };
|
| | | dialog.AddChidren(selectFL);
|
| | | //selectFL.Animate = Animate.DownToUp;
|
| | |
|
| | | var titleBG = new FrameLayout
|
| | | {
|
| | | Height = Application.GetRealHeight(138 * 2),
|
| | | Radius = (uint)Application.GetRealHeight(58),
|
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
|
| | | };
|
| | | selectFL.AddChidren(titleBG);
|
| | |
|
| | | var titleFL = new FrameLayout
|
| | | {
|
| | | Height = Application.GetRealHeight(138),
|
| | | };
|
| | | selectFL.AddChidren(titleFL);
|
| | |
|
| | | var line = new Button
|
| | | {
|
| | | Y = titleFL.Height - 1,
|
| | | Height = 1,
|
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2
|
| | | };
|
| | | titleFL.AddChidren(line);
|
| | |
|
| | | var cancleBtn = new Button
|
| | | {
|
| | | X = Application.GetRealWidth(80),
|
| | | Width = Application.GetRealWidth(200),
|
| | | TextColor = ZigbeeColor.Current.GXCTextGrayColor,
|
| | | TextSize = 14,
|
| | | TextAlignment = TextAlignment.CenterLeft,
|
| | | TextID = R.MyInternationalizationString.Cancel
|
| | | };
|
| | | titleFL.AddChidren(cancleBtn);
|
| | |
|
| | | var deviceName = new Button
|
| | | {
|
| | | Width = Application.GetRealWidth(600),
|
| | | Gravity = Gravity.CenterHorizontal,
|
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
| | | TextSize = 16,
|
| | | TextAlignment = TextAlignment.CenterLeft,
|
| | | Text = Common.LocalDevice.Current.GetDeviceEpointName(device)
|
| | | };
|
| | | titleFL.AddChidren(deviceName);
|
| | |
|
| | | var comfrimBtn = new Button
|
| | | {
|
| | | X = Application.GetRealWidth(800),
|
| | | Width = Application.GetRealWidth(200),
|
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor2,
|
| | | TextSize = 14,
|
| | | TextAlignment = TextAlignment.CenterRight,
|
| | | TextID = R.MyInternationalizationString.Complete
|
| | | };
|
| | | titleFL.AddChidren(comfrimBtn);
|
| | |
|
| | | var itemFL = new FrameLayout
|
| | | {
|
| | | Y = titleFL.Bottom,
|
| | | Height = Application.GetRealHeight(968),
|
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
|
| | | };
|
| | | selectFL.AddChidren(itemFL);
|
| | |
|
| | | var open = new SelectDeviceWithPickViewRow(0, 60);
|
| | | itemFL.AddChidren(open);
|
| | | open.Init();
|
| | | open.SetTitle(R.MyInternationalizationString.Open);
|
| | | open.IsSelected = true;
|
| | |
|
| | | open.pickerView.OnSelectChangeEvent = (l1, l2, l3) =>
|
| | | {
|
| | | tempId = l1;
|
| | | modelId = l2;
|
| | | fanid = l3;
|
| | | };
|
| | |
|
| | | var shut = new SelectSceneStatuRow(0, 60 + 703 + 30);
|
| | | itemFL.AddChidren(shut);
|
| | | shut.Init();
|
| | | shut.hideLine(true);
|
| | | shut.SetTitle(R.MyInternationalizationString.Shut);
|
| | |
|
| | | open.ClickButton.MouseUpEventHandler += (sender, e) =>
|
| | | {
|
| | | open.IsSelected = true;
|
| | | shut.IsSelected = false;
|
| | | };
|
| | |
|
| | | shut.ClickButton.MouseUpEventHandler += (sender, e) =>
|
| | | {
|
| | | open.IsSelected = false;
|
| | | shut.IsSelected = true;
|
| | | };
|
| | |
|
| | | cancleBtn.MouseUpEventHandler = (sender, e) =>
|
| | | {
|
| | | dialog.RemoveAll();
|
| | | dialog.RemoveFromParent();
|
| | | };
|
| | |
|
| | | if (sceneTarget.TaskList.Count > 0)
|
| | | {
|
| | | if (sceneTarget.TaskList.Count == 1)
|
| | | {
|
| | | open.IsSelected = false;
|
| | | shut.IsSelected = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | open.IsSelected = true;
|
| | | shut.IsSelected = false;
|
| | |
|
| | | for (int i = 0; i < sceneTarget.TaskList.Count; i++)
|
| | | {
|
| | | var tasklist = sceneTarget.TaskList[i];
|
| | | if (tasklist.Data1 == 6)
|
| | | {
|
| | | fanid = open.fanList.IndexOf(tasklist.Data2);
|
| | | }
|
| | | if (tasklist.Data1 == 3)
|
| | | {
|
| | | modelId = open.modeList.IndexOf(tasklist.Data2);
|
| | | }
|
| | | if (tasklist.Data1 == 4 || tasklist.Data1 == 5)
|
| | | {
|
| | | tempId = open.temperatureList.IndexOf(tasklist.Data2 / 100);
|
| | | }
|
| | | }
|
| | | open.pickerView.setCurrentItems(tempId, modelId, fanid);
|
| | | }
|
| | | }
|
| | |
|
| | | comfrimBtn.MouseUpEventHandler = (sender, e) =>
|
| | | {
|
| | |
|
| | | var taskList = new List<ZigBee.Device.Scene.TaskListInfo> { };
|
| | |
|
| | | int taskType = 5;
|
| | | int data1 = 0;
|
| | | int data2 = 0;
|
| | |
|
| | | if (shut.IsSelected)
|
| | | {
|
| | | //关
|
| | | data1 = 3;
|
| | | data2 = 0;
|
| | | var taskInfo = new ZigBee.Device.Scene.TaskListInfo
|
| | | {
|
| | | TaskType = taskType,
|
| | | Data1 = data1,
|
| | | Data2 = data2
|
| | | };
|
| | | taskList.Add(taskInfo);
|
| | | }
|
| | | else
|
| | | {
|
| | | //fan
|
| | | var taskInfo = new ZigBee.Device.Scene.TaskListInfo
|
| | | {
|
| | | TaskType = taskType,
|
| | | Data1 = 6,
|
| | | Data2 = open.fanList[fanid]
|
| | | };
|
| | | taskList.Add(taskInfo);
|
| | |
|
| | | //mode
|
| | | var taskInfo2 = new ZigBee.Device.Scene.TaskListInfo
|
| | | {
|
| | | TaskType = taskType,
|
| | | Data1 = 3,
|
| | | Data2 = open.modeList[modelId]
|
| | | };
|
| | | taskList.Add(taskInfo2);
|
| | |
|
| | | //tem
|
| | | if (open.modeList[modelId] == 4)
|
| | | {
|
| | | //heat
|
| | | var taskInfo3 = new ZigBee.Device.Scene.TaskListInfo
|
| | | {
|
| | | TaskType = taskType,
|
| | | Data1 = 4,
|
| | | Data2 = open.temperatureList[tempId] * 100
|
| | | };
|
| | | taskList.Add(taskInfo3);
|
| | |
|
| | | }
|
| | | else
|
| | | {
|
| | | //heat
|
| | | var taskInfo3 = new ZigBee.Device.Scene.TaskListInfo
|
| | | {
|
| | | TaskType = taskType,
|
| | | Data1 = 5,
|
| | | Data2 = open.temperatureList[tempId] * 100
|
| | | };
|
| | | taskList.Add(taskInfo3);
|
| | | }
|
| | | }
|
| | |
|
| | | sceneTarget.TaskList = taskList;
|
| | | sceneTarget.DeviceUI = device;
|
| | | selectedAction?.Invoke(sceneTarget);
|
| | | dialog.RemoveFromParent();
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | }
|
| | | } |