From 9c16d3614d9b88c637f967518a329f239fcd3aaf Mon Sep 17 00:00:00 2001 From: lss <316519258@qq.com> Date: 星期五, 12 六月 2020 09:22:04 +0800 Subject: [PATCH] 2020.06.12 --- ZigbeeApp/Shared/Phone/Device/CommonForm/SelectZone.cs | 175 ++++++++++++++++----------------------------------------- 1 files changed, 50 insertions(+), 125 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/SelectZone.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/SelectZone.cs index caedc18..f83aec4 100755 --- a/ZigbeeApp/Shared/Phone/Device/CommonForm/SelectZone.cs +++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/SelectZone.cs @@ -4,145 +4,70 @@ namespace Shared.Phone.Device.CommonForm { - public class SelectZone : FrameLayout + public class SelectZone { public Action<Common.Room> ZoneAction; - - private UIPickerView pickView; - - private List<string> floorList = new List<string> { }; - private List<string> roomList = new List<string> { }; - private List<string> roomIdList = new List<string> { }; - private string currentId; - public SelectZone() - { - } - + /// <summary> + /// curRoom + /// </summary> + private Common.Room curRoom; + /// <summary> + /// 鏍囬 + /// </summary> + public string title = Language.StringByID(R.MyInternationalizationString.BelongZone); /// <summary> /// Init /// </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) => - { - 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); - - backgroundFL.Animate = Animate.DownToUp; - - 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 = 16 - }; - 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 = 16 - }; - topView.AddChidren(confrim); - - pickView = new UIPickerView - { - Y = Application.GetRealHeight(20 + 138), - Height = Application.GetRealHeight(450) - }; - backgroundFL.AddChidren(pickView); - - foreach (var floor in Config.Instance.Home.FloorDics) - { - floorList.Add(floor.Value); - } - foreach (var room in Shared.Common.Room.Lists) - { - roomList.Add(room.Name); - roomIdList.Add(room.Id); - } - - if (floorList.Count == 0) - { - pickView.setNPicker(roomList, null, null); - pickView.OnSelectChangeEvent += (l1, l2, l3) => + foreach (var floor in Config.Instance.Home.FloorDics) { - currentId = roomIdList[l1]; - }; + if (UserCenter.HdlRoomLogic.Current.GetRoomsByFloorId(floor.Key).Count > 0) + { + floorIds.Add(floor.Key); + floorNames.Add(floor.Value); + + roomNames.Add(UserCenter.HdlRoomLogic.Current.GetRoomNamesByFloorId(floor.Key)); + rooms.Add(UserCenter.HdlRoomLogic.Current.GetRoomsByFloorId(floor.Key)); + } + } + PickerView.ShowSecondary(floorNames, roomNames, (index1, index2) => + { + curRoom = rooms[index1][index2]; + ZoneAction?.Invoke(curRoom); + }, 0, 0, title, + Language.StringByID(R.MyInternationalizationString.Confrim), + Language.StringByID(R.MyInternationalizationString.Cancel)); } else { - pickView.setNPicker(floorList, roomList, null); - pickView.OnSelectChangeEvent += (l1, l2, l3) => + var listAllRoom = UserCenter.HdlRoomLogic.Current.GetAllListRooms(); + for (int i = 0; i < listAllRoom.Count; i++) { - currentId = roomIdList[l2]; - }; + var r = listAllRoom[i]; + if (r.IsLove) + { + continue; + } + rs.Add(r); + rNames.Add(r.Name); + } + PickerView.Show(rNames, (index1) => + { + curRoom = rs[index1]; + ZoneAction?.Invoke(curRoom); + }, 0, title, + Language.StringByID(R.MyInternationalizationString.Confrim), + Language.StringByID(R.MyInternationalizationString.Cancel)); } - - cancle.MouseUpEventHandler += Close; - confrim.MouseUpEventHandler += Confrim_MouseEvent; - } - - /// <summary> - /// Close - /// </summary> - /// <param name="sender"></param> - /// <param name="mouseEventArgs"></param> - private void Close(object sender, MouseEventArgs mouseEventArgs) - { - RemoveFromParent(); - } - - /// <summary> - /// Confrim_MouseEvent - /// </summary> - /// <param name="sender"></param> - /// <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)); - } - RemoveFromParent(); } } } -- Gitblit v1.8.0