From c7df85937f73fb347ee0b19e9c052d2d00a6df6c Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期五, 18 九月 2020 13:58:19 +0800
Subject: [PATCH] 新版本

---
 ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs |  131 ++++++++++++++++++++++++++++++++++---------
 1 files changed, 102 insertions(+), 29 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs
index dee8d57..76cb9dc 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs
@@ -44,8 +44,12 @@
             //涓讳汉鎴栬�呯鐞嗗憳鎵嶄細鍑虹幇杩欎釜鑿滃崟
             if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
             {
-                //鍒濆鍖栧彸涓婅鑿滃崟
-                this.InitTopRightMenu();
+                //鏌ョ湅妯℃澘鏃�,涓嶅厑璁哥紪杈�
+                if (Common.Config.Instance.Home.IsShowTemplate == false)
+                {
+                    //鍒濆鍖栧彸涓婅鑿滃崟
+                    this.InitTopRightMenu();
+                }
             }
             //鍒濆鍖栦腑閮ㄤ俊鎭�
             this.InitMiddleFrame(i_CanDeleteResidence);
@@ -102,27 +106,19 @@
             if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
             {
                 rowHome.frameTable.UseClickStatu = true;
+                //鏌ョ湅妯℃澘鏃�,涓嶅厑璁哥紪杈�
+                if (Common.Config.Instance.Home.IsShowTemplate == true)
+                {
+                    rowHome.frameTable.CanClick = false;
+                }
                 rowHome.frameTable.ButtonClickEvent += (sender, e) =>
                 {
-                    //榛樿鍊� 23.134421,113.267189
-                    double latitude = Common.Config.Instance.Home.Latitude;
-                    double longitude = Common.Config.Instance.Home.Longitude;
-                    //鍦板浘
-                    GDMapKit.Show((mLatitude, mLongitude, mRadius, name) =>
-                    {
-                        HdlThreadLogic.Current.RunThread(() =>
-                        {
-                            //淇濆瓨浣忓畢鍦板潃
-                            this.SaveResidenceAdrress(btnLocation, mLatitude, mLongitude, name);
-                        });
-                    }, 
-                    Language.StringByID(R.MyInternationalizationString.uSelectAdrress),
-                    Language.StringByID(R.MyInternationalizationString.uSave),
-                    true, latitude, longitude, 100);
+                    //妫�娴嬫潈闄�,鐒跺悗鏄剧ず鍦板浘
+                    this.CheckAuthorityAndShowMap(btnLocation);
                 };
             }
 
-            if (i_CanDeleteResidence == true)
+            if (i_CanDeleteResidence == true && Common.Config.Instance.Home.IsShowTemplate == false)
             {
                 //鍒犻櫎
                 var btnDelete = new NormalViewControl(Application.GetRealWidth(184), rowHome.Height, false);
@@ -326,6 +322,11 @@
 
             if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
             {
+                //鏌ョ湅妯℃澘鏃�,涓嶅厑璁哥紪杈�
+                if (Common.Config.Instance.Home.IsShowTemplate == true)
+                {
+                    return;
+                }
                 //鏇存敼
                 var btnChanged = frameRow.AddEditorControl();
                 btnChanged.TextID = R.MyInternationalizationString.uChanged1;
@@ -352,11 +353,11 @@
                         Common.Config.Instance.Home.FloorDics.Remove(keys);
                         if (Common.Config.Instance.Home.CurrentFloorId == keys)
                         {
-                            //濡傛灉鍒犻櫎鐨勬槸褰撳墠妤煎眰鐨勮瘽
                             Common.Config.Instance.Home.CurrentFloorId = string.Empty;
-                            foreach (string floorId in Common.Config.Instance.Home.FloorDics.Keys)
+                            var dicFloor = HdlRoomLogic.Current.GetFloorSortList();
+                            foreach (var floorId in dicFloor.Keys)
                             {
-                                //鎶婄涓�涓ゼ灞侷D缁欏畠
+                                //鎶婄涓�涓ゼ灞傝祴鍊肩粰褰撳墠妤煎眰
                                 Common.Config.Instance.Home.CurrentFloorId = floorId;
                                 break;
                             }
@@ -406,7 +407,7 @@
                             this.AdjustContrlTableHeight();
                         }
                         //鍒犻櫎妤煎眰鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂�
-                        UserView.UserPage.Instance.RefreshForm = true;
+                        UserView.UserPage.Instance.RefreshAllForm = true;
                     });
                 };
             }
@@ -460,14 +461,15 @@
                     {
                         keys = Guid.NewGuid().ToString();
                     }
+                    bool hadFloor = Common.Config.Instance.Home.CurrentFloorId != string.Empty;
                     Common.Config.Instance.Home.FloorDics[keys] = textValue;
                     Common.Config.Instance.Home.Save();
-                    if (Common.Config.Instance.Home.CurrentFloorId == string.Empty)
+                    if (hadFloor == false)
                     {
-                        Common.Config.Instance.Home.CurrentFloorId = keys;
                         //鍒涘缓绗竴涓柊鐨勬ゼ灞傜殑璇�,闇�瑕佸幓鍒锋柊涓婚〉宸﹁竟鐨勬埧闂村垪琛�
                         HdlRoomLogic.Current.RefreshRoomListView();
                     }
+
                     if (btnFloor != null)
                     {
                         btnFloor.Text = textValue;
@@ -478,7 +480,7 @@
                         this.InitFrameTableByMode();
                     }
                     //鍒涘缓鎴栬�呬慨鏀规ゼ灞傜殑璇�,涓婚〉闇�瑕侀噸鏂板埛鏂�
-                    UserView.UserPage.Instance.RefreshForm = true;
+                    UserView.UserPage.Instance.RefreshAllForm = true;
                 }
             });
         }
@@ -581,7 +583,12 @@
                     btnName.Text = roomName;
                 };
             };
-
+            //鏌ョ湅妯℃澘鏃�,涓嶅厑璁哥紪杈�
+            if (Common.Config.Instance.Home.IsShowTemplate == true)
+            {
+                btnEditor.Text = Language.StringByID(R.MyInternationalizationString.uSearch1);
+                return;
+            }
             //鍒犻櫎
             var btnDelete = frameRow.AddDeleteControl();
             btnDelete.ButtonClickEvent += (sender, e) =>
@@ -619,7 +626,7 @@
                         this.AdjustContrlTableHeight();
                     }
                     //鍒犻櫎鎴块棿鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂�
-                    UserView.UserPage.Instance.RefreshForm = true;
+                    UserView.UserPage.Instance.RefreshAllForm = true;
                 });
             };
         }
@@ -694,16 +701,22 @@
             var myHouse = HdlResidenceLogic.Current.GetHouseByFilePath(Common.Config.Instance.HomeFilePathList[index]);
             //鍒囨崲浣忓畢
             Common.Config.Instance.HomeId = myHouse.Id;
+            Common.Config.Instance.Home = myHouse;
             Common.Global.CreateHomeDirectory(myHouse.Id);
             Common.Config.Instance.Save();
 
             //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼
-            UserCenterLogic.InitUserCenterMenmoryAndThread(false);
+            bool result2 = UserCenterLogic.InitUserCenterMenmoryAndThread(false);
+            if (result2 == false)
+            {
+                //寮�鍚簡璋冭瘯鍔熻兘
+                return;
+            }
 
             //鍒犻櫎浣忓畢
             HdlResidenceLogic.Current.DeleteHouseMemmory(deleteId);
 
-            Application.RunOnMainThread(() =>
+            HdlThreadLogic.Current.RunMain(() =>
             {
                 //鍏抽棴鐣岄潰
                 this.CloseForm();
@@ -712,6 +725,66 @@
 
         #endregion
 
+        #region 鈻� 鏄剧ず鍦板浘___________________________
+
+        /// <summary>
+        /// 妫�娴嬫潈闄�,鐒跺悗鏄剧ず鍦板浘
+        /// </summary>
+        /// <param name="btnLocation">鍦板潃鏄剧ず鎺т欢</param>
+        private void CheckAuthorityAndShowMap(NormalViewControl btnLocation)
+        {
+#if Android
+            //鏄剧ず鍦板浘
+            this.ShowMap(btnLocation);
+            ////鐢宠瀹氫綅鏉冮檺
+            //((BaseActivity)Application.Activity).SetGPSLocationPermission((result1) =>
+            //{
+            //    if (result1 == false) { return; }
+            //    //鐢宠璇绘潈闄�
+            //    ((BaseActivity)Application.Activity).ReadWriteContact((result2) =>
+            //    {
+            //        if (result2 == false) { return; }
+            //        //鐢宠璇诲彇鎵嬫満鍙锋潈闄�
+            //        ((BaseActivity)Application.Activity).SetPermission((result3) =>
+            //        {
+            //            if (result3 == false) { return; }
+            //            //鏄剧ず鍦板浘
+            //            this.ShowMap(btnLocation);
+            //        }, "android.permission.READ_PHONE_STATE");
+            //    });
+            //});
+#endif
+#if iOS
+            //鏄剧ず鍦板浘
+            this.ShowMap(btnLocation);
+#endif
+        }
+
+        /// <summary>
+        /// 鏄剧ず鍦板浘
+        /// </summary>
+        /// <param name="btnLocation">鍦板潃鏄剧ず鎺т欢</param>
+        private void ShowMap(NormalViewControl btnLocation)
+        {
+            //榛樿鍊� 23.134421,113.267189
+            double latitude = Common.Config.Instance.Home.Latitude;
+            double longitude = Common.Config.Instance.Home.Longitude;
+            //鍦板浘
+            GDMapKit.Show((mLatitude, mLongitude, mRadius, name) =>
+            {
+                HdlThreadLogic.Current.RunThread(() =>
+                {
+                    //淇濆瓨浣忓畢鍦板潃
+                    this.SaveResidenceAdrress(btnLocation, mLatitude, mLongitude, name);
+                });
+            },
+            Language.StringByID(R.MyInternationalizationString.uSelectAdrress),
+            Language.StringByID(R.MyInternationalizationString.uSave),
+            true, latitude, longitude, 100);
+        }
+
+        #endregion
+
         #region 鈻� 淇濆瓨浣忓畢鍦板浘鍦板潃___________________
 
         /// <summary>

--
Gitblit v1.8.0