xm
2021-12-01 6d73bf6e816570291865674bef8bce8972e4de3f
HDL_ON/UI/UI1-Login/SelectServerDialog.cs
@@ -25,23 +25,26 @@
        /// <summary>
        /// 
        /// </summary>
        public SelectServerDialog()
        public SelectServerDialog(Action selectAction)
        {
            bodyView = new FrameLayout();
            this.selectAction = selectAction;
        }
      /// <summary>
      ///
      /// </summary>
        /// <summary>
        ///
        /// </summary>
        public void LoadPage()
        {
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
            bodyView.BackgroundColor = CSS_Color.MainBackgroundColor;
            this.AddChidren(bodyView);
            new TopViewDiv(this, bodyView, Language.StringByID(StringId.SelectCountryOrRegion)).LoadTopView();
            //加载顶部菜单栏
            new TopViewDiv(this, bodyView, Language.StringByID(StringId.PleaseSelectCountryOrRegion)).LoadTopView();
            //加载服务器区域选择
            AddRegionalSelectionView();
            //Show
            this.Show();
        }
@@ -58,24 +61,12 @@
            };
            bodyView.AddChidren(VerticalScrolViewMiddle);
            //var TipView = new Button()
            //{
            //    Y = bodyView.Height - Application.GetRealHeight(60),
            //    Width = LayoutParams.MatchParent,
            //    Height = Application.GetRealHeight(60),
            //    BackgroundColor = 0xFFFFFFE0,
            //    TextSize = 11,
            //    //Text = "请选择注册的区域",
            //    //TextID = R.MyInternationalizationString.SelectRegisteredArea,
            //    TextColor = 0xFF1F1F1F,
            //    IsMoreLines = true
            //};
            //bodyView.AddChidren(TipView);
            var waitPage = new Loading();
            waitPage.Start("Please wait...");
            bodyView.AddChidren(waitPage);
            waitPage.Start(Language.StringByID(StringId.PleaseWait));
            System.Threading.Tasks.Task.Run(() => {
            System.Threading.Tasks.Task.Run(() =>
            {
                try
                {
                    var dataList = new List<GlobalRegionListRes>();
@@ -83,7 +74,8 @@
                    var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_GlobalRegionList, requestJson, HttpUtil.GlobalRequestHttpsHost);
                    if (revertObj.Code == StateCode.SUCCESS)
                    {
                        Application.RunOnMainThread(() => {
                        Application.RunOnMainThread(() =>
                        {
                            var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GlobalRegionListRes>>(revertObj.Data.ToString());
                            if (responseDataObj != null)
                            {
@@ -106,12 +98,17 @@
                }
                catch
                {
                }
                finally
                {
                    Application.RunOnMainThread(() => {
                        waitPage.Hide();
                    Application.RunOnMainThread(() =>
                    {
                        if (waitPage != null)
                        {
                            waitPage.RemoveFromParent();
                            waitPage = null;
                        }
                    });
                }
            });
@@ -125,29 +122,32 @@
        /// <param name="VerticalScrolViewMiddle"></param>
        void AddRowView(GlobalRegionListRes mGlobalRegion, VerticalScrolViewLayout VerticalScrolViewMiddle)
        {
            var rowView = new RowLayout()
            var rowView = new FrameLayout()
            {
                Height = Application.GetRealHeight(44),
            };
            VerticalScrolViewMiddle.AddChidren(rowView);
            var urlBtn = new Button() {
            var urlBtn = new Button()
            {
                X = Application.GetRealWidth(16),
                Height = rowView.Height,
                Width = Application.GetRealWidth(200),
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextColor = CSS_Color.FirstLevelTitleColor,
                Gravity = Gravity.CenterLeft
                TextAlignment = TextAlignment.CenterLeft
            };
            rowView.AddChidren(urlBtn);
            var lineView = new LineView();
            rowView.AddChidren(lineView);
            lineView.Y = rowView.Height - lineView.Height;
            //var lineView = new LineView();
            //rowView.AddChidren(lineView);
            //lineView.Y = rowView.Height - lineView.Height;
            EventHandler<MouseEventArgs> eHandler = (sender, e) => {
                UserInfo.Current.RequestHttpsHost = mGlobalRegion.regionUrl;
                UserInfo.Current.GlobalRegion = mGlobalRegion;
                UserInfo.Current.SaveUserInfo();
            EventHandler<MouseEventArgs> eHandler = (sender, e) =>
            {
                OnAppConfig.Instance.RequestHttpsHost = mGlobalRegion.regionUrl;
                OnAppConfig.Instance.GlobalRegion = mGlobalRegion;
                OnAppConfig.Instance.SaveConfig();
                //关闭页面
                this.Close();
                selectAction?.Invoke();
@@ -155,8 +155,9 @@
            rowView.MouseUpEventHandler += eHandler;
            urlBtn.MouseUpEventHandler += eHandler;
            urlBtn.Text = mGlobalRegion.regionName;
            if (mGlobalRegion.regionUrl == UserInfo.Current.RequestHttpsHost)
            if (mGlobalRegion.regionUrl == OnAppConfig.Instance.RequestHttpsHost)
            {
                urlBtn.TextColor = CSS_Color.MainColor;
            }