using System; using Shared; namespace HDL_ON.UI { public partial class PersonalDataPage { /// /// 加载事件列表 /// void LoadEventList() { LoadEvent_ChangeHeadImageView(); LoadEvent_Logout(); LoadEvent_EditUserName(); LoadEvent_SkipInterpretationSettings(); } /// /// 加载选择头像选项view /// void LoadEvent_ChangeHeadImageView() { userHeadImageView.MouseUpEventHandler = (sender, e) => { LoadPictureOptionView(); }; } /// /// 退出账号登录事件 /// void LoadEvent_Logout() { btnLogout.MouseUpEventHandler += (sender, e) => { MainPage.LoginUser.lastTime = DateTime.MinValue; MainPage.LoginUser.SaveUserInfo(); MainPage.GoLoginPage(MainPage.LoginUser.accountString); }; } /// /// 加载背景图选择区域事件列表 /// 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)((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(); }; } /// /// 加载修改用户名称事件 /// void LoadEvent_EditUserName() { EventHandler eventHandler = (sender, e) => { Action 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 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 } }