From ff3cfcf62632bf43e51a6b6098c203bf0f5cddbc Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期二, 24 十二月 2019 19:53:29 +0800 Subject: [PATCH] 2019.12.24 --- ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 103 insertions(+), 2 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs index d84a7e6..4ee3637 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs @@ -46,11 +46,19 @@ bodyFrameLayout.AddChidren(specialTopFrame); //鐢ㄦ埛鍥炬爣 - var btnUserIcon = new IconViewControl(251); + var btnUserIcon = new ImageView(); + btnUserIcon.Height = Application.GetMinRealAverage(251); + btnUserIcon.Width = Application.GetMinRealAverage(251); + btnUserIcon.Radius = (uint)Application.GetMinRealAverage(251) / 2; btnUserIcon.Y = Application.GetRealHeight(46); btnUserIcon.Gravity = Gravity.CenterHorizontal; - btnUserIcon.UnSelectedImagePath = UserCenterResourse.UserInfo.UserIconFile; + btnUserIcon.ImageBytes = Shared.IO.FileUtils.ReadFile(UserCenterResourse.UserInfo.UserIconFile); specialTopFrame.AddChidren(btnUserIcon); + btnUserIcon.MouseUpEventHandler += (sender, e) => + { + //鏄剧ず鑾峰彇鍥剧墖鏉ユ簮鑿滃崟 + this.ShowUserIconMenu(btnUserIcon); + }; } #endregion @@ -242,6 +250,7 @@ //閫�鍑虹櫥闄� var btnLogout = new NormalClickButton(specialFrame.Width, specialFrame.Height); + btnLogout.clickStatuColor = 0xfffbfbfb; btnLogout.TextID = R.MyInternationalizationString.uLogoutAccount; btnLogout.TextColor = 0xff666666; btnLogout.BackgroundColor = UserCenterColor.Current.White; @@ -296,6 +305,98 @@ #endregion + #region 鈻� 鏄剧ず鑾峰彇鍥剧墖鏉ユ簮鑿滃崟_______________ + + /// <summary> + /// 鏄剧ず鑾峰彇鍥剧墖鏉ユ簮鑿滃崟 + /// </summary> + /// <param name="btnUser"></param> + private void ShowUserIconMenu(ImageView btnUser) + { + var menuContr = new BottomMenuSelectForm(); + menuContr.AddForm(2); + //鎷嶇収 + menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.uTakePictrue), () => + { + //閫氳繃鐩告満鎷嶇収瑁佸壀 + CropImage.TakePicture((imagePath) => + { + if (string.IsNullOrEmpty(imagePath) == false) + { + //绉诲姩鐢ㄦ埛澶村儚鏂囦欢 + if (this.MoveUserIconFile(imagePath) == true) + { + //涓婁紶鐢ㄦ埛澶村儚鏂囦欢 + this.UpLoadUserIconFile(btnUser, UserCenterResourse.UserInfo.UserIconFile); + } + } + }, "HdlPicture"); + }); + //浠庣浉鍐屼腑閫夋嫨 + menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.uGetPictrueFromAlbum), () => + { + //浠庣浉鍐岄�夋嫨鍥剧墖瑁佸壀 + CropImage.SelectPicture((imagePath) => + { + if (string.IsNullOrEmpty(imagePath) == false) + { + //绉诲姩鐢ㄦ埛澶村儚鏂囦欢 + if (this.MoveUserIconFile(imagePath) == true) + { + //涓婁紶鐢ㄦ埛澶村儚鏂囦欢 + this.UpLoadUserIconFile(btnUser, UserCenterResourse.UserInfo.UserIconFile); + } + } + }, "HdlPicture"); + }); + } + + /// <summary> + /// 涓婁紶鐢ㄦ埛澶村儚鏂囦欢 + /// </summary> + /// <param name="btnUser"></param> + /// <param name="imagePath"></param> + private async void UpLoadUserIconFile(ImageView btnUser, string imagePath) + { + var pra = new { HeadImage = Shared.IO.FileUtils.ReadFile(imagePath) }; + var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpdateHeadImage", false, pra); + if (result == true) + { + UserCenterResourse.UserInfo.UserIconFileChanged = true; + btnUser.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath); + } + } + + /// <summary> + /// 绉诲姩鐢ㄦ埛澶村儚鏂囦欢 + /// </summary> + /// <param name="imagePath"></param> + /// <returns></returns> + private bool MoveUserIconFile(string imagePath) + { + try + { + if (System.IO.File.Exists(UserCenterResourse.UserInfo.UserIconFile) == true) + { + System.IO.File.Delete(UserCenterResourse.UserInfo.UserIconFile); + } + //绉诲姩鏂囦欢 + System.IO.File.Move(imagePath, UserCenterResourse.UserInfo.UserIconFile); + return true; + } + catch (Exception ex) + { + //鍑虹幇鏈煡閿欒 + var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError)); + alert.Show(); + //Log + HdlLogLogic.Current.WriteLog(ex); + return false; + } + } + + #endregion + #region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________ /// <summary> -- Gitblit v1.8.0