From fa6bcb2e9907772480f99205f36ec2a1ce735a22 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 09 一月 2020 14:11:07 +0800
Subject: [PATCH] 合并代码

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs |  131 +++++++++++++++++++++++--------------------
 1 files changed, 71 insertions(+), 60 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 4319b59..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>
@@ -125,22 +138,51 @@
             if (CanClick == true)
             {
                 //Log鍑哄姏
-                this.WriteLog();
+                this.WriteLog(0);
 
                 try
                 {
-                    this.ButtonClickEvent?.Invoke(this, e);
+                    this.ButtonClickEvent(this, e);
                 }
                 catch (Exception ex)
                 {
-                    //鍑虹幇鏈煡閿欒,鏁版嵁涓㈠け
-                    var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnknownErrorAndDataLost));
+                    //鍑虹幇鏈煡閿欒
+                    var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError));
                     alert.Show();
                     //Log鍑哄姏
-                    string msg = ex.Message + "\r\n";
-                    msg += ex.TargetSite.ToString();
-                    HdlLogLogic.Current.WriteLog(-1, msg);
+                    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);
             }
         }
 
@@ -167,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();
         }
 
@@ -201,49 +235,19 @@
         }
 
         /// <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;
-            }
-
-            int byteLength = 0;
-            for (int i = 0; i < i_text.Length; i++)
-            {
-                int length = Encoding.UTF8.GetBytes(i_text[i].ToString()).Length;
-                if (length == 1)
-                {
-                    //鑻辨枃
-                    byteLength += length;
-                    continue;
-                }
-                //涓枃(鏆傛椂鐢ㄤ腑鏂囧搴�)
-                byteLength += Encoding.GetEncoding("gb2312").GetBytes(i_text[i].ToString()).Length;
-            }
-            int realWidth = byteLength * (int)textSize;
-            return Application.GetRealWidth(realWidth);
-        }
-
-        /// <summary>
-        /// 娣诲姞搴曢儴闃村奖鐗规晥(纭繚鎷ユ湁鐖舵帶浠跺悗鎵嶈皟鐢�)
-        /// </summary>
-        public void AddBottomShadow()
-        {
-            var btnShadow = new PicViewControl(this.Width, Application.GetMinRealAverage(45), false);
-            btnShadow.X = this.X;
-            btnShadow.Y = this.Bottom - 1;
-            btnShadow.UnSelectedImagePath = "Item/BottomShadow.png";
-            this.Parent.AddChidren(btnShadow);
+#if Android
+            //闇�瑕佸鍔犱竴涓宸��
+            return this.GetTextWidth() + Application.GetRealWidth(12);
+#endif
+#if iOS
+            //闇�瑕佸鍔犱竴涓宸��
+            return this.GetTextWidth() + Application.GetRealWidth(25);
+#endif
         }
 
         #endregion
@@ -262,7 +266,7 @@
         /// <summary>
         /// Log鍑哄姏
         /// </summary>
-        private void WriteLog()
+        private void WriteLog(int div)
         {
             if (formName == null)
             {
@@ -293,7 +297,14 @@
                     controlName = this.UnSelectedImagePath;
                 }
             }
-            HdlLogLogic.Current.WriteLog(1, formName + "鐨刐" + controlName + "]鎸夐敭琚偣鍑�");
+            if (div == 0)
+            {
+                HdlLogLogic.Current.WriteLog(1, formName + "鐨刐" + controlName + "]鎸夐敭琚偣鍑�");
+            }
+            else
+            {
+                HdlLogLogic.Current.WriteLog(1, formName + "鐨刐" + controlName + "]鎸夐敭琚暱鎸�");
+            }
         }
 
         #endregion

--
Gitblit v1.8.0