From f1c3921b08bb22ac6f5db22d620e01d7e8e5c49f Mon Sep 17 00:00:00 2001 From: WJC <wjc@hdlchina.com.cn> Date: 星期一, 30 十二月 2019 13:32:33 +0800 Subject: [PATCH] 2019-12-30-1 --- ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs | 1589 ++++++++++++++++++++++++++++++---------------------------- 1 files changed, 818 insertions(+), 771 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs b/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs old mode 100644 new mode 100755 index b5a8290..9763cd1 --- a/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs +++ b/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs @@ -2,57 +2,95 @@ 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 + public class CategoryAddScene : FrameLayout { - public static string ImagePath; - public static string SceneText; - public static Shared.Common.Room CurrentRoom; - public static List<SceneTargetDeviceUI> sceneTargetDevicesList=new List<SceneTargetDeviceUI>{}; + #region 鈼� 鍙橀噺____________________________ /// <summary> - /// 璁板綍缂栬緫鍓嶇殑璁惧鍒楄〃 + /// bodyFrameLayout /// </summary> - public static List<SceneTargetDeviceUI> beforeSceneTargetDevicesList = new List<SceneTargetDeviceUI> { }; - public static bool Modify = false; - public static SceneUI ModifySceneUI = null; + 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> - /// 鍥剧墖鏉ユ簮 0--鏈湴鍥惧簱 1--鎷嶇収 2--绯荤粺鍥惧簱 + /// ImagePath /// </summary> - public static int IconType = 0; + 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 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; + /// <summary> + /// backGround + /// </summary> + private Button backGround; + + /// <summary> + /// 鏄惁淇敼 + /// </summary> + public bool isModify; + /// <summary> + /// 淇敼鐨勫満鏅� + /// </summary> + public SceneUI modifySceneUI; + /// <summary> + /// 璁板綍缂栬緫鍓嶇殑璁惧鍒楄〃 + /// </summary> + public List<SceneTargetDeviceUI> modifySceneTargetDevicesList; + /// <summary> + /// modifyRoom + /// </summary> + public Common.Room modifyRoom; + + + #endregion + + /// <summary> + /// CategoryAddScene + /// </summary> public CategoryAddScene() { BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; - Tag = "categoryAddScene"; } + /// <summary> + /// RemoveFromParent + /// </summary> public override void RemoveFromParent() { Category.instance?.RefreshBodyView(); @@ -64,106 +102,74 @@ 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) { + var targetRowLayout = new RowLayout() + { + Height = Application.GetRealHeight(160), + LineColor = ZigbeeColor.Current.GXCBackgroundColor, + BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor + }; + TargetListScrolView.AddChidren(targetRowLayout); string devImgPath = string.Empty; string devNameText = string.Empty; - if (targetDevice.Type==0) + if (targetDevice.Type == 0) { if (targetDevice.DeviceUI == null || targetDevice.DeviceUI.CommonDevice == null) continue; devImgPath = targetDevice.DeviceUI.IconPath; devNameText = targetDevice.DeviceUI.CommonDevice.DeviceEpointName; + + var targetRow = new SceneTargetFunctionRow(23); + targetRowLayout.AddChidren(targetRow); + targetRow.Init(); + targetRow.SetIcon(devImgPath); + targetRow.SetNameText(devNameText); + targetRow.SetZoneText(targetDevice.DeviceUI.GetZone()); + targetRow.SetStatuText(targetDevice.GetDeviceStatu()); } - else if(targetDevice.Type==1) + else if (targetDevice.Type == 2) { - devImgPath = "Item/Timer.png"; - devNameText = $"{targetDevice.DelayTime} {Language.StringByID(R.MyInternationalizationString.Second)}"; + devNameText = CommonFormResouce.GetTimeString(targetDevice.DelayTime); + devNameText += Language.StringByID(R.MyInternationalizationString.Later); + var targetRow = new SceneTargetTimeRow(23); + targetRowLayout.AddChidren(targetRow); + targetRow.Init(); + targetRow.SetTitle(devNameText); } - else if(targetDevice.Type==2) + else if (targetDevice.Type == 1) { - devImgPath = "Item/Scene.png"; + devImgPath = "Scene/SceneIcon.png"; devNameText = targetDevice.SceneName; + + var targetRow = new SceneTargetFunctionRow(23); + targetRowLayout.AddChidren(targetRow); + targetRow.Init(); + targetRow.SetIcon(devImgPath); + targetRow.SetNameText(devNameText); + targetRow.SetZoneText(targetDevice.SceneUI.GetZone()); } - var targetRowLayout = new RowLayout() + + var editBtn = new Button() { - LineColor = ZigbeeColor.Current.GXCLineColor, - Height = Application.GetRealHeight(170) + BackgroundColor = ZigbeeColor.Current.GXCEditBackGroundColor, + TextID = R.MyInternationalizationString.Edit, + TextColor = ZigbeeColor.Current.GXCTextWhiteColor }; - 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() + targetRowLayout.AddRightView(editBtn); + //缂栬緫璁惧 + editBtn.MouseUpEventHandler += detailMouseUpEventHandler; + var delBtn = 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)); - }; + targetRowLayout.AddRightView(delBtn); //鍒犻櫎璁惧 - devRight.MouseUpEventHandler += (sender, e) => + delBtn.MouseUpEventHandler += (sender, e) => { sceneTargetDevicesList.Remove(targetDevice); RefreshTargetListView(); @@ -179,93 +185,68 @@ { 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); + var deviceView = new SelectDevice(); + UserView.HomePage.Instance.AddChidren(deviceView); + UserView.HomePage.Instance.PageIndex += 1; + deviceView.sceneTargetDevice = targetDevice; + deviceView.deviceUI = targetDevice.DeviceUI; + deviceView.Show(); + deviceView.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 == 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(); + 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.Show(sceneTargetDevicesList,1,targetDevice.SceneTargetDeviceUIID); + sceneView.sceneTargetDevice = targetDevice; + sceneView.sceneUI = targetDevice.SceneUI; + 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(); + }; } } - devIMG.MouseUpEventHandler += detailMouseUpEventHandler; - devName.MouseUpEventHandler += detailMouseUpEventHandler; - targetRowLayout.MouseUpEventHandler += detailMouseUpEventHandler; - targetFL.MouseUpEventHandler += detailMouseUpEventHandler; + + } } } @@ -274,384 +255,209 @@ /// </summary> public void Show() { - #region topview - var topBGView = new FrameLayout()鈥� {鈥� Height = Application.GetRealHeight(CommonPage.Navigation_Height),鈥� BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor鈥� };鈥� AddChidren(topBGView);鈥� var topView = new FrameLayout()鈥� {鈥� Y = Application.GetRealHeight(CommonPage.NavigationTitle_Y),鈥� Height = Application.GetRealHeight(CommonPage.Navigation_Height - CommonPage.NavigationTitle_Y),鈥� BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor,鈥� };鈥� AddChidren(topView); - var title = new Button() - { - TextAlignment = TextAlignment.Center, - TextID = R.MyInternationalizationString.AddScence, - TextSize = 20, - TextColor = ZigbeeColor.Current.GXCTextBlackColor, - Width = Application.GetRealWidth(CommonPage.AppRealWidth - 500), - Gravity = Gravity.CenterHorizontal - }; - topView.AddChidren(title); - var back = new Device.CommonForm.BackButton() { };鈥� topView.AddChidren(back); - back.MouseUpEventHandler += (sender, e) => - { - this.RemoveFromParent(); - }; - #endregion + Init(); - #region midFL - var midFL = new FrameLayout() - { - Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height), - Y = topView.Bottom, - BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, - }; - this.AddChidren(midFL); - #endregion - #region 鑳屾櫙鍥� 鍚嶇О 鍖哄煙 鎵ц鐩爣 + AddTop(); - var backGround = new Button() + AddBodyView(); + + } + + #region Add____________________________________ + + /// <summary> + /// Init + /// </summary> + private void Init() + { + //foreach (var floor in Config.Instance.Home.FloorDics) + //{ + // floorIds.Add(floor.Key); + // floorNames.Add(floor.Value); + // if(Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key).Count>0) + // { + // roomNames.Add(Common.Room.CurrentRoom.GetRoomNamesByFloorId(floor.Key)); + // rooms.Add(Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key)); + // } + //} + } + + /// <summary> + /// AddTop + /// </summary> + private void AddTop() + { + var top = new TopFrameLayout(); + AddChidren(top); + top.InitTopview(); + if(isModify) { - Y = Application.GetRealHeight(50), - Width = Application.GetRealWidth(980), - Height = Application.GetRealHeight(350), - Gravity = Gravity.CenterHorizontal, - Radius = CommonPage.BigFormRadius, - UnSelectedImagePath = ImagePath + top.SetTopTitle(R.MyInternationalizationString.EditorScene); + } + else + { + top.SetTopTitle(R.MyInternationalizationString.AddScence); + } + top.backButton.MouseUpEventHandler += (sender, e) => + { + RemoveFromParent(); }; - midFL.AddChidren(backGround); - //--鍦烘櫙鍚� - var sceneNameFL = new FrameLayout() + } + + /// <summary> + /// AddBodyView + /// </summary> + private void AddBodyView() + { + bodyFrameLayout = new FrameLayout() { - Y = backGround.Bottom + Application.GetRealHeight(100), - Height = Application.GetRealHeight(170), + Y = Application.GetRealHeight(184), + Height = Application.GetRealHeight(1737), + BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, }; - midFL.AddChidren(sceneNameFL); - var sceneNameTip = new Button() + AddChidren(bodyFrameLayout); + + var imgFL = new FrameLayout { - X = Application.GetRealWidth(50), - Height = Application.GetRealHeight(70), - Width = Application.GetRealWidth(300), - TextAlignment = TextAlignment.CenterLeft, - TextSize = 12, - TextColor = ZigbeeColor.Current.GXCButtonTipColor, - TextID = R.MyInternationalizationString.SceneName, + Height = Application.GetRealHeight(556), + BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; - sceneNameFL.AddChidren(sceneNameTip); - var sceneNameET = new EditText() + bodyFrameLayout.AddChidren(imgFL); + + backGround = new Button() { - X = Application.GetRealWidth(50), - Y = sceneNameTip.Bottom, - Height = Application.GetRealHeight(100) - 1, + Width = Application.GetMinRealAverage(930), + Height = Application.GetMinRealAverage(464), + Gravity = Gravity.Center, + Radius = (uint)Application.GetMinRealAverage(CommonFormResouce.BigFormRadius), + //UnSelectedImagePath = ImagePath + UnSelectedImagePath = "SceneIcon/3.jpg" + }; + imgFL.AddChidren(backGround); + backGround.SetViewShadow(true); + + 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 = 20, - PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputSceneName), - PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor, - TextColor = ZigbeeColor.Current.GXCTextBlackColor, + TextSize = 14 }; - sceneNameFL.AddChidren(sceneNameET); - var sceneNameLine = new Button() - { - Y = sceneNameET.Bottom, - Height = 1, - BackgroundColor = ZigbeeColor.Current.GXCLineColor - }; - sceneNameFL.AddChidren(sceneNameLine); - //zone - var zoneFL = new FrameLayout() - { - Y = sceneNameFL.Bottom, - Height = Application.GetRealHeight(170), - }; - midFL.AddChidren(zoneFL); - var zoneTip = new Button() - { - X = Application.GetRealWidth(50), - Height = Application.GetRealHeight(70), - Width = Application.GetRealWidth(300), - TextAlignment = TextAlignment.CenterLeft, - TextSize = 12, - TextColor = ZigbeeColor.Current.GXCButtonTipColor, - TextID = R.MyInternationalizationString.BelongZone, - }; - zoneFL.AddChidren(zoneTip); - var zone = new Button() - { - X = Application.GetRealWidth(50), - Y = sceneNameTip.Bottom, - Height = Application.GetRealHeight(100) - 1, - Width = Application.GetRealWidth(500), - TextAlignment = TextAlignment.CenterLeft, - TextSize = 20, - TextColor = ZigbeeColor.Current.GXCTextBlackColor, - Text = CurrentRoom.Name - }; - zoneFL.AddChidren(zone); - var zoneRight = new Device.CommonForm.SelectedStatuButton() - { - X = Application.GetRealWidth(1080 - 150), - Width = Application.GetMinRealAverage(110), - Height = Application.GetMinRealAverage(110), - UnSelectedImagePath = "Item/Next.png", - SelectedImagePath="Item/NextSelected.png", - Gravity = Gravity.CenterVertical - }; - zoneFL.AddChidren(zoneRight); - var zoneLine = new Button() - { - Y = zone.Bottom, - Height = 1, - BackgroundColor = ZigbeeColor.Current.GXCLineColor - }; - zoneFL.AddChidren(zoneLine); - //娣诲姞鎵ц鐩爣 + 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.Init(); + zoneRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongZone)}:"); + //zoneRow.SetTitle(curRoom.Name); + infoFL.AddChidren(zoneRow); + zoneRow.HideLine(true); + var targetFL = new FrameLayout() { - Y = zoneFL.Bottom, - Height = Application.GetRealHeight(170), + Y = infoFL.Bottom + Application.GetRealHeight(23), + Height = Application.GetRealHeight(730) }; - midFL.AddChidren(targetFL); + 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(50), - Y = sceneNameTip.Bottom, - Height = Application.GetRealHeight(170) - 1, - Width = Application.GetRealWidth(500), + X = Application.GetRealWidth(CommonFormResouce.X_Left), + Height = Application.GetRealHeight(127) - 1, + Width = Application.GetRealWidth(600), TextAlignment = TextAlignment.CenterLeft, - TextSize = 20, TextColor = ZigbeeColor.Current.GXCTextBlackColor, - TextID = R.MyInternationalizationString.AddRoomScentTargetAction, + TextID = R.MyInternationalizationString.AddScentTargetAction, Gravity = Gravity.CenterVertical }; - targetFL.AddChidren(target); - var targetAdd = new Device.CommonForm.SelectedStatuButton() + addTargetFL.AddChidren(target); + + var targetAdd = new Button { - X = Application.GetRealWidth(1080 - 150), - Width = Application.GetMinRealAverage(110), - Height = Application.GetMinRealAverage(110), + X = Application.GetRealWidth(950), + Y = Application.GetRealHeight(46), + Width = Application.GetMinRealAverage(72), + Height = Application.GetMinRealAverage(72), + Gravity=Gravity.CenterVertical, UnSelectedImagePath = "Item/Add.png", - SelectedImagePath="Item/AddSelected.png", - Gravity = Gravity.CenterVertical }; - targetFL.AddChidren(targetAdd); + addTargetFL.AddChidren(targetAdd); var targetLine = new Button() { Y = target.Bottom, Height = 1, - BackgroundColor = ZigbeeColor.Current.GXCLineColor + BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2 }; - targetFL.AddChidren(targetLine); + addTargetFL.AddChidren(targetLine); + //娣诲姞鐩爣鍚庣殑灞曠ず鍒楄〃 TargetListScrolView = new VerticalScrolViewLayout() { - Y = targetFL.Bottom, - Height = Application.GetRealHeight(340+170), - BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor + Y = Application.GetRealHeight(49+127), + Height = Application.GetRealHeight(730-127-49), + //BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; - midFL.AddChidren(TargetListScrolView); - confirmBtn = new CommonForm.CompleteButton() - { - TextID = R.MyInternationalizationString.NextStep, - }; + targetFL.AddChidren(TargetListScrolView); + + confirmBtn = new CommonForm.CompleteButton(1656, 907, 127); AddChidren(confirmBtn); - RefreshTargetListView(); - if (!string.IsNullOrEmpty(SceneText)) + if(isModify) { - sceneNameET.Text = SceneText; + backGround.UnSelectedImagePath = modifySceneUI.IconPath; + nameRow.SetTitle(modifySceneUI.Name); + zoneRow.SetTitle($"{Config.Instance.Home.GetFloorNameById(modifyRoom.FloorId)},{modifyRoom.Name}"); + IconPathType = modifySceneUI.IconPathType; + curRoom = modifyRoom; + sceneTargetDevicesList.AddRange(modifySceneTargetDevicesList); } - if(CurrentRoom!=null) - { - } - if(Modify) - { - title.TextID = R.MyInternationalizationString.ModifyScene; - oldRoom = CurrentRoom; - if (ModifySceneUI != null && ModifySceneUI.IsSharedScene) - { - sceneNameET.Enable = false; - } - } - #endregion + RefreshTargetListView(); + #region event - //璁板綍杈撳叆鍦烘櫙鍚� - sceneNameET.TextChangeEventHandler += (sender, e) => - { - SceneText = sceneNameET.Text.Trim(); - }; //閫夋嫨鑳屾櫙鍥� EventHandler<MouseEventArgs> backGroundIMGHander = (sender, e) => { - if(CurrentRoom.IsSharedRoom) + if (curRoom != null && curRoom.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; - }; - - //var selectDialog = new Dialog() - //{ - //}; - //selectDialog.Show(); - - //var itemFL = new FrameLayout() - //{ - // Y = Application.GetRealHeight(1920 - 600), - // Width = Application.GetRealWidth(900), - // Height = Application.GetRealHeight(550), - // Radius = CommonPage.BigFormRadius, - // //BackgroundColor=ZigbeeColor.Current.GXCBackgroundColor, - // Gravity = Gravity.CenterHorizontal - //}; - //selectDialog.AddChidren(itemFL); - - //var localPicBtn = new Button() - //{ - // Height = Application.GetRealHeight(130) - 1, - // TextID = R.MyInternationalizationString.LocalPic, - // TextColor = ZigbeeColor.Current.GXCTextBlackColor, - // TextAlignment = TextAlignment.Center, - // BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor - //}; - //itemFL.AddChidren(localPicBtn); - //var localPicLine = new Button() - //{ - // Y = localPicBtn.Bottom, - // Height = 1, - // BackgroundColor = ZigbeeColor.Current.GXCLineColor, - //}; - //itemFL.AddChidren(localPicLine); - - //var takePhotoBtn = new Button() - //{ - // Y = localPicLine.Bottom, - // Height = Application.GetRealHeight(130) - 1, - // TextID = R.MyInternationalizationString.TakePhoto, - // TextColor = ZigbeeColor.Current.GXCTextBlackColor, - // TextAlignment = TextAlignment.Center, - // BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor - //}; - //itemFL.AddChidren(takePhotoBtn); - //var takePhotoLine = new Button() - //{ - // Y = takePhotoBtn.Bottom, - // Height = 1, - // BackgroundColor = ZigbeeColor.Current.GXCLineColor, - //}; - //itemFL.AddChidren(takePhotoLine); - - //var systemPicBtn = new Button() - //{ - // Y = takePhotoLine.Bottom, - // Height = Application.GetRealHeight(130), - // TextID = R.MyInternationalizationString.SystemPic, - // TextColor = ZigbeeColor.Current.GXCTextBlackColor, - // TextAlignment = TextAlignment.Center, - // BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor - //}; - //itemFL.AddChidren(systemPicBtn); - - - //var cancelBtn = new Button() - //{ - // Y = systemPicBtn.Bottom + Application.GetRealHeight(30), - // Height = Application.GetRealHeight(150), - // TextID = R.MyInternationalizationString.Cancel, - // TextColor = ZigbeeColor.Current.GXCTextWhiteColor, - // BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor, - // TextAlignment = TextAlignment.Center, - //}; - //itemFL.AddChidren(cancelBtn); - - ////鏈湴鍥惧簱 - //localPicBtn.MouseUpEventHandler += (send, ee) => - //{ - // selectDialog.Close(); - // var localPic = new CategorySceneSelectImgByLocal(); - // Shared.Phone.UserView.HomePage.Instance.AddChidren(localPic); - // Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; - // localPic.Show(); - // localPic.action = () => - // { - // backGround.UnSelectedImagePath = ImagePath; - // IconType = 0; - // }; - //}; - ////鎷嶇収 - //takePhotoBtn.MouseUpEventHandler += (send, ee) => - //{ - // var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); - // selectDialog.Close(); - // Camera.TakePicture((obj) => - // { - // if (obj == null) - // { - // return; - // } - // backGround.UnSelectedImagePath = $"ScenePicture{tradeTime}.png"; - // ImagePath = $"{Config.Instance.HomeId}/{backGround.UnSelectedImagePath}"; - // IconType = 1; - // }, $"ScenePicture{tradeTime}.png"); - //}; - ////绯荤粺鍥惧簱 - //systemPicBtn.MouseUpEventHandler += (send, ee) => - //{ - // var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); - // selectDialog.Close(); - // Camera.SelectPicture((obj) => - // { - // if (obj == null) - // { - // return; - // } - // backGround.UnSelectedImagePath = $"ScenePicture{tradeTime}.png"; - // ImagePath = $"{Config.Instance.HomeId}/{backGround.UnSelectedImagePath}"; - // IconType = 2; - // }, $"ScenePicture{tradeTime}.png"); - //}; - //cancelBtn.MouseUpEventHandler += (send, ee) => - //{ - // selectDialog.Close(); - //}; - }; - backGround.MouseUpEventHandler += backGroundIMGHander; - //鍖哄煙 - EventHandler<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; - zone.Text = CurrentRoom.Name; - }; - selectRoom.Show(); - }; - zoneRight.MouseUpEventHandler += zoneHander; - zoneFL.MouseUpEventHandler += zoneHander; - zone.MouseUpEventHandler += zoneHander; - //鎵ц鐩爣-娣诲姞鎵ц璁惧 - EventHandler<MouseEventArgs> targetAddHander = (sender, e) => - { - if (CurrentRoom.IsSharedRoom) - { - RoomCommon.ShowTipRoomIsShared(); - return; - } - - int selectRow_Height = 130; + int selectRow_Height = 150; + int selectRow_Width = 1034; var selectFL = new FrameLayout() { BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor @@ -660,37 +466,250 @@ var itemFL = new FrameLayout() { - Y = Application.GetRealHeight(CommonPage.AppRealHeight - selectRow_Height * 4 - 20), - Height = Application.GetRealHeight(selectRow_Height * 4 + 20) + Y = Application.GetRealHeight(1276), + Height = Application.GetRealHeight(450), + Width = Application.GetRealWidth(selectRow_Width), + Gravity = Gravity.CenterHorizontal, + Radius = (uint)Application.GetRealHeight(17), + BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor }; selectFL.AddChidren(itemFL); + itemFL.Animate = Animate.DownToUp; - var selectedFunctionBtn = new Device.CommonForm.SelectedStatuButton() + var selectLocalPicture = new Button() + { + Height = Application.GetRealHeight(selectRow_Height) - 1, + TextID = R.MyInternationalizationString.LocalPicture, + TextColor = ZigbeeColor.Current.GXCTextSelectedColor4 + }; + itemFL.AddChidren(selectLocalPicture); + var selectLocalLine = new Button() + { + Y = selectLocalPicture.Bottom, + Height = 1, + BackgroundColor = ZigbeeColor.Current.GXCLineColor + }; + itemFL.AddChidren(selectLocalLine); + + var selectPhotographBtn = new Button() + { + Y = selectLocalLine.Bottom, + Height = Application.GetRealHeight(selectRow_Height) - 1, + TextID = R.MyInternationalizationString.Photograph, + TextColor = ZigbeeColor.Current.GXCTextSelectedColor4 + }; + itemFL.AddChidren(selectPhotographBtn); + var selectPhotographLine = new Button() + { + Y = selectPhotographBtn.Bottom, + Height = 1, + BackgroundColor = ZigbeeColor.Current.GXCLineColor, + }; + itemFL.AddChidren(selectPhotographLine); + + var selectAblumsBtn = new Button() + { + Y = selectPhotographLine.Bottom, + Height = Application.GetRealHeight(selectRow_Height) - 1, + TextID = R.MyInternationalizationString.MyAblums, + TextColor = ZigbeeColor.Current.GXCTextSelectedColor4 + }; + 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(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.UnSelectedImagePath = imgPath; + }; + }; + selectPhotographBtn.MouseUpEventHandler += (send, ee) => + { + selectFL.RemoveFromParent(); + var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); + var fileName = $"Scene_{tradeTime}"; + //閫氳繃鐩告満鎷嶇収瑁佸壀 + CropImage.TakePicture((imagePath) => + { + if (isModify) + { + if (IconPathType != 0) + { + Global.DeleteFilebyHomeId(backGround.UnSelectedImagePath); + } + } + + IconPathType = 1; + backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath); + backGround.UnSelectedImagePath = 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 = $"Scene_{tradeTime}"; + //浠庣浉鍐岄�夋嫨鍥剧墖瑁佸壀 + CropImage.SelectPicture((imagePath) => + { + if (isModify) + { + if (IconPathType != 0) + { + Global.DeleteFilebyHomeId(backGround.UnSelectedImagePath); + } + } + + IconPathType = 2; + backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath); + backGround.UnSelectedImagePath = 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) => + { + 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) + { + foreach (var floor in Config.Instance.Home.FloorDics) + { + floorIds.Add(floor.Key); + floorNames.Add(floor.Value); + if (Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key).Count > 0) + { + roomNames.Add(Common.Room.CurrentRoom.GetRoomNamesByFloorId(floor.Key)); + rooms.Add(Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key)); + } + } + 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.BelongFloor), + 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.BelongFloor), + Language.StringByID(R.MyInternationalizationString.Confrim), + Language.StringByID(R.MyInternationalizationString.Cancel)); + } + }; + zoneRow.ClickBtn.MouseUpEventHandler += zoneHander; + + //鎵ц鐩爣-娣诲姞鎵ц璁惧 + EventHandler<MouseEventArgs> targetAddHander = (sender, e) => + { + + if (curRoom == null) + { + RoomCommon.ShowTipNoRoom(); + return; + } + 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(17), + 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.GXCTextBlackColor, - TextAlignment = TextAlignment.Center, - BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, - SelectedBackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor + TextColor = ZigbeeColor.Current.GXCTextSelectedColor4 }; itemFL.AddChidren(selectedFunctionBtn); var selectedFunctionLine = new Button() { Y = selectedFunctionBtn.Bottom, Height = 1, - BackgroundColor = ZigbeeColor.Current.GXCLineColor, + BackgroundColor = ZigbeeColor.Current.GXCLineColor }; itemFL.AddChidren(selectedFunctionLine); - var selectedSceneBtn = new Device.CommonForm.SelectedStatuButton() + var selectedSceneBtn = new Button() { Y = selectedFunctionLine.Bottom, Height = Application.GetRealHeight(selectRow_Height) - 1, TextID = R.MyInternationalizationString.Scence, - TextColor = ZigbeeColor.Current.GXCTextBlackColor, - BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, - SelectedBackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor + TextColor = ZigbeeColor.Current.GXCTextSelectedColor4 }; itemFL.AddChidren(selectedSceneBtn); var selectedSceneLine = new Button() @@ -701,63 +720,75 @@ }; itemFL.AddChidren(selectedSceneLine); - var selectedTimerBtn = new Device.CommonForm.SelectedStatuButton() + var selectedTimerBtn = new Button() { Y = selectedSceneLine.Bottom, - Height = Application.GetRealHeight(selectRow_Height)-1, - TextID = R.MyInternationalizationString.TimeSpan, - TextColor = ZigbeeColor.Current.GXCTextBlackColor, - BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, - SelectedBackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor + Height = Application.GetRealHeight(selectRow_Height) - 1, + TextID = R.MyInternationalizationString.Delay, + TextColor = ZigbeeColor.Current.GXCTextSelectedColor4 }; itemFL.AddChidren(selectedTimerBtn); - var cancelBtn = new Device.CommonForm.SelectedStatuButton() - { - Y = selectedTimerBtn.Bottom + Application.GetRealHeight(20), - Height = Application.GetRealHeight(selectRow_Height), - TextID = R.MyInternationalizationString.Cancel, - TextColor = ZigbeeColor.Current.GXCTextBlackColor, - BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, - SelectedBackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor - }; - itemFL.AddChidren(cancelBtn); - itemFL.Animate = Animate.DownToUp; + var cancelBtn = new Button() + { + Y = Application.GetRealHeight(1742), + Height = Application.GetRealHeight(selectRow_Height), + Width = Application.GetRealWidth(selectRow_Width), + Gravity=Gravity.CenterHorizontal, + TextID = R.MyInternationalizationString.Cancel, + TextColor = ZigbeeColor.Current.GXCTextSelectedColor4, + BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, + Radius = (uint)Application.GetRealHeight(17) + }; + selectFL.AddChidren(cancelBtn); + //娣诲姞鍔熻兘 selectedFunctionBtn.MouseUpEventHandler += (send, ee) => { selectFL.RemoveFromParent(); - var deviceTypeList = new CategorySceneSelectDevice(); - UserView.HomePage.Instance.AddChidren(deviceTypeList); + var deviceView = new SelectDevice(); + UserView.HomePage.Instance.AddChidren(deviceView); UserView.HomePage.Instance.PageIndex += 1; - deviceTypeList.Show(sceneTargetDevicesList); + deviceView.beforeSceneTargetDeviceUIs = sceneTargetDevicesList; + deviceView.Show(); + deviceView.selectedAction = (selectedDevice) => + { + sceneTargetDevicesList.Add(selectedDevice); + RefreshTargetListView(); + }; }; //娣诲姞鍦烘櫙 selectedSceneBtn.MouseUpEventHandler += (send, ee) => { selectFL.RemoveFromParent(); - var sceneView = new CategorySceneSelectedScene(); + var sceneView = new SelectScene(); UserView.HomePage.Instance.AddChidren(sceneView); UserView.HomePage.Instance.PageIndex += 1; - if(Modify) + sceneView.beforeSceneTargetDeviceUIs = sceneTargetDevicesList; + sceneView.Show(); + sceneView.selectedAction = (selectedScene) => { - sceneView.Show(sceneTargetDevicesList,-1, "", false, ModifySceneUI.Id); - } - else - { - sceneView.Show(sceneTargetDevicesList); - } + sceneTargetDevicesList.Add(selectedScene); + RefreshTargetListView(); + }; + }; //娣诲姞鏃堕棿闂撮殧 selectedTimerBtn.MouseUpEventHandler += (send, ee) => { selectFL.RemoveFromParent(); - var delayTimeView = new CategorySceneSelectedDelayTime(); + var delayTimeView = new SelectDelayTime(); UserView.HomePage.Instance.AddChidren(delayTimeView); UserView.HomePage.Instance.PageIndex += 1; delayTimeView.Show(); + delayTimeView.selectedTimeAction = (second) => + { + sceneTargetDevicesList.Add(second); + RefreshTargetListView(); + }; }; + cancelBtn.MouseUpEventHandler += (send, ee) => { selectFL.RemoveFromParent(); @@ -770,188 +801,24 @@ targetAdd.MouseUpEventHandler += targetAddHander; targetFL.MouseUpEventHandler += targetAddHander; target.MouseUpEventHandler += targetAddHander; + addTargetFL.MouseUpEventHandler += targetAddHander; //纭畾娣诲姞鐩爣 confirmBtn.MouseUpEventHandler += async (sender, e) => { - if (CurrentRoom.IsSharedRoom) + if (curRoom == null) + { + RoomCommon.ShowTipNoRoom(); + return; + } + if (curRoom.IsSharedRoom) { RemoveFromParent(); return; } - if (Modify) - { - try - { - CommonPage.Loading.Start(); - //淇敼--鍏堝垽鏂満鏅悕鏄惁鏀瑰彉锛屽啀绉婚櫎璁惧锛屽啀娣诲姞璁惧 - ModifySceneUI.IconPath = ImagePath; - if (ModifySceneUI.Name != sceneNameET.Text.Trim()) - { - if (Shared.Common.Room.AllRoomSceneUIList.Find(s => s.Name == sceneNameET.Text.Trim()) != null) - { - Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); - return; - } - //淇敼鍚嶅瓧 - var r = await ZigBee.Device.Scene.RenameSceneAsync(ModifySceneUI.Id, sceneNameET.Text.Trim()); - var reName = r.sceneRenameResponseData.Result; - if (reName == 0) - { - //澶辫触 - return; - } - else if (reName == 1) - { - //鎴愬姛 - ModifySceneUI.Name = sceneNameET.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(isModify) { - if (string.IsNullOrEmpty(sceneNameET.Text)) + 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(); @@ -964,84 +831,260 @@ { try { - if (Shared.Common.Room.AllRoomSceneUIList.Find(s => s.Name == sceneNameET.Text.Trim()) != null) + var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); + var fileName = $"Scene_{tradeTime}"; + //鏀瑰悕 + if (modifySceneUI.Name != nameRow.NameText.Text.Trim()) { - Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); - return; + if (Common.Room.CurrentRoom.GetSameFloorScenes(curRoom.FloorId).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; + } } + //鍥剧墖 + if(IconPathType==1 || IconPathType ==2) + { + Shared.IO.FileUtils.WriteFileByBytes(System.IO.Path.Combine(Config.Instance.FullPath, fileName), backGround.ImageBytes); + modifySceneUI.IconPath = System.IO.Path.Combine(Config.Instance.FullPath, fileName); + } + else + { + modifySceneUI.IconPath = backGround.UnSelectedImagePath; + } + modifySceneUI.IconPathType = IconPathType; + 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) + var memberData = new AddSceneMemberData { - 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, + DeviceAddr = sceneTarget.DeviceUI.CommonDevice.DeviceAddr, Epoint = sceneTarget.DeviceUI.CommonDevice.DeviceEpoint, TaskList = sceneTarget.TaskList, - DelayTime = AddedDelayTime + 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) { - if (beforeSceneTarget != null && beforeSceneTarget.Type == 1) + var memberData = new AddSceneMemberData { - 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, + Type = 2, ScenesId = 0, - ElseScenesId = sceneTarget.ElseScenesId, - DelayTime = AddedDelayTime + DelayTime = sceneTarget.DelayTime, + MemberNumber = i+1 }; memberDataList.Add(memberData); } } - var result = await CurrentRoom.AddScene(sceneNameET.Text, backGround.UnSelectedImagePath, memberDataList); + 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 || sceneTarget.DeviceUI.CommonDevice == null) + { + continue; + } + var removeDevice = new RemoveSceneDeviceListInfo + { + Type = 0, + DeviceAddr = sceneTarget.DeviceUI.CommonDevice.DeviceAddr, + Epoint = sceneTarget.DeviceUI.CommonDevice.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 curRoom.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.Save(); + curRoom.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 + { + 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); + imgPath = System.IO.Path.Combine(Config.Instance.FullPath, fileName); + } + else + { + imgPath = backGround.UnSelectedImagePath; + } + if (Common.Room.CurrentRoom.GetSameFloorScenes(curRoom.FloorId).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>(); + for (int i = 0; i < sceneTargetDevicesList.Count; i++) + { + var sceneTarget = sceneTargetDevicesList[i]; + + if (sceneTarget.Type == 0) + { + if (sceneTarget.DeviceUI == null || sceneTarget.DeviceUI.CommonDevice == null) + { + continue; + } + var memberData = new AddSceneMemberData + { + Type = 0, + ScenesId = 0, + DeviceAddr = sceneTarget.DeviceUI.CommonDevice.DeviceAddr, + Epoint = sceneTarget.DeviceUI.CommonDevice.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 curRoom.AddScene(nameRow.NameText.Text, imgPath, memberDataList); if (result == 1) { RemoveFromParent(); @@ -1068,8 +1111,12 @@ } } + + }; #endregion } + + #endregion } } -- Gitblit v1.8.0