using System; using Shared; using HDL_ON.UI.CSS; using HDL_ON.Stan; using System.Collections.Generic; namespace HDL_ON.UI { /// /// 执行过户操作的界面 /// public class TransferingResidenceForm : EditorCommonForm { #region ■ 变量声明___________________________ /// /// 成员信息 /// private AccountInfoResult accountResult = null; #endregion #region ■ 初始化_____________________________ /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// /// 账号信息 public void ShowForm(AccountInfoResult i_accountResult) { this.ScrollLeftEnabled = false; this.accountResult = i_accountResult; //过户 base.SetTitleText(Language.StringByID(StringId.Transfer)); //初始化中部信息 this.InitMiddleFrame(); } /// /// 初始化中部信息 /// private void InitMiddleFrame() { //清空bodyFrame this.ClearBodyFrame(); //主人的图标 var btnAdminIcon = new ImageView(); btnAdminIcon.Y = Application.GetRealHeight(112); btnAdminIcon.X = Application.GetRealWidth(48); btnAdminIcon.Height = this.GetPictrueRealSize(70); btnAdminIcon.Width = this.GetPictrueRealSize(70); btnAdminIcon.Radius = (uint)this.GetPictrueRealSize(70) / 2; btnAdminIcon.ImagePath = UserInfo.Current.headImagePagePath; bodyFrameLayout.AddChidren(btnAdminIcon); //主人名字 (以中间为基准,左右间距16) var btnAdminName = new NormalViewControl((btnAdminIcon.Right + btnAdminIcon.X) - HdlControlResourse.XXLeft * 2, Application.GetRealHeight(48), false); btnAdminName.X = HdlControlResourse.XXLeft; btnAdminName.Y = btnAdminIcon.Bottom + Application.GetRealHeight(10); btnAdminName.IsBold = true; btnAdminName.IsMoreLines = true; btnAdminName.TextAlignment = TextAlignment.TopCenter; btnAdminName.TextSize = CSS_FontSize.SubheadingFontSize; btnAdminName.Text = string.IsNullOrEmpty(UserInfo.Current.userName) == true ? UserInfo.Current.AccountString : UserInfo.Current.userName; bodyFrameLayout.AddChidren(btnAdminName); //头像 var imageByte = ImageUtlis.Current.ReadFile(this.accountResult.MemberHeadIcon); var btnUserIcon = new ImageView(); btnUserIcon.Y = btnAdminIcon.Y; btnUserIcon.X = bodyFrameLayout.Width - Application.GetRealWidth(48) - this.GetPictrueRealSize(70); btnUserIcon.Height = this.GetPictrueRealSize(70); btnUserIcon.Width = this.GetPictrueRealSize(70); btnUserIcon.Radius = (uint)this.GetPictrueRealSize(70) / 2; if (imageByte != null && imageByte.Length > 0) { btnUserIcon.ImageBytes = imageByte; } else { btnUserIcon.ImagePath = "LoginIcon/2.png"; } bodyFrameLayout.AddChidren(btnUserIcon); //昵称 (以中间为基准,左右间距50) var btnName = new NormalViewControl(btnAdminName.Width, btnAdminName.Height, false); btnName.X = bodyFrameLayout.Width - btnAdminName.X - btnAdminName.Width; btnName.Y = btnAdminName.Y; btnName.IsBold = true; btnName.IsMoreLines = true; btnName.TextAlignment = TextAlignment.TopCenter; btnName.TextSize = CSS_FontSize.SubheadingFontSize; btnName.Text = accountResult.MemberName; bodyFrameLayout.AddChidren(btnName); //开启连接的假想动画效果线程 this.StartConcetionAnimeteThread(btnAdminIcon.Right + Application.GetRealWidth(16)); //终止 var btnCancel = new BottomClickButton(); btnCancel.Y = Application.GetRealHeight(519); btnCancel.TextID = StringId.Terminate; bodyFrameLayout.AddChidren(btnCancel); btnCancel.ButtonClickEvent += (sender, e) => { this.CloseForm(); }; //初始化消息控件 this.InitMsgControl(); } #endregion #region ■ 假想动画___________________________ /// /// 开启连接的假想动画效果线程 /// private void StartConcetionAnimeteThread(int XX) { //生成点号图样 int pointXX = XX; int pointWidth = Application.GetRealWidth(4); int pointSpace = Application.GetRealWidth(9); for (int i = 0; i < 9; i++) { var btnPoint = new NormalViewControl(pointWidth, pointWidth, false); btnPoint.Radius = (uint)pointWidth / 2; btnPoint.BackgroundColor = CSS_Color.PromptingColor1; btnPoint.Y = Application.GetRealHeight(144); btnPoint.X = pointXX; bodyFrameLayout.AddChidren(btnPoint); pointXX = btnPoint.Right + pointSpace; } var listPoint = new List(); //跳动的间距 int jumpSpace = pointWidth + pointSpace; for (int i = 0; i < 9; i++) { //X轴+Index*(图标大小+间距) listPoint.Add(XX + i * jumpSpace); } var btnRound = new IconViewControl(8); btnRound.Radius = (uint)btnRound.IconSize / 2; btnRound.BackgroundColor = CSS_Color.MainColor; btnRound.X = listPoint[0] - (btnRound.IconSize - pointWidth) / 2; btnRound.Y = Application.GetRealHeight(142); bodyFrameLayout.AddChidren(btnRound); HdlThreadLogic.Current.RunThread(() => { int index = 1; while (this.Parent != null) { System.Threading.Thread.Sleep(500); HdlThreadLogic.Current.RunMain(() => { if (btnRound != null) { btnRound.X = listPoint[index]; index++; if (index == listPoint.Count) { index = 0; } } }); } }); } #endregion #region ■ 执行过户___________________________ /// /// 执行过户 /// private void DoTransferResidence() { this.ShowProgressBar(); System.Threading.Thread.Sleep(1500); //过户 bool success = new DAL.Server.HttpServerRequest().TransferResidence(this.accountResult.Account); this.CloseProgressBar(); HdlThreadLogic.Current.RunMain(() => { var form = new TransferResidenceResultPage(); form.AddForm(this.accountResult, success); form.FinishEvent += () => { if (success == false) { //重试 HdlThreadLogic.Current.RunThread(() => { //执行过户 this.DoTransferResidence(); }); } else { for (int i = 0; i < UserInfo.Current.regionList.Count; i++) { //移除当前住宅Id if (UserInfo.Current.regionList[i].id == Entity.DB_ResidenceData.Instance.CurrentRegion.id) { UserInfo.Current.regionList.RemoveAt(i); UserInfo.Current.SaveUserInfo(); break; } } //关闭所有界面 HdlFormLogic.Current.CloseAllOpenForm(); if (UserInfo.Current.regionList.Count == 0) { //没有住宅了,返回登陆界面 HDLCommon.Current.Logout(); } else { Entity.DB_ResidenceData.Instance.CurrentRegion = UserInfo.Current.regionList[0]; Entity.DB_ResidenceData.Instance.SaveResidenceData(); //刷新住宅数据 Common.ApiUtlis.Ins.DownloadData(); //获取主页的那个容器 var userPage = MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1) as UserPage; if (userPage != null) { //刷新个人中心界面 MainPage.CurPageIndex = 1; userPage.ChoosePersonalCenter(); } } } }; }); } #endregion #region ■ 一般方法___________________________ /// /// 初始化消息控件 /// private void InitMsgControl() { string msg = Language.StringByID(StringId.IsTransferingPleaseWaitting); //正在过户给用户,请稍后... var btnMsg = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(20), false); btnMsg.Y = Application.GetRealHeight(288); btnMsg.TextAlignment = TextAlignment.Center; btnMsg.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; btnMsg.Text = msg; bodyFrameLayout.AddChidren(btnMsg); HdlThreadLogic.Current.RunThread(() => { int timeOut = 15; while (timeOut >= 0 && this.Parent != null) { HdlThreadLogic.Current.RunMain(() => { btnMsg.Text = msg + timeOut + "s"; if (timeOut == 0) { btnMsg.Text = msg; } }, ShowErrorMode.NO); System.Threading.Thread.Sleep(1000); timeOut--; } if (timeOut <= 0) { //执行过户操作 this.DoTransferResidence(); } }); } #endregion } }