From c44b10e4447e84dbdfa9105edf460ef364a8f2b3 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期一, 30 十一月 2020 19:53:35 +0800 Subject: [PATCH] Merge branch 'master' into WJC --- HDL_ON/UI/UI1-Login/SelectServerDialog.cs | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 161 insertions(+), 0 deletions(-) diff --git a/HDL_ON/UI/UI1-Login/SelectServerDialog.cs b/HDL_ON/UI/UI1-Login/SelectServerDialog.cs new file mode 100644 index 0000000..2b262db --- /dev/null +++ b/HDL_ON/UI/UI1-Login/SelectServerDialog.cs @@ -0,0 +1,161 @@ +锘縰sing System; +using System.Collections.Generic; +using HDL_ON.DAL.Server; +using HDL_ON.UI.CSS; +using Shared; + +namespace HDL_ON.UI +{ + /// <summary> + /// SelectServerDialog + /// 鏈嶅姟鍣ㄩ�夋嫨椤甸潰 + /// </summary> + public class SelectServerDialog : Dialog + { + /// <summary> + /// + /// </summary> + FrameLayout bodyView; + + /// <summary> + /// 閫夋嫨浜嬩欢 + /// </summary> + Action selectAction; + + /// <summary> + /// + /// </summary> + public SelectServerDialog(Action selectAction) + { + bodyView = new FrameLayout(); + this.selectAction = selectAction; + } + + + /// <summary> + /// + /// </summary> + public void LoadPage() + { + bodyView.BackgroundColor = CSS_Color.MainBackgroundColor; + this.AddChidren(bodyView); + //鍔犺浇椤堕儴鑿滃崟鏍� + new TopViewDiv(this, bodyView, Language.StringByID(StringId.PleaseSelectCountryOrRegion)).LoadTopView(); + //鍔犺浇鏈嶅姟鍣ㄥ尯鍩熼�夋嫨 + AddRegionalSelectionView(); + //Show + this.Show(); + } + + + /// <summary> + /// 鍔犺浇鍖哄煙閫夋嫨View + /// </summary> + void AddRegionalSelectionView() + { + + VerticalScrolViewLayout VerticalScrolViewMiddle = new VerticalScrolViewLayout() + { + Y = Application.GetRealHeight(64), + Height = bodyView.Height - Application.GetRealHeight(64), + }; + bodyView.AddChidren(VerticalScrolViewMiddle); + + var waitPage = new Loading(); + waitPage.Start("Please wait..."); + + System.Threading.Tasks.Task.Run(() => + { + try + { + var dataList = new List<GlobalRegionListRes>(); + var requestJson = HttpUtil.GetSignRequestJson(new GetRegionListObj() { regionMark = HttpUtil.RegionMark }); + var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_GlobalRegionList, requestJson, HttpUtil.GlobalRequestHttpsHost); + if (revertObj.Code == StateCode.SUCCESS) + { + Application.RunOnMainThread(() => + { + var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GlobalRegionListRes>>(revertObj.Data.ToString()); + if (responseDataObj != null) + { + dataList = responseDataObj; + if (dataList != null && dataList.Count > 0) + { + foreach (var data in dataList) + { + AddRowView(data, VerticalScrolViewMiddle); + } + } + } + }); + } + else + { + //鎻愮ず閿欒 + IMessageCommon.Current.ShowErrorInfoAlter(revertObj.Code); + } + } + catch + { + + } + finally + { + Application.RunOnMainThread(() => + { + waitPage.Hide(); + }); + } + }); + + } + + /// <summary> + /// 鍔犺浇鍖哄煙閫夋嫨RowView + /// </summary> + /// <param name="mGlobalRegion"></param> + /// <param name="VerticalScrolViewMiddle"></param> + void AddRowView(GlobalRegionListRes mGlobalRegion, VerticalScrolViewLayout VerticalScrolViewMiddle) + { + var rowView = new FrameLayout() + { + Height = Application.GetRealHeight(44), + }; + VerticalScrolViewMiddle.AddChidren(rowView); + + var urlBtn = new Button() + { + X = Application.GetRealWidth(16), + Height = rowView.Height, + Width = Application.GetRealWidth(200), + TextSize = CSS_FontSize.SubheadingFontSize, + TextColor = CSS_Color.FirstLevelTitleColor, + TextAlignment = TextAlignment.CenterLeft + }; + rowView.AddChidren(urlBtn); + + //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(); + //鍏抽棴椤甸潰 + this.Close(); + selectAction?.Invoke(); + }; + rowView.MouseUpEventHandler += eHandler; + urlBtn.MouseUpEventHandler += eHandler; + + urlBtn.Text = mGlobalRegion.regionName; + + if (mGlobalRegion.regionUrl == UserInfo.Current.RequestHttpsHost) + { + urlBtn.TextColor = CSS_Color.MainColor; + } + } + } +} -- Gitblit v1.8.0