From 5986f63b75bd81c6cef262c670e9251c038cbf5d Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期二, 17 十二月 2019 17:21:07 +0800
Subject: [PATCH] 合并一个版本

---
 ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs |  149 +++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 129 insertions(+), 20 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs
index d8d38b6..c203417 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs
@@ -8,6 +8,11 @@
     /// </summary>
     public class UserInformationForm : EditorCommonForm
     {
+        /// <summary>
+        /// 涓儴妗屽竷鎺т欢
+        /// </summary>
+        private FrameLayout frameMiddleBack = null;
+
         #region 鈻� 鍒濆鍖朹____________________________
 
         /// <summary>
@@ -46,20 +51,18 @@
             bodyFrameLayout.AddChidren(specialTopFrame);
 
             //鐢ㄦ埛鍥炬爣
-            var btnUserIcon = new CutPictureControl(UserCenterResourse.UserInfo.UserIconFile, 251, 251, true);
+            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.ImagePath = UserCenterResourse.UserInfo.UserIconFile;
+            btnUserIcon.ImageBytes = Shared.IO.FileUtils.ReadFile(UserCenterResourse.UserInfo.UserIconFile);
             specialTopFrame.AddChidren(btnUserIcon);
-            btnUserIcon.SelectPictrueEvent += async (selectPic) =>
+            btnUserIcon.MouseUpEventHandler += (sender, e) =>
             {
-                var pra = new { HeadImage = Shared.IO.FileUtils.ReadFile(selectPic) };
-                var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpdateHeadImage", false, pra);
-                if (result == true)
-                {
-                    UserCenterResourse.UserInfo.UserIconFileChanged = true;
-                }
+                //鏄剧ず鑾峰彇鍥剧墖鏉ユ簮鑿滃崟
+                this.ShowUserIconMenu(btnUserIcon);
             };
         }
 
@@ -72,16 +75,23 @@
         /// </summary>
         private void InitMiddleBodyFrame()
         {
-            var frameBack = new FrameLayout();
-            frameBack.Y = Application.GetRealHeight(363);
-            frameBack.Height = Application.GetRealHeight(1008);
-            frameBack.BackgroundColor = UserCenterColor.Current.White;
-            bodyFrameLayout.AddChidren(frameBack);
+            if (this.frameMiddleBack == null)
+            {
+                frameMiddleBack = new FrameLayout();
+                frameMiddleBack.Y = Application.GetRealHeight(363);
+                frameMiddleBack.Height = Application.GetRealHeight(1008);
+                frameMiddleBack.BackgroundColor = UserCenterColor.Current.White;
+                bodyFrameLayout.AddChidren(frameMiddleBack);
+            }
+            else
+            {
+                frameMiddleBack.RemoveAll();
+            }
 
             var listMidFrame = new FrameListControl(12);
             listMidFrame.Y = Application.GetRealHeight(11);
             listMidFrame.Height = Application.GetRealHeight(1008 - 11);
-            frameBack.AddChidren(listMidFrame);
+            frameMiddleBack.AddChidren(listMidFrame);
 
             var rowName = new FrameRowControl(listMidFrame.rowSpace / 2);
             //鍏抽棴鐐瑰嚮鐘舵��
@@ -136,6 +146,7 @@
             rowEmail.AddRightArrow();
             //閭
             var btnEmail = rowEmail.AddMostRightView(UserCenterResourse.UserInfo.Email, 500);
+            btnEmail.IsBold = true;
             if (string.IsNullOrEmpty(UserCenterResourse.UserInfo.Email) == true)
             {
                 //鏈缃�,璇风粦瀹�
@@ -165,6 +176,7 @@
             rowPhone.AddRightArrow();
             //鎵嬫満鍙�
             var btnPhone = rowPhone.AddMostRightView(UserCenterResourse.UserInfo.Phone, 500);
+            btnPhone.IsBold = true;
             if (string.IsNullOrEmpty(UserCenterResourse.UserInfo.Phone) == true)
             {
                 //鏈缃�,璇风粦瀹�
@@ -198,7 +210,9 @@
             //娣诲姞鍚戝彸鍥炬爣
             rowOther.AddRightArrow();
             //寰俊銆丵Q
-            rowOther.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uWebChatAndQQ), 500);
+            //var btnQQ = rowOther.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uWebChatAndQQ), 500);
+            var btnQQ = rowOther.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uWebChat), 500);
+            btnQQ.IsBold = true;
             rowOther.ButtonClickEvent += (sender, e) =>
             {
                 var form = new OtherParty.OtherPartyAccountMenuForm();
@@ -214,7 +228,8 @@
             //娣诲姞鍚戝彸鍥炬爣
             rowSysPsw.AddRightArrow();
             //鍘讳慨鏀�
-            rowSysPsw.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGotoEditor), 350);
+            var btnPsw = rowSysPsw.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGotoEditor), 350);
+            btnPsw.IsBold = true;
             rowSysPsw.ButtonClickEvent += (sender, e) =>
             {
                 var form = new Password.EditorAccountPasswordForm();
@@ -228,7 +243,8 @@
             //娣诲姞鍚戝彸鍥炬爣
             rowSecond.AddRightArrow();
             //瀵嗙爜銆佹墜鍔裤�佹寚绾�
-            rowSecond.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uPasswordGestureFingerPrint), 400);
+            var btnSecand = rowSecond.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uPasswordGestureFingerPrint), 400);
+            btnSecand.IsBold = true;
             rowSecond.ButtonClickEvent += (sender, e) =>
             {
                 var form = new SecondAuthenticationForm();
@@ -252,6 +268,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;
@@ -306,6 +323,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>
@@ -313,8 +422,8 @@
         /// </summary>
         public override int FormActionAgainEvent()
         {
-            //閲嶆柊鍒锋柊鐣岄潰
-            this.ShowForm();
+            //鍒濆鍖栦腑閮ㄧ殑淇℃伅
+            this.InitMiddleBodyFrame();
 
             return 1;
         }

--
Gitblit v1.8.0