using System; using System.Collections.Generic; using HDL_ON.Entity; namespace HDL_ON { /// /// 房间楼层选择弹窗 /// public class FloorSelectPopupDialog { /// /// /// public FloorSelectPopupDialog() { } /// /// 一级List /// List mFirstList = new List(); /// /// 二级联动List /// List> mSecondList = new List>(); /// /// 读取本地楼层和房间数据,弹窗显示 /// /// 回调选中事件,回调选中的uid /// 设置选中的tga标记 public void ShowView(Action selectAction, string selectTag = DiySelectPopupDialog.ALLSELECT, int offsetY = 0) { //楼层集合数据 var floorList = SpatialInfo.CurrentSpatial.FloorList; //房间集合数据 var roomList = SpatialInfo.CurrentSpatial.RoomList; //根据楼层和房间数据结情况加载对于效果弹窗 if (floorList == null || floorList.Count == 0) { //没有楼层只加载房间 if (roomList == null) { Utlis.WriteLine("floorList and roomList null"); roomList = new List(); } mFirstList.Clear(); //遍历所有房间列表 foreach (var room in roomList) { mFirstList.Add(new RoomCellInfo() { Title = room.roomName, TagId = room.uid }); } //弹窗一级联动选择窗口 var roomSelectPopupDialog = new DiySelectPopupDialog(); roomSelectPopupDialog.ShowView(mFirstList, null, selectAction, selectTag,offsetY); } else { mFirstList.Clear(); mSecondList.Clear(); //一级数组为楼层 foreach (var floor in floorList) { //遍历所有楼层列表以及楼层所关联房间的列表 mFirstList.Add(new RoomCellInfo() { Title = floor.roomName, TagId = floor.uid }); var mList = new List(); var allRoom = roomList.FindAll((room) => room.parentId == floor.uid); foreach (var mRoom in allRoom) { mList.Add(new RoomCellInfo() { Title = mRoom.roomName, TagId = mRoom.uid }); } if(mList == null) { mList = new List(); } mSecondList.Add(mList); } //弹窗二级联动选择窗口 var roomSelectPopupDialog = new DiySelectPopupDialog(); roomSelectPopupDialog.ShowView(mFirstList, mSecondList, selectAction, selectTag,offsetY); } } } }