黄学彪
2019-11-13 8b9ce384b26c414db32f98e94e088f5334869c2d
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 ■ 结构体_____________________________