From 1f65fe366062b3f2cda6b03e1849afce6d2646f8 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期四, 17 十月 2019 13:47:37 +0800 Subject: [PATCH] 2019.10.17 --- ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs | 75 ++++++++++++++++++++++++------------- 1 files changed, 49 insertions(+), 26 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs b/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs index eb1575d..3a10ff5 100644 --- a/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs +++ b/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs @@ -16,12 +16,18 @@ /// </summary> private FrameLayout bodyFrameLayout; + 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>> { }; + + #endregion public static string ImagePath; public static string SceneText; - public static Shared.Common.Room CurrentRoom; + public Common.Room curRoom; public static List<SceneTargetDeviceUI> sceneTargetDevicesList = new List<SceneTargetDeviceUI> { }; /// <summary> @@ -284,8 +290,12 @@ /// <summary> /// Show this instance. /// </summary> - public void Show() + public void Show(Common.Room room=null) { + Init(); + + curRoom = room; + AddTop(); AddBodyView(); @@ -294,10 +304,22 @@ #region Add____________________________________ + private void Init() + { + + foreach (var floor in Config.Instance.Home.FloorDics) + { + floorIds.Add(floor.Key); + floorNames.Add(floor.Value); + roomNames.Add(Common.Room.CurrentRoom.GetRoomNamesByFloorId(floor.Key)); + rooms.Add(Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key)); + } + } + /// <summary> /// AddTop /// </summary> - public void AddTop() + private void AddTop() { var top = new TopFrameLayout(); AddChidren(top); @@ -313,7 +335,7 @@ /// <summary> /// AddBodyView /// </summary> - public void AddBodyView() + private void AddBodyView() { bodyFrameLayout = new FrameLayout() { @@ -336,7 +358,8 @@ Height = Application.GetRealHeight(464), Gravity = Gravity.Center, Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius), - UnSelectedImagePath = ImagePath + //UnSelectedImagePath = ImagePath + UnSelectedImagePath = "SceneIcon/3.png" }; imgFL.AddChidren(backGround); @@ -370,8 +393,9 @@ var zoneRow = new DeviceInfoRow(257); zoneRow.Init(); zoneRow.SetTipTitle(R.MyInternationalizationString.BelongZone); - zoneRow.SetTitle(CurrentRoom.Name); + //zoneRow.SetTitle(curRoom.Name); infoFL.AddChidren(zoneRow); + var targetFL = new FrameLayout() { @@ -433,14 +457,14 @@ { nameRow.NameText.Text = SceneText; } - if (CurrentRoom != null) + if (curRoom != null) { } if (Modify) { //title.TextID = R.MyInternationalizationString.ModifyScene; - oldRoom = CurrentRoom; + oldRoom = curRoom; if (ModifySceneUI != null && ModifySceneUI.IsSharedScene) { nameRow.NameText.Enable = false; @@ -458,7 +482,7 @@ //閫夋嫨鑳屾櫙鍥� EventHandler<MouseEventArgs> backGroundIMGHander = (sender, e) => { - if (CurrentRoom.IsSharedRoom) + if (curRoom.IsSharedRoom) { RoomCommon.ShowTipRoomIsShared(); return; @@ -480,28 +504,27 @@ //鍖哄煙 EventHandler<MouseEventArgs> zoneHander = (sender, e) => { - if (CurrentRoom.IsSharedRoom) + if (curRoom.IsSharedRoom) { RoomCommon.ShowTipRoomIsShared(); return; } - var selectRoom = new CategorySceneSelectRoomList(); - UserView.HomePage.Instance.AddChidren(selectRoom); - UserView.HomePage.Instance.PageIndex += 1; - selectRoom.SelectedRoomAction = (room) => + + PickerView.ShowSecondary(floorNames, roomNames, (index1,index2) => { - CurrentRoom = room; - zoneRow.NameText.Text = CurrentRoom.Name; - }; - selectRoom.Show(); + curRoom = rooms[index1][index2]; + zoneRow.NameText.Text = $"{Config.Instance.Home.GetFloorNameById(floorIds[index1])} , {rooms[index1][index2].Name}"; + }, 0,0, Language.StringByID(R.MyInternationalizationString.BelongFloor), Language.StringByID(R.MyInternationalizationString.Confrim), Language.StringByID(R.MyInternationalizationString.Cancel)); }; zoneRow.NextBtn.MouseUpEventHandler += zoneHander; zoneRow.TipBtn.MouseUpEventHandler += zoneHander; + zoneRow.NameText.MouseUpEventHandler += zoneHander; zoneRow.MouseUpEventHandler += zoneHander; + //鎵ц鐩爣-娣诲姞鎵ц璁惧 EventHandler<MouseEventArgs> targetAddHander = (sender, e) => { - if (CurrentRoom.IsSharedRoom) + if (curRoom.IsSharedRoom) { RoomCommon.ShowTipRoomIsShared(); return; @@ -629,7 +652,7 @@ //纭畾娣诲姞鐩爣 confirmBtn.MouseUpEventHandler += async (sender, e) => { - if (CurrentRoom.IsSharedRoom) + if (curRoom.IsSharedRoom) { RemoveFromParent(); return; @@ -769,17 +792,17 @@ } sceneRemoveMemberData.DeviceList = removeSceneDeviceListInfoList; sceneRemoveMemberData.ScenesId = ModifySceneUI.Id; - var result = await CurrentRoom.ModifyScene(ModifySceneUI, sceneRemoveMemberData, memberDataList); + var result = await curRoom.ModifyScene(ModifySceneUI, sceneRemoveMemberData, memberDataList); if (result == 1) { - if (oldRoom != CurrentRoom) + if (oldRoom != curRoom) { oldRoom.SceneUIList.Remove(ModifySceneUI); oldRoom.SceneUIFilePathList.Remove(ModifySceneUI.FileName); - CurrentRoom.SceneUIList.Add(ModifySceneUI); - CurrentRoom.SceneUIFilePathList.Add(ModifySceneUI.FileName); + curRoom.SceneUIList.Add(ModifySceneUI); + curRoom.SceneUIFilePathList.Add(ModifySceneUI.FileName); oldRoom.Save(); - CurrentRoom.Save(); + curRoom.Save(); } RemoveFromParent(); @@ -897,7 +920,7 @@ } } - var result = await CurrentRoom.AddScene(nameRow.NameText.Text, backGround.UnSelectedImagePath, memberDataList); + var result = await curRoom.AddScene(nameRow.NameText.Text, backGround.UnSelectedImagePath, memberDataList); if (result == 1) { RemoveFromParent(); -- Gitblit v1.8.0