From 8b9ce384b26c414db32f98e94e088f5334869c2d Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期三, 13 十一月 2019 15:36:28 +0800
Subject: [PATCH] 全部合并了代码,安卓和 IOS 都测试通过了

---
 ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs |  137 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 133 insertions(+), 4 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs
index 434417d..da559e5 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs
@@ -68,6 +68,7 @@
             rowHome.Height = Application.GetRealHeight(173);
             rowHome.BackgroundColor = UserCenterColor.Current.White;
             bodyFrameLayout.AddChidren(rowHome);
+            rowHome.frameTable.UseClickStatu = false;
 
             var btnAdreeIcon = rowHome.frameTable.AddLeftIcon(81);
             btnAdreeIcon.UnSelectedImagePath = "Item/FixedPositionSelected.png";
@@ -83,8 +84,36 @@
             btnNowView.Y = Application.GetRealHeight(95);
             btnNowView.TextColor = UserCenterColor.Current.TextGrayColor1;
             rowHome.frameTable.AddChidren(btnNowView, ChidrenBindMode.BindEventOnly);
-            //鍙崇澶�
-            rowHome.frameTable.AddRightArrow();
+            //涓讳汉鎴栬�呯鐞嗗憳鎵嶄細鍑虹幇杩欎釜鑿滃崟
+            if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
+            {
+                //鍙崇澶�
+                rowHome.frameTable.AddRightArrow();
+            }
+            //缁忕含搴�
+            var btnLocation = rowHome.frameTable.AddMostRightView(string.Empty, 500);
+            btnLocation.Text = this.GetLatitudeAndLongitudeText(Common.Config.Instance.Home.Longitude, Common.Config.Instance.Home.Latitude);
+
+            //涓讳汉鎴栬�呯鐞嗗憳鎵嶄細鍑虹幇杩欎釜鑿滃崟
+            if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
+            {
+                rowHome.frameTable.UseClickStatu = true;
+                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);
+                        });
+                    }, Language.StringByID(R.MyInternationalizationString.uSelectAdrress), true, latitude, longitude, 100);
+                };
+            }
 
             if (i_CanDeleteResidence == true)
             {
@@ -375,7 +404,8 @@
         private void CreatOrEditorFloor(NormalViewControl btnFloor, string keys, string floorName)
         {
             //鐢熸垚涓�涓脊绐楃敾闈�
-            var dialogForm = new DialogInputFrameControl(this, DialogFrameMode.OnlyInput);
+            var dialogForm = new DialogInputForm();
+            dialogForm.AddForm(DialogFrameMode.OnlyInput);
             //鍒涘缓妤煎眰
             dialogForm.SetTitleText(Language.StringByID(R.MyInternationalizationString.uCreatFloor));
             if (keys != string.Empty)
@@ -396,7 +426,7 @@
                     return;
                 }
                 //鐢婚潰鍏抽棴
-                dialogForm.CloseDialog();
+                dialogForm.CloseForm();
                 if (floorName != textValue)
                 {
                     //缂栬緫鎴栬�呭垱寤烘ゼ灞傚悕绉�
@@ -623,6 +653,61 @@
 
         #endregion
 
+        #region 鈻� 淇濆瓨浣忓畢鍦板浘鍦板潃___________________
+
+        /// <summary>
+        /// 淇濆瓨浣忓畢鍦板潃
+        /// </summary>
+        /// <param name="btnLocation">鏄剧ず鎺т欢</param>
+        /// <param name="latitude">绾害</param>
+        /// <param name="longitude">缁忓害</param>
+        private async void SaveResidenceAdrress(NormalViewControl btnLocation, double latitude, double longitude)
+        {
+            //寮�鍚繘搴︽潯
+            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)
+            {
+                var result = HdlGatewayLogic.Current.SetGatewaySite(gateway, longitude, latitude);
+                if (result == false)
+                {
+                    //鍏抽棴杩涘害鏉�
+                    this.CloseProgressBar();
+                    return;
+                }
+            }
+
+            //鍏抽棴杩涘害鏉�
+            this.CloseProgressBar();
+            //淇濆瓨缂撳瓨
+            Common.Config.Instance.Home.Longitude = longitude;
+            Common.Config.Instance.Home.Latitude = latitude;
+            Common.Config.Instance.Home.Save();
+            HdlThreadLogic.Current.RunMain(() =>
+            {
+                btnLocation.Text = this.GetLatitudeAndLongitudeText(longitude, latitude);
+            });
+        }
+
+        #endregion
+
         #region 鈻� 涓�鑸柟娉昣__________________________
 
         /// <summary>
@@ -674,6 +759,50 @@
             return true;
         }
 
+        /// <summary>
+        /// 鑾峰彇缁忕含搴︾殑缈昏瘧鍚嶅瓧
+        /// </summary>
+        /// <param name="Longitude">缁忓害</param>
+        /// <param name="Latitude">绾害</param>
+        /// <returns></returns>
+        private string GetLatitudeAndLongitudeText(double Longitude, double Latitude)
+        {
+            string value1 = string.Empty;
+            string value2 = string.Empty;
+            if (Longitude == 0)
+            {
+                //榛樿涓滅粡
+                value1 = "0掳00'E";
+            }
+            else if (Longitude > 0)
+            {
+                //涓滅粡
+                value1 = Math.Round(Longitude, 2).ToString().Replace(".", "掳") + "'E";
+            }
+            else if (Longitude < 0)
+            {
+                //瑗跨粡
+                value1 = Math.Round(-Longitude, 2).ToString().Replace(".", "掳") + "'W";
+            }
+
+            if (Latitude == 0)
+            {
+                //榛樿鍖楃含
+                value2 = "0掳00'N";
+            }
+            else if (Latitude > 0)
+            {
+                //鍖楃含
+                value2 = Math.Round(Latitude, 2).ToString().Replace(".", "掳") + "'N";
+            }
+            else if (Latitude < 0)
+            {
+                //鍗楃含
+                value2 = Math.Round(-Latitude, 2).ToString().Replace(".", "掳") + "'S";
+            }
+            return value1 + " " + value2;
+        }
+
         #endregion
 
         #region 鈻� 缁撴瀯浣揰____________________________

--
Gitblit v1.8.0