using System; using Shared.Common; using Shared.Phone.Device.Category; using Shared.Phone.Device.CommonForm; using Shared.Phone.UserView; namespace Shared.Phone.Device.Room { public class RoomManagement : FrameLayout { #region ◆ 变量____________________________ /// /// bodyFrameLayout /// private FrameLayout bodyFrameLayout; private Button floorBtn; /// /// 当前楼层id /// private string curFloorId; public FrameLayout itemView; static RoomManagement roomManagement; public static RoomManagement Instance { get { if (roomManagement == null) { roomManagement = new RoomManagement { }; } return roomManagement; } } /// /// 是否可以触发点击事件--是否可以跳转主页房间 /// public bool CanClick = true; #endregion public Action action; public override void RemoveFromParent() { //action?.Invoke(); base.RemoveFromParent(); } /// /// 房间管理 /// public void Show() { RemoveAll(); AddTop(); AddBodyView(Config.Instance.Home.CurrentFloorId); } #region Add____________________________________ /// /// AddTop /// public void AddTop() { var top = new TopFrameLayout(); AddChidren(top); top.InitTopview(); top.SetTopTitle(R.MyInternationalizationString.RoomList); top.backButton.MouseUpEventHandler += (sender, e) => { CommonPage.Instance.CloseLeftMenu(); }; floorBtn = new Button() { X = Application.GetRealWidth(650), Width = Application.GetRealWidth(300), Height = Application.GetRealHeight(60), Gravity = Gravity.CenterVertical, TextAlignment = TextAlignment.CenterRight, TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize = 14, IsBold = true }; var selectFloorBtn = new Button() { X = Application.GetRealWidth(950), Width = Application.GetMinRealAverage(69), Height = Application.GetMinRealAverage(69), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "Item/Drop_Down.png" }; floorBtn.Text = Config.Instance.Home.GetCurrentFloorName; if(Config.Instance.Home.FloorDics.Count>0) { curFloorId = Config.Instance.Home.CurrentFloorId; top.topView.AddChidren(floorBtn); top.topView.AddChidren(selectFloorBtn); } selectFloorBtn.MouseUpEventHandler += SelectedFloor_MouseUpEventHandler; floorBtn.MouseUpEventHandler += SelectedFloor_MouseUpEventHandler; } /// /// 选择楼层 /// /// Sender. /// The ${ParameterType} instance containing the event data. private void SelectedFloor_MouseUpEventHandler(object sender, MouseEventArgs mouseEventArgs) { var floors = new SelectFloor(); AddChidren(floors); floors.changeFloor = false; floors.CurFloorId = curFloorId; floors.Init(599, 161,Direction.Right); floors.FloorAction += (floorId) => { curFloorId = floorId; floorBtn.Text = Config.Instance.Home.GetFloorNameById(floorId); AddBodyView(floorId); }; } /// /// AddBodyView /// public void AddBodyView(string floorId) { bodyFrameLayout = new FrameLayout() { Y = Application.GetRealHeight(184), Height = Application.GetRealHeight(1737), BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, }; AddChidren(bodyFrameLayout); try { if (UserCenter.HdlRoomLogic.Current.GetAllListRooms().Count <= 1) { return; } var roomScrolView = new VerticalScrolViewLayout { }; bodyFrameLayout.AddChidren(roomScrolView); var roomList = UserCenter.HdlRoomLogic.Current.GetRoomsByFloorId(floorId); if (roomList == null || roomList.Count == 0) { itemView = new FrameLayout() { Height = Application.GetRealHeight(354 + 58) }; roomScrolView.AddChidren(itemView); var roomView = new RoomNoNameMainView(34, 58); itemView.AddChidren(roomView); roomView.Init(); roomView.Icon.MouseUpEventHandler += ShowUnallocatedRoom_MouseUpEvent; roomView.RoomNameButton.MouseUpEventHandler += ShowUnallocatedRoom_MouseUpEvent; roomView.iconFL.MouseUpEventHandler += ShowUnallocatedRoom_MouseUpEvent; } else { for (int i = 0; i < roomList.Count + 1; i++) { int xx = 43 + i % 2 * (20 + 487); int yy = 0; if (i == 0 || i == 1) { if (i % 2 == 0) { itemView = new FrameLayout() { Height = Application.GetRealHeight(354 + 58) }; roomScrolView.AddChidren(itemView); } yy = 58; } else if (i % 2 == 0) { itemView = new FrameLayout() { Height = Application.GetRealHeight(354) }; roomScrolView.AddChidren(itemView); } if (i < roomList.Count) { var room = roomList[i]; var roomView = new RoomMainView(xx, yy); itemView.AddChidren(roomView); roomView.Init(this, room); roomView.SetRoomName(room.Name); roomView.SetRoomIcon(room.BackgroundImageType == 0 ? room.BackgroundImage : System.IO.Path.Combine(Config.Instance.FullPath, room.BackgroundImage)); roomView.ClickBtn.MouseUpEventHandler += (sender, e) => { if (CanClick == false) { return; } CommonPage.Instance.CloseLeftMenu(); UserCenter.HdlRoomLogic.Current.CurrentRoom = room; Config.Instance.Home.CurrentFloorId = room.FloorId; UserPage.Instance.Fresh(); }; } else { var roomView = new RoomNoNameMainView(xx, yy); itemView.AddChidren(roomView); roomView.Init(); roomView.Icon.MouseUpEventHandler += ShowUnallocatedRoom_MouseUpEvent; roomView.RoomNameButton.MouseUpEventHandler += ShowUnallocatedRoom_MouseUpEvent; roomView.iconFL.MouseUpEventHandler += ShowUnallocatedRoom_MouseUpEvent; } } } } catch (Exception ex) { string tt=ex.Message; } } #endregion /// /// 房间管理界面 /// public RoomManagement() { BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; roomManagement = this; } /// /// ShowUnallocatedRoom_MouseUpEvent /// /// /// private void ShowUnallocatedRoom_MouseUpEvent(object sender,MouseEventArgs mouseEventArgs) { if(CanClick==false) { return; } var unalloctedRoom = new UnallocatedRoom(); AddChidren(unalloctedRoom); unalloctedRoom.Show(); } } }