From dc0309e64f02227d8e1468b7326c07955f804612 Mon Sep 17 00:00:00 2001 From: chenqiyang <1406175257@qq.com> Date: 星期三, 22 六月 2022 11:22:18 +0800 Subject: [PATCH] 修改引用路径 --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs | 673 ++++++++++++++++++++++++++++++++----------------------- 1 files changed, 386 insertions(+), 287 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 old mode 100755 new mode 100644 index 4319b59..3e07c81 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs @@ -1,301 +1,400 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Text; - -namespace Shared.Phone.UserCenter -{ - /// <summary> - /// Botton鐨勬渶鍒濆師鍨�(涓嶅缓璁慨鏀瑰拰鐩存帴浣跨敤):鏍囧噯瀛椾綋鍜岄鑹诧紝鏂囧瓧鍚戝乏闈犻綈,14鍙峰瓧 - /// </summary> - public class ButtonBase : Button - { - #region 鈻� 鍙橀噺澹版槑___________________________ - - /// <summary> - /// 璁剧疆鑳藉惁瑙︾偣鍑讳簨浠� - /// </summary> - private bool m_CanClick = true; - /// <summary> - /// 璁剧疆鑳藉惁瑙︾偣鍑讳簨浠� +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace Shared.Phone.UserCenter +{ + /// <summary> + /// Botton鐨勬渶鍒濆師鍨�(涓嶅缓璁慨鏀瑰拰鐩存帴浣跨敤):鏍囧噯瀛椾綋鍜岄鑹诧紝鏂囧瓧鍚戝乏闈犻綈,14鍙峰瓧 + /// </summary> + public class ButtonBase : Button + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 璁剧疆鑳藉惁瑙︾偣鍑讳簨浠� /// </summary> - public bool CanClick - { - get { return m_CanClick; } - set - { - m_CanClick = value; - //鑳藉鐐瑰嚮,鍒欐樉绀烘病鏈夌偣鍑昏繃鐨勭姸鎬� - if (m_CanClick == true) { this.SetNotClickStatu(); } - //涓嶈兘鐐瑰嚮,鍒欐樉绀哄凡缁忕偣鍑讳簡鐨勭姸鎬� - else { this.SetClickStatu(); } - } - } - - /// <summary> - /// 鎺т欢鐨勭偣鍑讳簨浠�(姝や簨浠惰璁ゅ彲涓烘墽琛屾寜閽寜涓嬩簨浠讹紝鍙桟anClick灞炴�ф帶鍒�) - /// </summary> - public Action<Button, MouseEventArgs> ButtonClickEvent = null; - - #endregion - - #region 鈻� 鍒濆鍖朹____________________________ - - /// <summary> - /// Botton鐨勬渶鍒濆師鍨�(涓嶅缓璁慨鏀瑰拰鐩存帴浣跨敤):鏍囧噯瀛椾綋鍜岄鑹诧紝鏂囧瓧鍚戝乏闈犻綈,14鍙峰瓧 - /// </summary> - public ButtonBase() - { - //娴嬭瘯锛屽叏浣撴寜閽负14鍙峰瓧 - this.TextSize = 14; - - this.TextColor = UserCenterColor.Current.TextColor1; - this.TextAlignment = TextAlignment.CenterLeft; - - //鐐瑰嚮浜嬩欢 - this.MouseUpEventHandler += ButtonBase_MouseUpEventHandler; - } - - /// <summary> - /// 鍒濆鍖栨帶浠跺ぇ灏�(涓嶄互骞冲潎鍊艰繘琛岀湡瀹炴暟鍊艰绠�) - /// </summary> + private bool m_CanClick = true; + /// <summary> + /// 璁剧疆鑳藉惁瑙︾偣鍑讳簨浠� + /// </summary> + public bool CanClick + { + get { return m_CanClick; } + set + { + if (m_CanClick == value) { return; } + + m_CanClick = value; + //鑳藉鐐瑰嚮,鍒欐樉绀烘病鏈夌偣鍑昏繃鐨勭姸鎬� + if (m_CanClick == true) { this.SetNotClickStatu(); } + //涓嶈兘鐐瑰嚮,鍒欐樉绀哄凡缁忕偣鍑讳簡鐨勭姸鎬� + else { this.SetClickStatu(); } + } + } + /// <summary> + /// 鍦嗚搴� + /// </summary> + public int RadiusEx + { + set { this.Radius = (uint)Application.GetRealHeight(value); } + } + /// <summary> + /// 澹版槑姝ゅ彉閲�,鏃ㄥ湪瀛愮嚎绋嬩篃鑳藉鍘昏幏鍙栦竴涓帶浠剁殑涓婚敭 + /// </summary> + public string MainKey = string.Empty; + + /// <summary> + /// 鐐瑰嚮鐨勫潗鏍� + /// </summary> + private System.Drawing.Point downPoint = new System.Drawing.Point(); + + /// <summary> + /// 鎺т欢鐨勭偣鍑讳簨浠�(鑷畾涔夊皝瑁呬簨浠�,姝や簨浠惰璁ゅ彲涓烘墽琛屾寜閽寜涓嬩簨浠�,鍙桟anClick灞炴�ф帶鍒�) + /// </summary> + public Action<Button, MouseEventArgs> ButtonClickEvent = null; + /// <summary> + /// 鎺т欢鐨勬寜涓嬩簨浠�(鑷畾涔夊皝瑁呬簨浠�,姝や簨浠惰璁ゅ彲涓烘墽琛屾寜閽寜涓嬩簨浠�,鍙桟anClick灞炴�ф帶鍒�) + /// </summary> + public Action<Button, MouseEventArgs> ButtonDownClickEvent = null; + /// <summary> + /// 鎺т欢瑙﹀彂绉诲姩鐨勪簨浠�(鑷韩鎷ユ湁绠楁硶,褰撶Щ鍔ㄥ灏戝儚绱犲悗,瑙﹀彂浜嬩欢,娉ㄦ剰,璇ヤ簨浠跺彲鑳戒細棰戠箒鐨勮Е鍙�) + /// </summary> + public Action ButtonHappenMoveEvent = null; + + #endregion + + #region 鈻� 閲嶅啓褰摜鐨勫睘鎬____________________ + + /// <summary> + /// 閲嶅啓Text灞炴�� + /// </summary> + public new string Text + { + //鍏堣繖涔堝紕鍏堝惂 + get { return base.Text == null ? string.Empty : base.Text; } + set + { + base.Text = value == null ? string.Empty : value; + } + } + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// Botton鐨勬渶鍒濆師鍨�(涓嶅缓璁慨鏀瑰拰鐩存帴浣跨敤):鏍囧噯瀛椾綋鍜岄鑹诧紝鏂囧瓧鍚戝乏闈犻綈,14鍙峰瓧 + /// </summary> + public ButtonBase() + { + //娴嬭瘯锛屽叏浣撴寜閽负14鍙峰瓧 + this.TextSize = 14; + + this.TextColor = UserCenterColor.Current.TextColor1; + this.TextAlignment = TextAlignment.CenterLeft; + + //鐐瑰嚮浜嬩欢 + this.MouseUpEventHandler += ButtonBase_MouseUpEventHandler; + //鎸変笅浜嬩欢 + this.MouseDownEventHandler += ButtonBase_MouseDownEventHandler; + //绉诲姩浜嬩欢 + this.MouseMoveEventHandler += ButtonBase_MouseMoveEventHandler; + } + + /// <summary> + /// 鍒濆鍖栨帶浠跺ぇ灏�(涓嶄互骞冲潎鍊艰繘琛岀湡瀹炴暟鍊艰绠�) + /// </summary> /// <param name="i_Width">瀹藉害</param> /// <param name="i_Height">楂樺害</param> - /// <param name="real">鏄惁璁$畻鐪熷疄鍊�</param> - public void InitSize(int i_Width, int i_Height, bool real = true) - { - if (real == true) - { - i_Width = Application.GetRealWidth(i_Width); - i_Height = Application.GetRealHeight(i_Height); + /// <param name="real">鏄惁璁$畻鐪熷疄鍊�</param> + public void InitSize(int i_Width, int i_Height, bool real = true) + { + if (real == true) + { + i_Width = Application.GetRealWidth(i_Width); + i_Height = Application.GetRealHeight(i_Height); } this.Height = i_Height; - this.Width = i_Width; - } - - /// <summary> - /// 鍒濆鍖栨帶浠跺ぇ灏�(涓嶄互骞冲潎鍊艰繘琛岀湡瀹炴暟鍊艰绠�) - /// </summary> + this.Width = i_Width; + } + + /// <summary> + /// 鍒濆鍖栨帶浠跺ぇ灏�(涓嶄互骞冲潎鍊艰繘琛岀湡瀹炴暟鍊艰绠�) + /// </summary> /// <param name="i_Width">瀹藉害</param> - /// <param name="real">鏄惁璁$畻鐪熷疄鍊�</param> - public void InitSize(int i_Width, bool real = false) - { - if (real == true) - { - i_Width = Application.GetRealWidth(i_Width); + /// <param name="real">鏄惁璁$畻鐪熷疄鍊�</param> + public void InitSize(int i_Width, bool real = false) + { + if (real == true) + { + i_Width = Application.GetRealWidth(i_Width); } this.Height = ControlCommonResourse.NormalControlHeight; - this.Width = i_Width; - } - - /// <summary> - /// 鍒濆鍖栨帶浠跺ぇ灏�(浠ュ钩鍧囧�艰繘琛岀湡瀹炴暟鍊艰绠�) - /// </summary> + this.Width = i_Width; + } + + /// <summary> + /// 鍒濆鍖栧浘鏍囨帶浠跺ぇ灏�(浠ュ钩鍧囧�艰繘琛岀湡瀹炴暟鍊艰绠�) + /// </summary> /// <param name="i_Width">瀹藉害</param> /// <param name="i_Height">楂樺害</param> - /// <param name="real">鏄惁璁$畻鐪熷疄鍊�</param> - public void InitAvgSize(int i_Width, int i_Height, bool real = true) - { - if (real == true) - { - i_Width = Application.GetMinRealAverage(i_Width); - i_Height = Application.GetMinRealAverage(i_Height); + /// <param name="real">鏄惁璁$畻鐪熷疄鍊�</param> + public void InitIconSize(int i_Width, int i_Height, bool real = true) + { + if (real == true) + { + i_Width = this.GetPictrueRealSize(i_Width); + i_Height = this.GetPictrueRealSize(i_Height); } this.Height = i_Height; - this.Width = i_Width; - } - - #endregion - - #region 鈻� 鐐瑰嚮浜嬩欢___________________________ - - /// <summary> - /// 鐐瑰嚮浜嬩欢 - /// </summary> - /// <param name="sender"></param> - /// <param name="e"></param> - private void ButtonBase_MouseUpEventHandler(object sender, MouseEventArgs e) - { - if (ButtonClickEvent == null) - { - this.MouseUpEventHandler -= ButtonBase_MouseUpEventHandler; - return; - } - if (CanClick == true) - { - //Log鍑哄姏 - this.WriteLog(); - - try - { - this.ButtonClickEvent?.Invoke(this, e); - } - catch (Exception ex) - { - //鍑虹幇鏈煡閿欒,鏁版嵁涓㈠け - var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnknownErrorAndDataLost)); - alert.Show(); - //Log鍑哄姏 - string msg = ex.Message + "\r\n"; - msg += ex.TargetSite.ToString(); - HdlLogLogic.Current.WriteLog(-1, msg); - } - } - } - - #endregion - - #region 鈻� 璁剧疆鐐瑰嚮鐘舵�乢______________________ - - /// <summary> - /// 璁剧疆鐐瑰嚮鍚庣殑鐘舵��(姝ゆ柟娉曠敱鍚勮嚜鎺т欢杩涜閲嶈浇) - /// </summary> - public virtual void SetClickStatu() - { - } - - /// <summary> - /// 璁剧疆闈炵偣鍑诲悗鐨勭姸鎬�(姝ゆ柟娉曠敱鍚勮嚜鎺т欢杩涜閲嶈浇) - /// </summary> - public virtual void SetNotClickStatu() - { - } - - #endregion - - #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; - base.RemoveFromParent(); - } - - /// <summary> - /// Y杞撮噸缃�(鐪熷疄鏁板��,娌℃湁鐖跺鍣ㄦ棤鏁�) - /// </summary> - /// <param name="alignment">涓婁笅瀵归綈鏂瑰紡</param> - /// <param name="Space">涓婁笅涓ら儴鍒嗙殑闂磋窛</param> - public void ReSetYaxis(UViewAlignment alignment, int Space = 0) - { - if (this.Parent == null) - { - return; - } - //Y杞撮噸缃� - this.Y = UserCenterLogic.GetControlChidrenYaxis(this.Parent.Height, this.Height, alignment, Space); - } - - /// <summary> - /// 鏍规嵁鏂囨湰,璁$畻瀹冨疄闄呯殑瀹藉害(杩斿洖鐨勬槸鐪熷疄鍊�) - /// </summary> - /// <param name="textSize">瀛椾綋澶у皬,鐪佺暐鏃朵娇鐢ㄥ綋鍓嶆帶浠剁殑瀛椾綋澶у皬</param> - /// <param name="i_text">闇�瑕佽绠楃殑鏂囨湰淇℃伅,鐪佺暐鏃朵娇鐢ㄥ綋鍓嶆帶浠剁殑鏂囨湰</param> - /// <returns></returns> - public int GetRealWidthByText(float textSize, string i_text = null) - { - 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); - } - - #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 - } -} + this.Width = i_Width; + } + + /// <summary> + /// 鍒濆鍖栧浘鐗囨帶浠跺ぇ灏� + /// </summary> + /// <param name="i_Width">瀹藉害</param> + /// <param name="i_Height">楂樺害</param> + /// <param name="real">鏄惁璁$畻鐪熷疄鍊�</param> + public void InitPictrueSize(int i_Width, int i_Height, bool real = true) + { + if (real == true) + { + i_Width = HdlControlLogic.Current.GetPictrueRealSize(i_Width); + i_Height = HdlControlLogic.Current.GetPictrueRealSize(i_Height); + } + + this.Height = i_Height; + this.Width = i_Width; + } + + #endregion + + #region 鈻� 鐐瑰嚮浜嬩欢___________________________ + + /// <summary> + /// 鐐瑰嚮浜嬩欢 + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void ButtonBase_MouseUpEventHandler(object sender, MouseEventArgs e) + { + if (ButtonClickEvent == null) + { + this.MouseUpEventHandler -= ButtonBase_MouseUpEventHandler; + return; + } + //2020.05.14杩藉姞IsFormAdding:鐣岄潰杩樺湪鍔犺浇涓�,涓嶈兘鍐嶇偣鍑� + if (CanClick == true && ControlCommonResourse.IsFormAdding == false) + { + //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) + { + //璁板綍璧峰綋鍓嶇偣鍑荤殑鍧愭爣 + downPoint.X = (int)e.X; + downPoint.Y = (int)e.Y; + + 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); + } + } + + #endregion + + #region 鈻� 绉诲姩浜嬩欢___________________________ + + /// <summary> + /// 绉诲姩浜嬩欢 + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void ButtonBase_MouseMoveEventHandler(object sender, MouseEventArgs e) + { + if (this.ButtonHappenMoveEvent == null) + { + this.MouseMoveEventHandler -= ButtonBase_MouseMoveEventHandler; + return; + } + int value = (int)e.X - this.downPoint.X; + if (value >= 30 || value <= -30) + { + //瑙﹀彂绉诲姩浜嬩欢 + this.ButtonHappenMoveEvent(); + return; + } + value = (int)e.Y - this.downPoint.Y; + if (value >= 30 || value <= -30) + { + //瑙﹀彂绉诲姩浜嬩欢 + this.ButtonHappenMoveEvent(); + return; + } + } + + #endregion + + #region 鈻� 璁剧疆鐐瑰嚮鐘舵�乢______________________ + + /// <summary> + /// 璁剧疆鐐瑰嚮鍚庣殑鐘舵��(姝ゆ柟娉曠敱鍚勮嚜鎺т欢杩涜閲嶈浇) + /// </summary> + public virtual void SetClickStatu() + { + } + + /// <summary> + /// 璁剧疆闈炵偣鍑诲悗鐨勭姸鎬�(姝ゆ柟娉曠敱鍚勮嚜鎺т欢杩涜閲嶈浇) + /// </summary> + public virtual void SetNotClickStatu() + { + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 鎺т欢鎽ф瘉 + /// </summary> + public override void RemoveFromParent() + { + ButtonClickEvent = null; + ButtonDownClickEvent = null; + + if (this.Parent != null) + { + base.RemoveFromParent(); + } + } + + /// <summary> + /// 鏍规嵁鏂囨湰,璁$畻瀹冨疄闄呯殑瀹藉害 + /// </summary> + /// <returns></returns> + public int GetRealWidthByText() + { + if (string.IsNullOrEmpty(this.Text) == true) { return Application.GetRealWidth(25); } +#if Android + //闇�瑕佸鍔犱竴涓宸�� + return this.GetTextWidth() + Application.GetRealWidth(12); +#endif +#if iOS + //闇�瑕佸鍔犱竴涓宸�� + return this.GetTextWidth() + Application.GetRealWidth(25); +#endif + } + + /// <summary> + /// 璁$畻鍥剧墖鐨勭湡瀹為珮瀹藉害 + /// </summary> + /// <param name="i_size"></param> + /// <returns></returns> + public int GetPictrueRealSize(int i_size) + { + return HdlControlLogic.Current.GetPictrueRealSize(i_size); + } + + #endregion + + #region 鈻� Log鍑哄姏____________________________ + + /// <summary> + /// 璇ユ帶浠舵墍灞炵殑鐣岄潰鍚嶅瓧 + /// </summary> + public 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