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/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs | 152 +++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 130 insertions(+), 22 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..7c86b24 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(); } @@ -204,18 +254,76 @@ 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); + } + + #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) + { + 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; + } + } + if (div == 0) + { + HdlLogLogic.Current.WriteLog(1, formName + "鐨刐" + controlName + "]鎸夐敭琚偣鍑�"); + } + else + { + HdlLogLogic.Current.WriteLog(1, formName + "鐨刐" + controlName + "]鎸夐敭琚暱鎸�"); + } } #endregion -- Gitblit v1.8.0