wxr
2020-04-21 f718d23a262a5a8e1241fdeaeb4153399f95e79d
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
using System;
using Shared;
 
namespace HDL_ON.UI
{
    public partial class PersonalDataPage
    {
        /// <summary>
        /// 加载事件列表
        /// </summary>
        void LoadEventList()
        {
            LoadEvent_ChangeHeadImageView();
            LoadEvent_Logout();
            LoadEvent_EditUserName();
            LoadEvent_SkipInterpretationSettings();
        }
 
        /// <summary>
        /// 加载选择头像选项view
        /// </summary>
        void LoadEvent_ChangeHeadImageView()
        {
            userHeadImageView.MouseUpEventHandler = (sender, e) => {
                LoadPictureOptionView();
            };
        }
 
        /// <summary>
        /// 退出账号登录事件
        /// </summary>
        void LoadEvent_Logout()
        {
            btnLogout.MouseUpEventHandler += (sender, e) => {
                MainPage.LoginUser.lastTime = DateTime.MinValue;
                MainPage.LoginUser.SaveUserInfo();
                MainPage.GoLoginPage(MainPage.LoginUser.accountString);
            };
        }
 
 
        /// <summary>
        /// 加载背景图选择区域事件列表
        /// </summary>
        void LoadEvent_PictureOptionViewEventList()
        {
            pictureOptionView.MouseUpEventHandler = (sender, e) =>
            {
                pictureOptionView.RemoveFromParent();
            };
 
            btnCancel.MouseUpEventHandler = (sender, e) =>
            {
                pictureOptionView.RemoveFromParent();
            };
 
            btnTakePicture.MouseUpEventHandler = (sender, e) =>
            {
                var pid = Guid.NewGuid();
                CropImage.TakePicture((Action<string>)((imagePath) =>
                {
                    if (imagePath != null)
                    {
                        MainPage.LoginUser.headImagePagePath = imagePath.ToString();
                        userHeadImageView.ImagePath = imagePath.ToString();
                        updataHeadImage();
                        new System.Threading.Thread(() =>
                        {
                            new DAL.Server.HttpServerRequest().UpdataUserHeadImage(imagePath);
                        })
                        { IsBackground = true }.Start();
                        MainPage.LoginUser.SaveUserInfo();
                        MainPage.Log("SelectPicture 裁剪图片返回路径: " + imagePath);
                    }
                }), pid.ToString(), 1, 1);
                pictureOptionView.RemoveFromParent();
            };
 
            btnAlbum.MouseUpEventHandler = (sender, e) =>
            {
                var pid = Guid.NewGuid();
                CropImage.SelectPicture((imagePath) =>
                {
                    if (imagePath != null)
                    {
                        MainPage.LoginUser.headImagePagePath = imagePath.ToString();
                        userHeadImageView.ImagePath = imagePath.ToString();
                        updataHeadImage();
 
                        new System.Threading.Thread(() =>
                        {
                            new DAL.Server.HttpServerRequest().UpdataUserHeadImage(imagePath);
                        })
                        { IsBackground = true }.Start(); MainPage.LoginUser.SaveUserInfo();
                        MainPage.Log("SelectPicture 裁剪图片返回路径: " + imagePath);
                    }
                }, pid.ToString(), 1, 1);
                pictureOptionView.RemoveFromParent();
            };
        }
 
        /// <summary>
        /// 加载修改用户名称事件
        /// </summary>
        void LoadEvent_EditUserName()
        {
            EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
            {
                Action<string> callBack = (str) =>
                {
                    if (string.IsNullOrEmpty(str))
                    {
                        new Tip()
                        {
                            CloseTime = 3,
                            Text = Language.StringByID(StringId.UesrNameCannotBeEmpty),
                            Direction = AMPopTipDirection.None,
                        }.Show(bodyView);
                        return;
                    }
                    var waitPage = new Loading();
                    waitPage.Start(Language.StringByID(StringId.PleaseWait));
                    new System.Threading.Thread(() =>
                    {
                        try
                        {
                            var responsePack = new DAL.Server.HttpServerRequest().EditUserName(str);
                            if (responsePack.StateCode.ToUpper() == "SUCCESS")
                            {
                                MainPage.LoginUser.userName = str;
                                MainPage.LoginUser.SaveUserInfo();
                                Application.RunOnMainThread(() =>
                                {
                                    btnUserName.Text = str;
                                    updataUserName();
                                });
                            }
                            else
                            {
                                var tipStr = "Server erorr";
                                switch (responsePack.StateCode)
                                {
                                    case "NoLogin":
                                        tipStr = Language.StringByID(StringId.InvalidLoginCertificate);
                                        break;
                                    case "AccountNoExists":
                                        tipStr = "";
                                        break;
                                }
                                Application.RunOnMainThread(() =>
                                {
                                //提示原因
                                var tip = new Tip()
                                    {
                                        Text = tipStr,
                                        CloseTime = 3,
                                        Direction = AMPopTipDirection.None
                                    };
                                    tip.Show(bodyView);
                                });
                            }
                        }catch (Exception ex)
                        {
                            MainPage.Log($"update user name error : {ex.Message}");
                        }
                        finally
                        {
                            Application.RunOnMainThread(() => {
                                waitPage.Hide();
                            });
                        }
                    })
                    { IsBackground = true }.Start();
                };
                new PublicAssmebly().LoadDialog_EditParater(StringId.UesrName, MainPage.LoginUser.userName, callBack);
            };
            btnUserName.MouseUpEventHandler = eventHandler;
            btnEditUserNameIcon.MouseUpEventHandler = eventHandler;
        }
 
 
        #region 解锁设置区域
        void LoadEvent_SkipInterpretationSettings()
        {
            EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
            {
                var page = new AppUnlockSettingsPage();
                MainPage.BasePageView.AddChidren(page);
                page.LoadPage();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
 
            btnInterpretationSettingsRight.MouseUpEventHandler = eventHandler;
            btnInterpretationSettingsTitle.MouseUpEventHandler = eventHandler;
            btnInterpretationSettingsTip.MouseUpEventHandler = eventHandler;
        }
 
        #endregion
 
    }
}