From c7698e163e43cea9e7f8ee45f8e3f91c9265cca4 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 04 十一月 2019 19:11:41 +0800
Subject: [PATCH] 合并了全部的代码

---
 ZigbeeApp/Shared/Phone/UserCenter/Safety/GarrisonAreaExistSensorForm.cs |  109 ++++++++++++++++--------------------------------------
 1 files changed, 32 insertions(+), 77 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Safety/SensorDeviceSettionListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Safety/GarrisonAreaExistSensorForm.cs
similarity index 77%
rename from ZigbeeApp/Shared/Phone/UserCenter/Safety/SensorDeviceSettionListForm.cs
rename to ZigbeeApp/Shared/Phone/UserCenter/Safety/GarrisonAreaExistSensorForm.cs
index 1df2003..1018198 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Safety/SensorDeviceSettionListForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Safety/GarrisonAreaExistSensorForm.cs
@@ -8,7 +8,7 @@
     /// <summary>
     /// 宸茬粡璁剧疆浜嗙殑浼犳劅鍣ㄧ殑涓�瑙堢敾闈�
     /// </summary>
-    public class SensorDeviceSettionListForm : EditorCommonForm
+    public class GarrisonAreaExistSensorForm : EditorCommonForm
     {
         #region 鈻� 鍙橀噺澹版槑___________________________
 
@@ -48,12 +48,6 @@
                 this.AddNewSensorDevice();
             };
 
-            listView = new VerticalListControl(29);
-            listView.Y = Application.GetRealHeight(-6);
-            listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6);
-            listView.BackgroundColor = UserCenterColor.Current.White;
-            bodyFrameLayout.AddChidren(listView);
-
             //鍒濆鍖栦紶鎰熷櫒鍒楄〃淇℃伅
             this.InitSensorDevicesListInfo();
         }
@@ -63,35 +57,34 @@
         /// </summary>
         private void InitSensorDevicesListInfo()
         {
-            this.listView.RemoveAll();
-            listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6);
+            //娓呯┖bodyFrameLayout
+            this.ClearBodyFrame();
 
             //鑾峰彇鎸囧畾闃插尯鍏ㄩ儴鐨勪紶鎰熷櫒璁惧鐨勪俊鎭�
             var listInfo = HdlSafeguardLogic.Current.GetSensorDevicesInfoByZoonID(this.zoonID);
             if (listInfo.Count == 0)
             {
+                //杩樻病鏈夎缃紶鎰熷櫒鍝�
+                this.ShowNotDataImage(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uDoNotHadSettionSensorMsg));
+                this.listView = null;
                 return;
             }
-            HdlThreadLogic.Current.RunThread(() =>
+
+            listView = new VerticalListControl(29);
+            listView.Y = Application.GetRealHeight(-6);
+            listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6);
+            listView.BackgroundColor = UserCenterColor.Current.White;
+            bodyFrameLayout.AddChidren(listView);
+
+            HdlThreadLogic.Current.RunMainInThread(() =>
             {
-                Application.RunOnMainThread(() =>
+                int count = listInfo.Count - 1;
+                for (int i = 0; i < listInfo.Count; i++)
                 {
-                    int count = listInfo.Count - 1;
-                    for (int i = 0; i < listInfo.Count; i++)
-                    {
-                        if (this.Parent != null)
-                        {
-                            this.AddRowLayout(listInfo[i], i != count);
-                        }
-                    }
-                    if (listView.ChildrenCount == 0)
-                    {
-                        //娌℃湁鍚堟硶鐨勪紶鎰熷櫒
-                        return;
-                    }
-                    //璋冩暣鍒楄〃鎺т欢鐨勯珮搴�
-                    this.AdjustListviewHeight();
-                });
+                    this.AddRowLayout(listInfo[i], i != count);
+                }
+                //璋冩暣鍒楄〃鎺т欢鐨勯珮搴�
+                this.listView.AdjustRealHeight(Application.GetRealHeight(23));
             });
         }
 
@@ -177,24 +170,21 @@
         /// <param name="device"></param>
         private async void DeleteRow(DeviceRoomControl rowLayout, CommonDevice device)
         {
-            //寮�鍚繘搴︽潯
-            this.ShowProgressBar();
-
             bool result = await HdlSafeguardLogic.Current.DeleteSensorDevice(this.zoonID, new List<CommonDevice>() { device });
 
-            //鍏抽棴杩涘害鏉�
-            this.CloseProgressBar();
             if (result == false)
             {
                 return;
             }
-            Application.RunOnMainThread(() =>
+            //浠庣敾闈腑绉婚櫎
+            rowLayout?.RemoveFromParent();
+            //璋冩暣鍒楄〃鎺т欢鐨勯珮搴�
+            this.listView.AdjustRealHeight(Application.GetRealHeight(23));
+            if (this.listView.ChildrenCount == 0)
             {
-                //浠庣敾闈腑绉婚櫎
-                rowLayout?.RemoveFromParent();
-                //璋冭妭鍒楄〃鎺т欢鐨勯珮搴�
-                this.AdjustListviewHeight();
-            });
+                //鍒濆鍖栦紶鎰熷櫒鍒楄〃淇℃伅
+                this.InitSensorDevicesListInfo();
+            }
         }
 
         #endregion
@@ -244,27 +234,16 @@
             {
                 if (listDevice.Count == 0)
                 {
-                    Application.RunOnMainThread(() =>
-                    {
-                        //鍏抽棴鐣岄潰
-                        form.CloseForm();
-                    });
+                    //鍏抽棴鐣岄潰
+                    form.CloseForm();
                     return;
                 }
-                //寮�鍚繘搴︽潯
-                this.ShowProgressBar();
                 //娣诲姞璁惧鍒板畨闃�
                 bool success = await HdlSafeguardLogic.Current.AddSensorDevice(this.zoonID, listDevice);
-                //鍏抽棴杩涘害鏉�
-                this.CloseProgressBar();
-
                 if (success == true)
                 {
-                    Application.RunOnMainThread(() =>
-                    {
-                        //鍏抽棴鐣岄潰
-                        form.CloseForm();
-                    });
+                    //鍏抽棴鐣岄潰
+                    form.CloseForm();
                     //鍒锋柊鍒楄〃
                     this.InitSensorDevicesListInfo();
                 }
@@ -294,30 +273,6 @@
                 listNew.Add(device);
             }
             return listNew;
-        }
-
-        #endregion
-
-        #region 鈻� 涓�鑸柟娉昣__________________________
-
-        /// <summary>
-        /// 璋冭妭鍒楄〃鎺т欢鐨勯珮搴�
-        /// </summary>
-        private void AdjustListviewHeight()
-        {
-            if (listView.ChildrenCount == 0)
-            {
-                //鐩存帴鎷夋弧灞忓箷
-                listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6);
-                return;
-            }
-            var realHeight = listView.ChildrenCount * listView.GetChildren(listView.ChildrenCount - 1).Height;
-            realHeight += listView.rowSpace;
-            if (realHeight < listView.Height)
-            {
-                //缂╁皬鎺т欢楂樺害
-                listView.Height = realHeight;
-            }
         }
 
         #endregion

--
Gitblit v1.8.0