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 |  431 ++++++++++++++++++++++++++++++-----------------------
 1 files changed, 246 insertions(+), 185 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Room/RoomManagement.cs b/ZigbeeApp/Shared/Phone/Device/Room/RoomManagement.cs
index 3b2ff1a..3fa6ec0 100644
--- a/ZigbeeApp/Shared/Phone/Device/Room/RoomManagement.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Room/RoomManagement.cs
@@ -1,208 +1,269 @@
 锘縰sing 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
     {
-        public  Action action;
+
+        #region 鈼� 鍙橀噺____________________________
+        /// <summary>
+        /// bodyFrameLayout
+        /// </summary>
+        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()
+        {
+            //action?.Invoke();
+            base.RemoveFromParent();
+        }
         /// <summary>
         /// 鎴块棿绠$悊
         /// </summary>
         public void Show()
         {
-            RoomPage();
+            RemoveAll();
+
+            AddTop();
+
+            AddBodyView(Config.Instance.Home.CurrentFloorId);
         }
-        public override void RemoveFromParent()
+
+        #region Add____________________________________
+
+        /// <summary>
+        /// AddTop
+        /// </summary>
+        public void AddTop()
         {
-            //鏇存柊鐣岄潰
-            action();
-            base.RemoveFromParent();
+            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;
         }
+
+        /// <summary>
+        /// 閫夋嫨妤煎眰
+        /// </summary>
+        /// <param name="sender">Sender.</param>
+        /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
+        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);
+            };
+        }
+
+        /// <summary>
+        /// AddBodyView
+        /// </summary>
+        public void AddBodyView(string floorId)
+        {
+            bodyFrameLayout = new FrameLayout()
+            {
+                Y = Application.GetRealHeight(184),
+                Height = Application.GetRealHeight(1737),
+                BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor,
+            };
+            AddChidren(bodyFrameLayout);
+
+            try
+            {
+                if (Common.Room.Lists.Count <= 1)
+                {
+                    return;
+                }
+                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 + 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();
+                                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;
+            }
+        }
+
+        #endregion
+
         /// <summary>
         /// 鎴块棿绠$悊鐣岄潰
         /// </summary>
-        void RoomPage()
+        public RoomManagement()
         {
-            RemoveAll();
-            #region topview
-            var topBGView = new FrameLayout()鈥�            {鈥�                Height = Application.GetRealHeight(CommonPage.Navigation_Height),鈥�                BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor鈥�            };鈥�            AddChidren(topBGView);
-            var topView = new FrameLayout()鈥�            {鈥�                Y = Application.GetRealHeight(CommonPage.NavigationTitle_Y),鈥�                Height = Application.GetRealHeight(CommonPage.Navigation_Height - CommonPage.NavigationTitle_Y),鈥�                BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor,鈥�            };
-            AddChidren(topView);鈥�
-            var title = new Button()
+            BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
+            roomManagement = this;
+        }
+
+        /// <summary>
+        /// ShowUnallocatedRoom_MouseUpEvent
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="mouseEventArgs"></param>
+        private void ShowUnallocatedRoom_MouseUpEvent(object sender,MouseEventArgs mouseEventArgs)
+        {
+            if(CanClick==false)
             {
-                TextAlignment = TextAlignment.Center,
-                TextID=R.MyInternationalizationString.RoomList,
-                TextSize = 20,
-                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
-                Width = Application.GetRealWidth(CommonPage.AppRealWidth - 500),
-                Gravity = Gravity.CenterHorizontal
-            };
-            topView.AddChidren(title);
-
-            var back = new Device.CommonForm.BackButton() { };鈥�            topView.AddChidren(back);
-
-            back.MouseUpEventHandler += (sender, e) =>
-            {
-                this.RemoveFromParent();
-            };
-
-            var addRoomItemBtn = new Device.CommonForm.SelectedStatuButton()
-            {
-                Width = Application.GetMinRealAverage(100),
-                Height = Application.GetMinRealAverage(100),
-                UnSelectedImagePath = "Item/Add.png",
-                SelectedImagePath="Item/AddSelected.png",
-                X = Application.GetRealWidth(1080 - 150),
-                Gravity = Gravity.CenterVertical
-            };
-            topView.AddChidren(addRoomItemBtn);
-
-            //Action action = RoomPage;
-
-            addRoomItemBtn.MouseUpEventHandler += (sender, e) =>
-            {
-                //AddOrUpdateRoom(action);
-                var addRoom = new AddRoom();
-                Shared.Phone.UserView.HomePage.Instance.AddChidren(addRoom);
-                Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
-                addRoom.action = () =>
-                {
-                    Show();
-                };
-                AddRoom.OldBackgroundImagePath = string.Empty;
-                addRoom.Show("");
-            };
-            #endregion
-
-            var middleHomePage = new FrameLayout()
-            {
-                Width = LayoutParams.MatchParent,
-                Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height),
-                Y = topView.Bottom,
-                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
-            };
-            this.AddChidren(middleHomePage);
-
-            var RoomBodyView = new VerticalScrolViewLayout()
-            {
-                Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height),
-                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
-            };
-            middleHomePage.AddChidren(RoomBodyView);
-
-
-            foreach (var roomFilePath in Config.Instance.Home.RoomFilePathList)
-            {
-                var room = Shared.Common.Room.GetRoomByFilePath(roomFilePath);
-                if (room == null)
-                {
-                    continue;
-                }
-
-                var roomFL = new FrameLayout()
-                {
-                    Height = Application.GetRealHeight(570),
-                    Width = Application.GetRealWidth(CommonPage.AppRealWidth - CommonPage.XLeft * 2),
-                    BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
-                    Gravity = Gravity.CenterHorizontal,
-                    Radius = CommonPage.BigFormRadius,
-                };
-                RoomBodyView.AddChidren(roomFL);
-
-                var roomRowView = new RowLayout()
-                {
-                    Y = Application.GetRealHeight(20),
-                    Height = Application.GetMinRealAverage(550),
-                    Width = Application.GetRealWidth(CommonPage.AppRealWidth - CommonPage.XLeft * 2),
-                    BackgroundColor =ZigbeeColor.Current.GXCBackgroundColor,
-                    LineColor= ZigbeeColor.Current.GXCBackgroundColor,
-                    Radius = CommonPage.BigFormRadius,
-                    Gravity = Gravity.CenterHorizontal
-                };
-                roomFL.AddChidren(roomRowView);
-
-                var backGroundBtn = new Button()
-                {
-                    UnSelectedImagePath = room.BackgroundImage,
-                    Radius = CommonPage.BigFormRadius,
-                    Height = Application.GetMinRealAverage(550),
-                    Width = Application.GetRealWidth(CommonPage.AppRealWidth - CommonPage.XLeft * 2),
-                };
-                roomRowView.AddChidren(backGroundBtn);
-
-                var hardBlackBG = new FrameLayout()
-                {
-                    Radius = CommonPage.BigFormRadius,
-                    BackgroundColor = ZigbeeColor.Current.GXCBlack70Color
-                };
-                roomRowView.AddChidren(hardBlackBG);
-
-                var btnRoomName = new Button()
-                {
-                    Width = Application.GetRealWidth(500),
-                    Height=Application.GetRealHeight(200),
-                    Text = room.Name,
-                    TextAlignment = TextAlignment.Center,
-                    TextSize=25,
-                    TextColor=ZigbeeColor.Current.GXCTextWhiteColor,
-                    Gravity=Gravity.Center
-                };
-                roomRowView.AddChidren(btnRoomName);
-
-                var btnEditRoom = new Device.CommonForm.SelectedStatuButton()
-                {
-                    X = roomRowView.Width- Application.GetRealWidth(100+30),
-                    Y=backGroundBtn.Y,
-                    Width = Application.GetMinRealAverage(110),
-                    Height=Application.GetMinRealAverage(110),
-                    UnSelectedImagePath = "Room/More.png",
-                    SelectedImagePath="Room/MoreSelected.png",
-                };
-                roomRowView.AddChidren(btnEditRoom);
-
-                var delBtn = new Shared.Phone.Device.CommonForm.RowLayoutDeleteButton();
-                //绗竴涓槸鎴块棿鍠滅埍锛屼笉鍏佽婊戝姩鍒犻櫎  鍒嗕韩杩囨潵鐨勪篃涓嶅厑璁稿垹闄�
-                if (!room.IsLove || !room.IsSharedRoom){
-                    roomRowView.AddRightView(delBtn);
-                }
-                //鍒犻櫎浣忓畢
-                delBtn.MouseUpEventHandler += (sender, e) =>
-                {
-                    var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.ConfirmDeleteThisRoom), Language.StringByID(R.MyInternationalizationString.Cancel), Language.StringByID(R.MyInternationalizationString.Confrim));
-                    alert.Show();
-                    alert.ResultEventHandler += (send, ee) =>
-                    {
-                        if(ee)
-                        {
-                            Shared.Common.Room.CurrentRoom.Remove(roomFilePath);
-                            Show();
-                        }
-                    };
-                };
-
-                btnEditRoom.MouseUpEventHandler += (sender, e) =>
-                {
-                    //AddOrUpdateRoom(action, roomFilePath);
-                    var addRoom = new AddRoom();
-                    Shared.Phone.UserView.HomePage.Instance.AddChidren(addRoom);
-                    Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
-                    addRoom.action = () =>
-                    {
-                        Show();
-                    };
-                    AddRoom.OldBackgroundImagePath = string.Empty;
-                    addRoom.Show(roomFilePath);
-                };
-
-                roomRowView.MouseUpEventHandler += (sender, e) =>
-                {
-                    //var userRoom = new RoomAddDevice();
-                    //this.AddChidren(userRoom);
-                    //userRoom.Show(roomFilePath);
-                };
-
+                return;
             }
+            var unalloctedRoom = new UnallocatedRoom();
+            AddChidren(unalloctedRoom);
+            unalloctedRoom.Show();
         }
     }
-}
\ No newline at end of file
+}

--
Gitblit v1.8.0