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/UserCenter/Residence/ResidenceManagementForm.cs |  176 ++++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 116 insertions(+), 60 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs
index 6ca7502..1fdf829 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs
@@ -16,9 +16,13 @@
         /// </summary>
         private FrameLayout frameTable = null;
         /// <summary>
-        /// 鍒楄〃鎺т欢
+        /// 鍒楄〃鎺т欢(鐧借壊鑳屾櫙)
         /// </summary>
-        private VerticalListControl listView = null;
+        private FrameListControl listView = null;
+        /// <summary>
+        /// 鏁翠釜鐣岄潰鐨勪笂涓嬫粦鍔ㄦ帶浠�
+        /// </summary>
+        private VerticalFrameControl listBackContr = null;
         /// <summary>
         /// 妤煎眰椤哄簭
         /// </summary>
@@ -64,10 +68,16 @@
             //娓呯┖bodyFrame
             this.ClearBodyFrame();
 
+            //鏁翠釜鐣岄潰鐨勪笂涓嬫粦鍔ㄦ帶浠�
+            this.listBackContr = new VerticalFrameControl();
+            listBackContr.Height = bodyFrameLayout.Height;
+            bodyFrameLayout.AddChidren(listBackContr);
+
+            //浣忓畢琛�
             var rowHome = new RowLayoutControl();
             rowHome.Height = Application.GetRealHeight(173);
             rowHome.BackgroundColor = UserCenterColor.Current.White;
-            bodyFrameLayout.AddChidren(rowHome);
+            listBackContr.frameTable.AddChidren(rowHome);
             rowHome.frameTable.UseClickStatu = false;
 
             var btnAdreeIcon = rowHome.frameTable.AddLeftIcon(81);
@@ -77,13 +87,13 @@
             var btnHomeName = rowHome.frameTable.AddLeftCaption(Common.Config.Instance.Home.Name, 700, 60);
             btnHomeName.TextSize = 15;
             btnHomeName.Y = Application.GetRealHeight(35);
-            rowHome.frameTable.AddChidren(btnHomeName, ChidrenBindMode.BindEventOnly);
+            rowHome.frameTable.AddChidren(btnHomeName, ChidrenBindMode.BindEvent);
             //褰撳墠浣忓畢
             var btnNowView = rowHome.frameTable.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uNowResidence), 700, 49);
             btnNowView.TextSize = 12;
             btnNowView.Y = Application.GetRealHeight(95);
             btnNowView.TextColor = UserCenterColor.Current.TextGrayColor1;
-            rowHome.frameTable.AddChidren(btnNowView, ChidrenBindMode.BindEventOnly);
+            rowHome.frameTable.AddChidren(btnNowView, ChidrenBindMode.BindEvent);
             //涓讳汉鎴栬�呯鐞嗗憳鎵嶄細鍑虹幇杩欎釜鑿滃崟
             if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
             {
@@ -92,6 +102,8 @@
             }
             //缁忕含搴�
             var btnLocation = rowHome.frameTable.AddMostRightView(string.Empty, 500);
+            btnLocation.IsMoreLines = true;
+            btnLocation.TextSize = 10;
             btnLocation.Text = Common.Config.Instance.Home.ResidenceAddressName;
 
             //涓讳汉鎴栬�呯鐞嗗憳鎵嶄細鍑虹幇杩欎釜鑿滃崟
@@ -144,8 +156,8 @@
             //鍒濆鍖栨甯�
             this.frameTable = new FrameLayout();
             frameTable.Y = rowHome.Bottom + Application.GetRealHeight(23);
-            frameTable.Height = bodyFrameLayout.Height - rowHome.Bottom - Application.GetRealHeight(23);
-            bodyFrameLayout.AddChidren(frameTable);
+            frameTable.Height = listBackContr.frameTable.Height - rowHome.Bottom - Application.GetRealHeight(23);
+            listBackContr.frameTable.AddChidren(frameTable);
 
             //鏍规嵁鎸囧畾妯″紡,鍒濆鍖栨甯冩帶浠�
             this.InitFrameTableByMode();
@@ -244,7 +256,7 @@
             frameFloor.UseClickStatu = false;
             frameFloor.Height = Application.GetRealHeight(115);
             frameFloor.BackgroundColor = UserCenterColor.Current.White;
-            frameTable.AddChidren(frameFloor);
+            this.frameTable.AddChidren(frameFloor);
 
             //妤煎眰
             var btnFloor = frameFloor.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uFloor), 200, 60);
@@ -253,11 +265,11 @@
             btnFloor.TextSize = 15;
             frameFloor.AddChidren(btnFloor, ChidrenBindMode.NotBind);
 
-            listView = new VerticalListControl(29);
+            listView = new FrameListControl(29);
             listView.BackgroundColor = UserCenterColor.Current.White;
             listView.Y = frameFloor.Bottom;
             listView.Height = frameTable.Height - frameFloor.Bottom;
-            frameTable.AddChidren(listView);
+            this.frameTable.AddChidren(listView);
 
             //鍒濆鍖栨ゼ灞傝
             this.InitFloorRow();
@@ -289,7 +301,7 @@
                     this.AddFloorRow(keys, dicFloor[keys], i != count);
                 }
                 //璋冩暣鎺т欢楂樺害
-                listView.AdjustRealHeight(Application.GetRealHeight(23));
+                this.AdjustContrlTableHeight();
             });
         }
 
@@ -306,6 +318,7 @@
         private void AddFloorRow(string keys, string floorName, bool addLine)
         {
             var frameRow = new RowLayoutControl(listView.rowSpace / 2);
+            frameRow.MainKeys = keys;
             this.listView.AddChidren(frameRow);
             //鍥炬爣
             var btnIcon = frameRow.frameTable.AddLeftIcon(81);
@@ -373,11 +386,6 @@
                                 listDeleteId.Add(listAllRoom[i].Id);
                             }
                         }
-                        //濡傛灉褰撳墠閫夋嫨鐨勬埧闂存槸鍒犻櫎瀵硅薄鐨勮瘽
-                        if (HdlRoomLogic.Current.CurrentRoom.FloorId == keys)
-                        {
-                            HdlRoomLogic.Current.CurrentRoom = HdlRoomLogic.Current.GetLoveRoom();
-                        }
                         //鍒犻櫎鎴块棿
                         foreach (string roomId in listDeleteId)
                         {
@@ -395,9 +403,27 @@
                         }
                         else
                         {
+                            bool canMove = false;
+                            for (int i = 0; i < listView.ChildrenCount; i++)
+                            {
+                                var myRow = listView.GetChildren(i) as RowLayoutControl;
+                                if (myRow != null && myRow.MainKeys == keys)
+                                {
+                                    canMove = true;
+                                    continue;
+                                }
+                                if (canMove == true)
+                                {
+                                    //瀹冧箣鍚庣殑琛岋紝鍏ㄩ儴寰�涓婄Щ
+                                    myRow.Y -= frameRow.Height;
+                                }
+                            }
                             frameRow.RemoveFromParent();
-                            listView.AdjustRealHeight(Application.GetRealHeight(23));
+                            //璋冩暣妗屽竷楂樺害
+                            this.AdjustContrlTableHeight();
                         }
+                        //鍒犻櫎妤煎眰鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂�
+                        UserView.UserPage.Instance.RefreshForm = true;
                     });
                 };
             }
@@ -468,6 +494,8 @@
                         //鏍规嵁鎸囧畾妯″紡,鍒濆鍖栨甯冩帶浠�
                         this.InitFrameTableByMode();
                     }
+                    //鍒涘缓鎴栬�呬慨鏀规ゼ灞傜殑璇�,涓婚〉闇�瑕侀噸鏂板埛鏂�
+                    UserView.UserPage.Instance.RefreshForm = true;
                 }
             });
         }
@@ -495,7 +523,7 @@
             btnRoomList.TextSize = 15;
             frameRoom.AddChidren(btnRoomList, ChidrenBindMode.NotBind);
 
-            listView = new VerticalListControl(29);
+            listView = new FrameListControl(29);
             listView.BackgroundColor = UserCenterColor.Current.White;
             listView.Y = frameRoom.Bottom;
             listView.Height = frameTable.Height - frameRoom.Bottom;
@@ -523,8 +551,8 @@
                 //娣诲姞鎴块棿琛�
                 this.AddRoomRow(listRoom[i], i != listRoom.Count - 1);
             }
-            //璋冩暣鎺т欢鐪熷疄楂樺害
-            listView.AdjustRealHeight(Application.GetRealHeight(23));
+            //璋冩暣妗屽竷楂樺害
+            this.AdjustContrlTableHeight();
         }
 
         #endregion
@@ -539,6 +567,7 @@
         private void AddRoomRow(Common.Room room, bool addLine)
         {
             var frameRow = new RowLayoutControl(listView.rowSpace / 2);
+            frameRow.MainKeys = room.Id;
             listView.AddChidren(frameRow);
             //鍥炬爣
             var btnIcon = frameRow.frameTable.AddLeftIcon(81);
@@ -584,11 +613,6 @@
                 //纭鍒犻櫎鎴块棿?
                 this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uDeleteRoomMsg), () =>
                 {
-                    if (HdlRoomLogic.Current.CurrentRoom.Id == room.Id)
-                    {
-                        //濡傛灉鍒犻櫎鐨勬槸褰撳墠鎴块棿鐨勮瘽
-                        HdlRoomLogic.Current.CurrentRoom = HdlRoomLogic.Current.GetLoveRoom();
-                    }
                     HdlRoomLogic.Current.RemoveRoom(room.Id);
                     //淇濆瓨椤哄簭
                     this.listRoomSort.Remove(room.Id);
@@ -602,9 +626,27 @@
                     }
                     else
                     {
+                        bool canMove = false;
+                        for (int i = 0; i < listView.ChildrenCount; i++)
+                        {
+                            var myRow = listView.GetChildren(i) as RowLayoutControl;
+                            if (myRow != null && myRow.MainKeys == room.Id)
+                            {
+                                canMove = true;
+                                continue;
+                            }
+                            if (canMove == true)
+                            {
+                                //瀹冧箣鍚庣殑琛岋紝鍏ㄩ儴寰�涓婄Щ
+                                myRow.Y -= frameRow.Height;
+                            }
+                        }
                         frameRow.RemoveFromParent();
-                        listView.AdjustRealHeight(Application.GetRealHeight(23));
+                        //璋冩暣妗屽竷楂樺害
+                        this.AdjustContrlTableHeight();
                     }
+                    //鍒犻櫎鎴块棿鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂�
+                    UserView.UserPage.Instance.RefreshForm = true;
                 });
             };
         }
@@ -676,7 +718,7 @@
                 }
             }
 
-            var myHouse = Common.House.GetHouseByFilePath(Common.Config.Instance.HomeFilePathList[index]);
+            var myHouse = HdlResidenceLogic.Current.GetHouseByFilePath(Common.Config.Instance.HomeFilePathList[index]);
             //鍒囨崲浣忓畢
             Common.Config.Instance.HomeId = myHouse.Id;
             Common.Global.CreateHomeDirectory(myHouse.Id);
@@ -684,10 +726,9 @@
 
             //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼
             await UserCenterLogic.InitUserCenterMenmoryAndThread(false);
-            HdlRoomLogic.Current.InitAllRoom();
 
             //鍒犻櫎浣忓畢
-            Common.House.DeleteHouseByHouseId(deleteId);
+            HdlResidenceLogic.Current.DeleteHouseMemmory(deleteId);
 
             Application.RunOnMainThread(() =>
             {
@@ -709,45 +750,49 @@
         /// <param name="addresName">浣嶇疆鍚嶇О</param>
         private async void SaveResidenceAdrress(NormalViewControl btnLocation, double latitude, double longitude, string addresName)
         {
-            //寮�鍚繘搴︽潯
-            this.ShowProgressBar();
-
-            var Pra = new EditorResidencePra();
-            Pra.HomeId = Common.Config.Instance.Home.Id;
-            Pra.Name = Common.Config.Instance.Home.Name;
-            Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
-            Pra.Latitude = latitude;
-            Pra.Longitude = longitude;
-
-            //缂栬緫浣忓畢
-            bool flage = await UserCenterLogic.GetResultStatuByRequestHttps("App/EditHome", true, Pra);
-            if (flage == false)
+            //濡傛灉涓嶆槸铏氭嫙浣忓畢,鎵嶆洿鏂颁簯绔�
+            if (Common.Config.Instance.Home.IsVirtually == false)
             {
-                //鍏抽棴杩涘害鏉�
-                this.CloseProgressBar();
-                return;
-            }
-            //璁剧疆鍏ㄩ儴缃戝叧鐨勪綇瀹呭湴鍧�
-            var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway();
-            foreach (var gateway in listGateway)
-            {
-                ZigBee.Device.ZbGateway realWay = null;
-                if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, gateway) == false)
-                {
-                    //閿欒:缃戝叧瀵硅薄涓㈠け
-                    continue;
-                }
-                var result = HdlGatewayLogic.Current.SetGatewaySite(gateway, longitude, latitude, ShowErrorMode.YES);
-                if (result == false)
+                //寮�鍚繘搴︽潯
+                this.ShowProgressBar();
+
+                var Pra = new EditorResidencePra();
+                Pra.HomeId = Common.Config.Instance.Home.Id;
+                Pra.Name = Common.Config.Instance.Home.Name;
+                Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
+                Pra.Latitude = latitude;
+                Pra.Longitude = longitude;
+
+                //缂栬緫浣忓畢
+                bool flage = await UserCenterLogic.GetResultStatuByRequestHttps("App/EditHome", true, Pra);
+                if (flage == false)
                 {
                     //鍏抽棴杩涘害鏉�
                     this.CloseProgressBar();
                     return;
                 }
+                //璁剧疆鍏ㄩ儴缃戝叧鐨勪綇瀹呭湴鍧�
+                var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway();
+                foreach (var gateway in listGateway)
+                {
+                    ZigBee.Device.ZbGateway realWay = null;
+                    if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, gateway) == false)
+                    {
+                        //閿欒:缃戝叧瀵硅薄涓㈠け
+                        continue;
+                    }
+                    var result = HdlGatewayLogic.Current.SetGatewaySite(gateway, longitude, latitude, ShowErrorMode.YES);
+                    if (result == false)
+                    {
+                        //鍏抽棴杩涘害鏉�
+                        this.CloseProgressBar();
+                        return;
+                    }
+                }
+                //鍏抽棴杩涘害鏉�
+                this.CloseProgressBar();
             }
 
-            //鍏抽棴杩涘害鏉�
-            this.CloseProgressBar();
             //淇濆瓨缂撳瓨
             Common.Config.Instance.Home.Longitude = longitude;
             Common.Config.Instance.Home.Latitude = latitude;
@@ -812,6 +857,17 @@
             return true;
         }
 
+        /// <summary>
+        /// 璋冩暣鎺т欢妗屽竷楂樺害
+        /// </summary>
+        private void AdjustContrlTableHeight()
+        {
+            //璋冩暣妗屽竷楂樺害
+            listView.AdjustRealHeight(Application.GetRealHeight(23));
+            this.frameTable.Height = listView.Bottom;
+            this.listBackContr.AdjustTableHeight();
+        }
+
         #endregion
 
         #region 鈻� 缁撴瀯浣揰____________________________

--
Gitblit v1.8.0