From 3dcbd186c42c598c0c08d1cd37034cf2baa09e54 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期一, 30 十二月 2019 15:47:51 +0800 Subject: [PATCH] 合并了代码 --- ZigbeeApp/Shared/Phone/Device/CommonForm/SelectZone.cs | 142 +++++++++++++++++----------------------------- 1 files changed, 53 insertions(+), 89 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/SelectZone.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/SelectZone.cs index 78d0cef..2779996 100755 --- a/ZigbeeApp/Shared/Phone/Device/CommonForm/SelectZone.cs +++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/SelectZone.cs @@ -13,7 +13,11 @@ private List<string> floorList = new List<string> { }; private List<string> roomList = new List<string> { }; private List<string> roomIdList = new List<string> { }; - private string currentId; + /// <summary> + /// curRoom + /// </summary> + private Common.Room curRoom; + public SelectZone() { } @@ -23,70 +27,54 @@ /// </summary> public void Init() { - var dialog = new FrameLayout() + 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) { - BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor - }; - AddChidren(dialog); - - dialog.MouseUpEventHandler += (sender, e) => + 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]; + ZoneAction?.Invoke(curRoom); + RemoveFromParent(); + }, 0, 0, Language.StringByID(R.MyInternationalizationString.BelongFloor), + Language.StringByID(R.MyInternationalizationString.Confrim), + Language.StringByID(R.MyInternationalizationString.Cancel)); + } + else { - RemoveFromParent(); - }; - - var backgroundFL = new FrameLayout - { - Y = Application.GetRealHeight(1115), - Height = Application.GetRealHeight(805), - BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, - Radius = (uint)Application.GetRealHeight(20) - }; - dialog.AddChidren(backgroundFL); - - var topView = new FrameLayout - { - Height = Application.GetRealHeight(138) - }; - backgroundFL.AddChidren(topView); - - var cancle = new Button - { - X = Application.GetRealWidth(80), - Width = Application.GetRealWidth(300), - TextAlignment = TextAlignment.CenterLeft, - TextColor = ZigbeeColor.Current.GXCTextGrayColor, - TextID = R.MyInternationalizationString.Cancel, - TextSize = 14 - }; - topView.AddChidren(cancle); - - var title = new Button - { - Width = Application.GetRealWidth(300), - Gravity = Gravity.CenterHorizontal, - TextColor = ZigbeeColor.Current.GXCTextBlackColor2, - TextID = R.MyInternationalizationString.AddTo, - TextSize = 16 - }; - topView.AddChidren(title); - - var confrim = new Button - { - X = Application.GetRealWidth(CommonFormResouce.AppRealWidth - 80 - 300), - Width = Application.GetRealWidth(300), - TextAlignment = TextAlignment.CenterRight, - TextColor = ZigbeeColor.Current.GXCTextSelectedColor2, - TextID = R.MyInternationalizationString.Confrim, - TextSize = 14 - }; - topView.AddChidren(confrim); - - pickView = new UIPickerView - { - Y = Application.GetRealHeight(20 + 138), - Height = Application.GetRealHeight(450) - }; - backgroundFL.AddChidren(pickView); + 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]; + ZoneAction?.Invoke(curRoom); + RemoveFromParent(); + }, 0, Language.StringByID(R.MyInternationalizationString.BelongFloor), + Language.StringByID(R.MyInternationalizationString.Confrim), + Language.StringByID(R.MyInternationalizationString.Cancel)); + } foreach (var floor in Config.Instance.Home.FloorDics) { @@ -101,28 +89,7 @@ roomList.Add(room.Name); roomIdList.Add(room.Id); } - - if (floorList.Count == 0) - { - pickView.setNPicker(roomList, null, null); - currentId = roomIdList[0]; - pickView.OnSelectChangeEvent += (l1, l2, l3) => - { - currentId = roomIdList[l1]; - }; - } - else - { - pickView.setNPicker(floorList, roomList, null); - currentId = roomIdList[0]; - pickView.OnSelectChangeEvent += (l1, l2, l3) => - { - currentId = roomIdList[l2]; - }; - } - - cancle.MouseUpEventHandler += Close; - confrim.MouseUpEventHandler += Confrim_MouseEvent; + } /// <summary> @@ -142,10 +109,7 @@ /// <param name="mouseEventArgs"></param> private void Confrim_MouseEvent(object sender, MouseEventArgs mouseEventArgs) { - if (Shared.Common.Room.CurrentRoom.GetRoomById(currentId) != null) - { - ZoneAction?.Invoke(Shared.Common.Room.CurrentRoom.GetRoomById(currentId)); - } + ZoneAction?.Invoke(curRoom); RemoveFromParent(); } } -- Gitblit v1.8.0