From 66a9965c44ecc32a6696abca876ab9d1cd091584 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期五, 28 二月 2020 15:25:13 +0800 Subject: [PATCH] 2020.2.28 --- ZigbeeApp/Shared/Phone/Device/Room/RoomManagement.cs | 149 +++++++++++++++++++++++++++++++++++++------------ 1 files changed, 113 insertions(+), 36 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Room/RoomManagement.cs b/ZigbeeApp/Shared/Phone/Device/Room/RoomManagement.cs index c6f94e4..3fa6ec0 100644 --- a/ZigbeeApp/Shared/Phone/Device/Room/RoomManagement.cs +++ b/ZigbeeApp/Shared/Phone/Device/Room/RoomManagement.cs @@ -17,13 +17,37 @@ private FrameLayout bodyFrameLayout; private Button floorBtn; + /// <summary> + /// 褰撳墠妤煎眰id + /// </summary> + private string curFloorId; public FrameLayout itemView; + + static RoomManagement roomManagement; + public static RoomManagement Instance + { + get + { + if (roomManagement == null) + { + roomManagement = new RoomManagement { }; + } + return roomManagement; + } + } + + /// <summary> + /// 鏄惁鍙互瑙﹀彂鐐瑰嚮浜嬩欢--鏄惁鍙互璺宠浆涓婚〉鎴块棿 + /// </summary> + public bool CanClick = true; #endregion public Action action; + + public override void RemoveFromParent() { @@ -35,6 +59,8 @@ /// </summary> public void Show() { + RemoveAll(); + AddTop(); AddBodyView(Config.Instance.Home.CurrentFloorId); @@ -58,14 +84,14 @@ floorBtn = new Button() { - X = Application.GetRealWidth(750), - Width = Application.GetRealWidth(200), + 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 + TextSize = 14, + IsBold = true }; var selectFloorBtn = new Button() @@ -80,6 +106,7 @@ 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); } @@ -96,9 +123,12 @@ { 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); }; @@ -117,46 +147,24 @@ }; AddChidren(bodyFrameLayout); - var roomScrolView = new VerticalScrolViewLayout { }; - bodyFrameLayout.AddChidren(roomScrolView); - var roomList = Common.Room.CurrentRoom.GetRoomsByFloorId(floorId); - for (int i = 0; i < roomList.Count+1; i++) + try { - int xx = 43 + i % 2 * (20 + 487); - int yy = 0; - if (i == 0 || i == 1) + if (Common.Room.Lists.Count <= 1) { - if (i % 2 == 0) - { - itemView = new FrameLayout() - { - Height = Application.GetRealHeight(354 + 58) - }; - roomScrolView.AddChidren(itemView); - } - yy = 58; + return; } - else if (i % 2 == 0) + var roomScrolView = new VerticalScrolViewLayout { }; + bodyFrameLayout.AddChidren(roomScrolView); + var roomList = Common.Room.CurrentRoom.GetRoomsByFloorId(floorId); + if (roomList == null || roomList.Count == 0) { itemView = new FrameLayout() { - Height = Application.GetRealHeight(354) + Height = Application.GetRealHeight(354 + 58) }; roomScrolView.AddChidren(itemView); - } - if (i< roomList.Count) - { - var room = roomList[i]; - var roomView = new RoomMainView(xx, yy); - itemView.AddChidren(roomView); - roomView.Init(); - roomView.SetRoomName(room.Name); - roomView.SetRoomIcon(room.BackgroundImage); - } - else - { - var roomView = new RoomNoNameMainView(xx, yy); + var roomView = new RoomNoNameMainView(34, 58); itemView.AddChidren(roomView); roomView.Init(); @@ -164,6 +172,70 @@ 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(); + Common.Room.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; } } @@ -172,9 +244,10 @@ /// <summary> /// 鎴块棿绠$悊鐣岄潰 /// </summary> - void RoomPage() + public RoomManagement() { BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; + roomManagement = this; } /// <summary> @@ -184,6 +257,10 @@ /// <param name="mouseEventArgs"></param> private void ShowUnallocatedRoom_MouseUpEvent(object sender,MouseEventArgs mouseEventArgs) { + if(CanClick==false) + { + return; + } var unalloctedRoom = new UnallocatedRoom(); AddChidren(unalloctedRoom); unalloctedRoom.Show(); -- Gitblit v1.8.0