From 3a26f6025130dcaae4aa82ea19b16ad902450eb8 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 28 十一月 2019 11:43:47 +0800
Subject: [PATCH] 合并全部代码完成

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs |  164 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 153 insertions(+), 11 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..6c3fb2b 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs
@@ -35,6 +35,14 @@
         /// 鎺т欢鐨勭偣鍑讳簨浠�(姝や簨浠惰璁ゅ彲涓烘墽琛屾寜閽寜涓嬩簨浠讹紝鍙桟anClick灞炴�ф帶鍒�)
         /// </summary>
         public Action<Button, MouseEventArgs> ButtonClickEvent = null;
+        /// <summary>
+        /// 搴曢儴闃村奖鎺т欢1
+        /// </summary>
+        private Button btnBottomShadowView1 = null;
+        /// <summary>
+        /// 搴曢儴闃村奖鎺т欢2
+        /// </summary>
+        private Button btnBottomShadowView2 = null;
 
         #endregion
 
@@ -124,7 +132,21 @@
             }
             if (CanClick == true)
             {
-                this.ButtonClickEvent?.Invoke(this, e);
+                //Log鍑哄姏
+                this.WriteLog();
+
+                try
+                {
+                    this.ButtonClickEvent?.Invoke(this, e);
+                }
+                catch (Exception ex)
+                {
+                    //鍑虹幇鏈煡閿欒
+                    var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError));
+                    alert.Show();
+                    //Log鍑哄姏
+                    HdlLogLogic.Current.WriteLog(ex);
+                }
             }
         }
 
@@ -204,18 +226,138 @@
             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;
+                byteLength += Encoding.UTF8.GetBytes(i_text[i].ToString()).Length;
+                //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);
+            return Application.GetRealWidth(realWidth + 20);
+        }
+
+        /// <summary>
+        /// 娣诲姞搴曢儴闃村奖鐗规晥(纭繚鎷ユ湁鐖舵帶浠跺悗鎵嶈皟鐢�)
+        /// </summary>
+        /// <param name="view">涓哄摢涓帶浠舵坊鍔犻槾褰辩壒鏁�,鐪佺暐鏃�,涓哄綋鍓嶆帶浠舵坊鍔�</param>
+        /// <param name="average">娣诲姞鐨勯槾褰辩壒鏁堟槸鍚︽寜骞冲潎鍊艰缃珮瀹藉害</param>
+        public void AddBottomShadow(View view = null, bool average = false)
+        {
+            //闇�瑕佹墿澶х殑楂樺害
+            int heightValue = 21;
+            //闇�瑕佹墿澶х殑瀹藉害
+            int widthValue = 15;
+            //鏈�澶ч珮搴�
+            int maxHeight = 0;
+            if (average == false)
+            {
+                heightValue = Application.GetRealHeight(heightValue);
+                widthValue = Application.GetRealWidth(widthValue);
+                maxHeight = Application.GetRealHeight(460);
+            }
+            else
+            {
+                heightValue = Application.GetMinRealAverage(heightValue);
+                widthValue = Application.GetMinRealAverage(widthValue);
+                maxHeight = Application.GetMinRealAverage(460);
+            }
+            if (view == null)
+            {
+                //鐪佺暐鏃�,鎸囧畾涓哄綋鍓嶆帶浠�
+                view = this;
+            }
+            //鍏堢Щ闄�
+            this.btnBottomShadowView1?.RemoveFromParent();
+            this.btnBottomShadowView2?.RemoveFromParent();
+
+            int realHeight = view.Height + heightValue * 2;
+            if (realHeight <= maxHeight)
+            {
+                //闃村奖鎺т欢
+                this.btnBottomShadowView1 = new Button();
+                btnBottomShadowView1.UnSelectedImagePath = "Item/BottomShadow.png";
+                btnBottomShadowView1.Height = realHeight;
+                btnBottomShadowView1.Width = view.Width + widthValue * 2;
+                btnBottomShadowView1.X = view.X - widthValue;
+                btnBottomShadowView1.Y = view.Y;
+                view.Parent.AddChidren(btnBottomShadowView1);
+                view.BringToFront();
+            }
+            else
+            {
+                //瓒呰繃鏈�澶ф椂,鐗规畩澶勭悊
+                this.btnBottomShadowView1 = new Button();
+                btnBottomShadowView1.UnSelectedImagePath = "Item/BottomShadow.png";
+                btnBottomShadowView1.Height = view.Height - heightValue * 2;
+                btnBottomShadowView1.Width = view.Width + widthValue * 2;
+                btnBottomShadowView1.X = view.X - widthValue;
+                btnBottomShadowView1.Y = view.Y + heightValue * 2;
+                view.Parent.AddChidren(btnBottomShadowView1);
+
+                this.btnBottomShadowView2 = new Button();
+                btnBottomShadowView2.UnSelectedImagePath = "Item/BottomShadow.png";
+                btnBottomShadowView2.Height = maxHeight;
+                btnBottomShadowView2.Width = view.Width + widthValue * 2;
+                btnBottomShadowView2.X = view.X - widthValue;
+                btnBottomShadowView2.Y = view.Bottom - maxHeight + heightValue * 2;
+                view.Parent.AddChidren(btnBottomShadowView2);
+                view.BringToFront();
+            }
+        }
+
+        #endregion
+
+        #region 鈻� Log鍑哄姏____________________________
+
+        /// <summary>
+        /// 璇ユ帶浠舵墍灞炵殑鐣岄潰鍚嶅瓧
+        /// </summary>
+        private string formName = null;
+        /// <summary>
+        /// 鎺т欢鍚嶅瓧
+        /// </summary>
+        private string controlName = null;
+
+        /// <summary>
+        /// Log鍑哄姏
+        /// </summary>
+        private void WriteLog()
+        {
+            if (formName == null)
+            {
+                formName = string.Empty;
+                View myView = this.Parent;
+                for (; ; )
+                {
+                    if (myView == null)
+                    {
+                        break;
+                    }
+                    else if (myView is CommonFormBase)
+                    {
+                        //杩欎釜鎺т欢鎵�灞炵殑鐣岄潰
+                        formName = ((CommonFormBase)myView).FormID;
+                        break;
+                    }
+                    myView = myView.Parent;
+                }
+                if (string.IsNullOrEmpty(this.Text) == false)
+                {
+                    //杩欎釜鎺т欢鐨勬枃鏈�
+                    controlName = this.Text;
+                }
+                else
+                {
+                    //濡傛灉娌℃湁鏂囨湰鐨勮瘽,瀹冨簲璇ユ槸涓�寮犲浘鐗�
+                    controlName = this.UnSelectedImagePath;
+                }
+            }
+            HdlLogLogic.Current.WriteLog(1, formName + "鐨刐" + controlName + "]鎸夐敭琚偣鍑�");
         }
 
         #endregion

--
Gitblit v1.8.0