From 9904031f5291daaf56985146bb671f25e18ebbdf Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期四, 02 四月 2020 19:51:31 +0800 Subject: [PATCH] 最新代码 --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 52 insertions(+), 1 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 52af78a..b4aea46 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs @@ -39,6 +39,11 @@ } /// <summary> + /// 鐐瑰嚮鐨勫潗鏍� + /// </summary> + private System.Drawing.Point downPoint = new System.Drawing.Point(); + + /// <summary> /// 鎺т欢鐨勭偣鍑讳簨浠�(鑷畾涔夊皝瑁呬簨浠�,姝や簨浠惰璁ゅ彲涓烘墽琛屾寜閽寜涓嬩簨浠�,鍙桟anClick灞炴�ф帶鍒�) /// </summary> public Action<Button, MouseEventArgs> ButtonClickEvent = null; @@ -46,6 +51,10 @@ /// 鎺т欢鐨勬寜涓嬩簨浠�(鑷畾涔夊皝瑁呬簨浠�,姝や簨浠惰璁ゅ彲涓烘墽琛屾寜閽寜涓嬩簨浠�,鍙桟anClick灞炴�ф帶鍒�) /// </summary> public Action<Button, MouseEventArgs> ButtonDownClickEvent = null; + /// <summary> + /// 鎺т欢瑙﹀彂绉诲姩鐨勪簨浠�(鑷韩鎷ユ湁绠楁硶,褰撶Щ鍔ㄥ灏戝儚绱犲悗,瑙﹀彂浜嬩欢,娉ㄦ剰,璇ヤ簨浠跺彲鑳戒細棰戠箒鐨勮Е鍙�) + /// </summary> + public Action ButtonHappenMoveEvent = null; #endregion @@ -66,6 +75,8 @@ this.MouseUpEventHandler += ButtonBase_MouseUpEventHandler; //鎸変笅浜嬩欢 this.MouseDownEventHandler += ButtonBase_MouseDownEventHandler; + //绉诲姩浜嬩欢 + this.MouseMoveEventHandler += ButtonBase_MouseMoveEventHandler; } /// <summary> @@ -166,6 +177,10 @@ /// <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) { //涓嶈兘鐐瑰嚮 @@ -183,6 +198,38 @@ 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; } } @@ -216,7 +263,10 @@ ButtonClickEvent = null; ButtonDownClickEvent = null; - base.RemoveFromParent(); + if (this.Parent != null) + { + base.RemoveFromParent(); + } } /// <summary> @@ -240,6 +290,7 @@ /// <returns></returns> public int GetRealWidthByText() { + if (string.IsNullOrEmpty(this.Text) == true) { return Application.GetRealWidth(25); } #if Android //闇�瑕佸鍔犱竴涓宸�� return this.GetTextWidth() + Application.GetRealWidth(12); -- Gitblit v1.8.0