From 48ba446936b51fffafa7c3600c0dadc6ac0e8c20 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 10 七月 2020 10:52:13 +0800
Subject: [PATCH] 2020-07-10-01

---
 ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs |   70 +++++++++++++++++++++++------------
 1 files changed, 46 insertions(+), 24 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs
index 8998b82..881b00b 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs
@@ -20,6 +20,9 @@
         /// </summary>
         public void ShowForm()
         {
+            //璁颁綇瀹冨師鏉ョ殑鏄电О
+            UserCenterResourse.UserInfo.OldUserName = UserCenterResourse.UserInfo.UserName;
+
             //鍥犱负鍒殑鐢婚潰浼氳皟鐢ㄨ繖涓嚱鏁帮紝鐒跺悗鍒锋柊鐢婚潰
             this.ClearBodyFrame();
 
@@ -52,9 +55,9 @@
 
             //鐢ㄦ埛鍥炬爣
             var btnUserIcon = new ImageView();
-            btnUserIcon.Height = Application.GetMinRealAverage(251);
-            btnUserIcon.Width = Application.GetMinRealAverage(251);
-            btnUserIcon.Radius = (uint)Application.GetMinRealAverage(251) / 2;
+            btnUserIcon.Height = this.GetPictrueRealSize(251);
+            btnUserIcon.Width = this.GetPictrueRealSize(251);
+            btnUserIcon.Radius = (uint)this.GetPictrueRealSize(251) / 2;
             btnUserIcon.Y = Application.GetRealHeight(46);
             btnUserIcon.Gravity = Gravity.CenterHorizontal;
             btnUserIcon.ImageBytes = Shared.IO.FileUtils.ReadFile(UserCenterResourse.UserInfo.UserIconFile);
@@ -102,7 +105,8 @@
             //鍚嶇ОView
             rowName.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uName), 350);
             //鍚嶇О杈撳叆
-            var txtName = new TextInputExControl(700, true);
+            var txtName = new TextInputControl(700, true);
+            txtName.UseFocusColor = true;
             txtName.X = bodyFrameLayout.Width - Application.GetRealWidth(700) - ControlCommonResourse.XXLeft;
             txtName.Gravity = Gravity.CenterVertical;
             txtName.TextAlignment = TextAlignment.CenterRight;
@@ -112,15 +116,27 @@
             //杈撳叆缁撴潫浜嬩欢
             txtName.FinishInputEvent += (() =>
             {
-                if (txtName.Text.Trim() == string.Empty)
-                {
-                    //鎶婂悕绉拌繕鍘熷洖鍘�
-                    txtName.Text = UserCenterResourse.UserInfo.UserName;
-                    return;
-                }
                 //鏇存柊鐢ㄦ埛鍚�
-                this.SaveUserName(txtName.Text.Trim());
+                this.SaveUserName(txtName, true);
             });
+            //杈撳叆鍊兼敼鍙樹簨浠�(2020.04.05:浠ュ墠閮藉畾姝昏鎸夊洖杞﹂敭鎵嶆洿鏂�,鐜板湪鍙堣鍚嶅瓧娌℃湁鍚屾
+            //鎵�浠ユ墠鍑烘涓嬬瓥,娣诲姞杩欎釜浜嬩欢)
+            txtName.TextChangeEventHandler += (sender, value) =>
+            {
+                UserCenterResourse.UserInfo.UserName = value;
+            };
+            //鍏夋爣鏀瑰彉浜嬩欢(2020.04.05:浠ュ墠閮藉畾姝昏鎸夊洖杞﹂敭鎵嶆洿鏂�,鐜板湪鍙堣鍚嶅瓧娌℃湁鍚屾
+            //鎵�浠ユ墠鍑烘涓嬬瓥,娣诲姞杩欎釜浜嬩欢)
+            txtName.FoucsChanged += (sender, focusEvent) =>
+            {
+                //鍏夋爣绂诲紑鏃�,鎵ц鍚嶅瓧淇敼
+                if (focusEvent.Focus == false)
+                {
+                    //鏇存柊鐢ㄦ埛鍚�
+                    this.SaveUserName(txtName, false);
+                }
+            };
+
             //鑱斿姩绾跨殑鐘舵��
             txtName.btnLine = btnNameLine;
 
@@ -300,32 +316,38 @@
         /// <summary>
         /// 鏇存柊鐢ㄦ埛鍚�
         /// </summary>
-        /// <param name="userName">鏄电О</param>
-        private async void SaveUserName(string userName)
+        /// <param name="txtName"></param>
+        private async void SaveUserName(TextInputControl txtName, bool showMsg)
         {
-            if (UserCenterResourse.UserInfo.UserName == userName)
+            if (UserCenterResourse.UserInfo.UserName == string.Empty)
             {
+                //鎶婂悕绉拌繕鍘熷洖鍘�
+                txtName.Text = UserCenterResourse.UserInfo.OldUserName;
+                UserCenterResourse.UserInfo.UserName = UserCenterResourse.UserInfo.OldUserName;
                 return;
             }
-            //鎵撳紑杩涘害鏉�
-            this.ShowProgressBar();
-
+            if (UserCenterResourse.UserInfo.OldUserName == UserCenterResourse.UserInfo.UserName)
+            {
+                //鏃犻渶淇敼
+                return;
+            }
             var pra = new SaveUserNamePra();
-            pra.UserName = userName;
+            pra.UserName = UserCenterResourse.UserInfo.UserName;
 
             bool result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpdateUserName", false, pra);
-            //鍏抽棴杩涘害鏉�
-            this.CloseProgressBar();
             if (result == false)
             {
                 return;
             }
 
-            //鐢ㄦ埛鍚嶇О淇敼鎴愬姛!
-            string msg = Language.StringByID(R.MyInternationalizationString.uUserNameSaveSuccess);
-            this.ShowMassage(ShowMsgType.Tip, msg);
+            if (showMsg == true)
+            {
+                //鐢ㄦ埛鍚嶇О淇敼鎴愬姛!
+                string msg = Language.StringByID(R.MyInternationalizationString.uUserNameSaveSuccess);
+                this.ShowMassage(ShowMsgType.Tip, msg);
+            }
 
-            UserCenterResourse.UserInfo.UserName = userName;
+            UserCenterResourse.UserInfo.OldUserName = UserCenterResourse.UserInfo.UserName;
         }
 
         #endregion

--
Gitblit v1.8.0