tzy
2021-05-30 1c63243a7bcc330b7293cc8d5ec81c4c52018196
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
using System;
using Shared;
using HDL_ON.UI.CSS;
using HDL_ON.Stan;
using System.Collections.Generic;
 
namespace HDL_ON.UI
{
    /// <summary>
    /// 执行过户操作的界面
    /// </summary>
    public class TransferingResidenceForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 成员信息
        /// </summary>
        private AccountInfoResult accountResult = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_accountResult">账号信息</param>
        public void ShowForm(AccountInfoResult i_accountResult)
        {
            this.ScrollLeftEnabled = false;
 
            this.accountResult = i_accountResult;
 
            //过户
            base.SetTitleText(Language.StringByID(StringId.Transfer));
 
 
            //初始化中部信息
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        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 ■ 假想动画___________________________
 
        /// <summary>
        /// 开启连接的假想动画效果线程
        /// </summary>
        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>();
            //跳动的间距
            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 ■ 执行过户___________________________
 
        /// <summary>
        /// 执行过户
        /// </summary>
        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 ■ 一般方法___________________________
 
        /// <summary>
        /// 初始化消息控件
        /// </summary>
        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
    }
}