From 66a9965c44ecc32a6696abca876ab9d1cd091584 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 28 二月 2020 15:25:13 +0800
Subject: [PATCH] 2020.2.28

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs |  159 +++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 124 insertions(+), 35 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs
index 74b9849..52af78a 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs
@@ -30,11 +30,22 @@
                 else { this.SetClickStatu(); }
             }
         }
+        /// <summary>
+        /// 鍦嗚搴�
+        /// </summary>
+        public int RadiusEx
+        {
+            set { this.Radius = (uint)Application.GetRealHeight(value); }
+        }
 
         /// <summary>
-        /// 鎺т欢鐨勭偣鍑讳簨浠�(姝や簨浠惰璁ゅ彲涓烘墽琛屾寜閽寜涓嬩簨浠讹紝鍙桟anClick灞炴�ф帶鍒�)
+        /// 鎺т欢鐨勭偣鍑讳簨浠�(鑷畾涔夊皝瑁呬簨浠�,姝や簨浠惰璁ゅ彲涓烘墽琛屾寜閽寜涓嬩簨浠�,鍙桟anClick灞炴�ф帶鍒�)
         /// </summary>
         public Action<Button, MouseEventArgs> ButtonClickEvent = null;
+        /// <summary>
+        /// 鎺т欢鐨勬寜涓嬩簨浠�(鑷畾涔夊皝瑁呬簨浠�,姝や簨浠惰璁ゅ彲涓烘墽琛屾寜閽寜涓嬩簨浠�,鍙桟anClick灞炴�ф帶鍒�)
+        /// </summary>
+        public Action<Button, MouseEventArgs> ButtonDownClickEvent = null;
 
         #endregion
 
@@ -53,6 +64,8 @@
 
             //鐐瑰嚮浜嬩欢
             this.MouseUpEventHandler += ButtonBase_MouseUpEventHandler;
+            //鎸変笅浜嬩欢
+            this.MouseDownEventHandler += ButtonBase_MouseDownEventHandler;
         }
 
         /// <summary>
@@ -124,7 +137,52 @@
             }
             if (CanClick == true)
             {
-                this.ButtonClickEvent?.Invoke(this, e);
+                //Log鍑哄姏
+                this.WriteLog(0);
+
+                try
+                {
+                    this.ButtonClickEvent(this, e);
+                }
+                catch (Exception ex)
+                {
+                    //鍑虹幇鏈煡閿欒
+                    var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError));
+                    alert.Show();
+                    //Log鍑哄姏
+                    HdlLogLogic.Current.WriteLog(ex);
+                }
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 鎸変笅浜嬩欢___________________________
+
+        /// <summary>
+        /// 鎸変笅浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ButtonBase_MouseDownEventHandler(object sender, MouseEventArgs e)
+        {
+            if (CanClick == false || this.ButtonDownClickEvent == null)
+            {
+                //涓嶈兘鐐瑰嚮
+                return;
+            }
+
+            try
+            {
+                this.ButtonDownClickEvent(this, e);
+            }
+            catch (Exception ex)
+            {
+                //鍑虹幇鏈煡閿欒
+                var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError));
+                alert.Show();
+                //Log鍑哄姏
+                HdlLogLogic.Current.WriteLog(ex);
             }
         }
 
@@ -151,21 +209,13 @@
         #region 鈻� 涓�鑸柟娉昣__________________________
 
         /// <summary>
-        /// 閲嶇疆鍗曞嚮浜嬩欢(姝ゆ搷浣滃鎵樹細鍙榥ull)
-        /// </summary>
-        public void ResetClickEvent()
-        {
-            ButtonClickEvent = null;
-            this.MouseUpEventHandler -= this.ButtonBase_MouseUpEventHandler;
-            this.MouseUpEventHandler += this.ButtonBase_MouseUpEventHandler;
-        }
-
-        /// <summary>
         /// 鎺т欢鎽ф瘉
         /// </summary>
         public override void RemoveFromParent()
         {
             ButtonClickEvent = null;
+            ButtonDownClickEvent = null;
+
             base.RemoveFromParent();
         }
 
@@ -185,37 +235,76 @@
         }
 
         /// <summary>
-        /// 鏍规嵁鏂囨湰,璁$畻瀹冨疄闄呯殑瀹藉害(杩斿洖鐨勬槸鐪熷疄鍊�)
+        /// 鏍规嵁鏂囨湰,璁$畻瀹冨疄闄呯殑瀹藉害
         /// </summary>
-        /// <param name="textSize">瀛椾綋澶у皬,鐪佺暐鏃朵娇鐢ㄥ綋鍓嶆帶浠剁殑瀛椾綋澶у皬</param>
-        /// <param name="i_text">闇�瑕佽绠楃殑鏂囨湰淇℃伅,鐪佺暐鏃朵娇鐢ㄥ綋鍓嶆帶浠剁殑鏂囨湰</param>
         /// <returns></returns>
-        public int GetRealWidthByText(float textSize, string i_text = null)
+        public int GetRealWidthByText()
         {
-            if (i_text == null)
-            {
-                i_text = this.Text;
-            }
-            if (textSize == -1)
-            {
-                textSize = this.TextSize;
-            }
+#if Android
+            //闇�瑕佸鍔犱竴涓宸��
+            return this.GetTextWidth() + Application.GetRealWidth(12);
+#endif
+#if iOS
+            //闇�瑕佸鍔犱竴涓宸��
+            return this.GetTextWidth() + Application.GetRealWidth(25);
+#endif
+        }
 
-            int byteLength = 0;
-            for (int i = 0; i < i_text.Length; i++)
+        #endregion
+
+        #region 鈻� Log鍑哄姏____________________________
+
+        /// <summary>
+        /// 璇ユ帶浠舵墍灞炵殑鐣岄潰鍚嶅瓧
+        /// </summary>
+        private string formName = null;
+        /// <summary>
+        /// 鎺т欢鍚嶅瓧
+        /// </summary>
+        private string controlName = null;
+
+        /// <summary>
+        /// Log鍑哄姏
+        /// </summary>
+        private void WriteLog(int div)
+        {
+            if (formName == null)
             {
-                int length = Encoding.UTF8.GetBytes(i_text[i].ToString()).Length;
-                if (length == 1)
+                formName = string.Empty;
+                View myView = this.Parent;
+                for (; ; )
                 {
-                    //鑻辨枃
-                    byteLength += length;
-                    continue;
+                    if (myView == null)
+                    {
+                        break;
+                    }
+                    else if (myView is CommonFormBase)
+                    {
+                        //杩欎釜鎺т欢鎵�灞炵殑鐣岄潰
+                        formName = ((CommonFormBase)myView).FormID;
+                        break;
+                    }
+                    myView = myView.Parent;
                 }
-                //涓枃(鏆傛椂鐢ㄤ腑鏂囧搴�)
-                byteLength += Encoding.GetEncoding("gb2312").GetBytes(i_text[i].ToString()).Length;
+                if (string.IsNullOrEmpty(this.Text) == false)
+                {
+                    //杩欎釜鎺т欢鐨勬枃鏈�
+                    controlName = this.Text;
+                }
+                else
+                {
+                    //濡傛灉娌℃湁鏂囨湰鐨勮瘽,瀹冨簲璇ユ槸涓�寮犲浘鐗�
+                    controlName = this.UnSelectedImagePath;
+                }
             }
-            int realWidth = byteLength * (int)textSize;
-            return Application.GetRealWidth(realWidth);
+            if (div == 0)
+            {
+                HdlLogLogic.Current.WriteLog(1, formName + "鐨刐" + controlName + "]鎸夐敭琚偣鍑�");
+            }
+            else
+            {
+                HdlLogLogic.Current.WriteLog(1, formName + "鐨刐" + controlName + "]鎸夐敭琚暱鎸�");
+            }
         }
 
         #endregion

--
Gitblit v1.8.0