From 2450c12c825ad4d78d1572da2fa421706db2df2f Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 18 六月 2020 16:01:14 +0800
Subject: [PATCH] 新代码

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs |  145 +++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 123 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 52af78a..3a2334a 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs
@@ -17,7 +17,7 @@
         private bool m_CanClick = true;
         /// <summary>
         /// 璁剧疆鑳藉惁瑙︾偣鍑讳簨浠�
-        /// </summary>
+        /// </summary>
         public bool CanClick
         {
             get { return m_CanClick; }
@@ -37,6 +37,15 @@
         {
             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灞炴�ф帶鍒�)
@@ -46,6 +55,27 @@
         /// 鎺т欢鐨勬寜涓嬩簨浠�(鑷畾涔夊皝瑁呬簨浠�,姝や簨浠惰璁ゅ彲涓烘墽琛屾寜閽寜涓嬩簨浠�,鍙桟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
 
@@ -66,13 +96,15 @@
             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="i_Width">瀹藉害</param>
+        /// <param name="i_Height">楂樺害</param>
         /// <param name="real">鏄惁璁$畻鐪熷疄鍊�</param>
         public void InitSize(int i_Width, int i_Height, bool real = true)
         {
@@ -80,42 +112,60 @@
             {
                 i_Width = Application.GetRealWidth(i_Width);
                 i_Height = Application.GetRealHeight(i_Height);
-            }
-            this.Height = i_Height;
+            }
+            this.Height = i_Height;
             this.Width = i_Width;
         }
 
         /// <summary>
         /// 鍒濆鍖栨帶浠跺ぇ灏�(涓嶄互骞冲潎鍊艰繘琛岀湡瀹炴暟鍊艰绠�)
         /// </summary>
-        /// <param name="i_Width">瀹藉害</param>
+        /// <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);
-            }
-
-            this.Height = ControlCommonResourse.NormalControlHeight;
+            }
+
+            this.Height = ControlCommonResourse.NormalControlHeight;
             this.Width = i_Width;
         }
 
         /// <summary>
-        /// 鍒濆鍖栨帶浠跺ぇ灏�(浠ュ钩鍧囧�艰繘琛岀湡瀹炴暟鍊艰绠�)
+        /// 鍒濆鍖栧浘鏍囨帶浠跺ぇ灏�(浠ュ钩鍧囧�艰繘琛岀湡瀹炴暟鍊艰绠�)
         /// </summary>
-        /// <param name="i_Width">瀹藉害</param>
-        /// <param name="i_Height">楂樺害</param>
+        /// <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)
+        public void InitIconSize(int i_Width, int i_Height, bool real = true)
         {
             if (real == true)
             {
-                i_Width = Application.GetMinRealAverage(i_Width);
-                i_Height = Application.GetMinRealAverage(i_Height);
-            }
-
-            this.Height = i_Height;
+                i_Width = this.GetPictrueRealSize(i_Width);
+                i_Height = this.GetPictrueRealSize(i_Height);
+            }
+
+            this.Height = i_Height;
+            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;
         }
 
@@ -135,7 +185,8 @@
                 this.MouseUpEventHandler -= ButtonBase_MouseUpEventHandler;
                 return;
             }
-            if (CanClick == true)
+            //2020.05.14杩藉姞IsFormAdding:鐣岄潰杩樺湪鍔犺浇涓�,涓嶈兘鍐嶇偣鍑�
+            if (CanClick == true && ControlCommonResourse.IsFormAdding == false)
             {
                 //Log鍑哄姏
                 this.WriteLog(0);
@@ -166,6 +217,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 +238,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 +303,10 @@
             ButtonClickEvent = null;
             ButtonDownClickEvent = null;
 
-            base.RemoveFromParent();
+            if (this.Parent != null)
+            {
+                base.RemoveFromParent();
+            }
         }
 
         /// <summary>
@@ -231,7 +321,7 @@
                 return;
             }
             //Y杞撮噸缃�
-            this.Y = UserCenterLogic.GetControlChidrenYaxis(this.Parent.Height, this.Height, alignment, Space);
+            this.Y = HdlControlLogic.Current.GetControlChidrenYaxis(this.Parent.Height, this.Height, alignment, Space);
         }
 
         /// <summary>
@@ -240,6 +330,7 @@
         /// <returns></returns>
         public int GetRealWidthByText()
         {
+            if (string.IsNullOrEmpty(this.Text) == true) { return Application.GetRealWidth(25); }
 #if Android
             //闇�瑕佸鍔犱竴涓宸��
             return this.GetTextWidth() + Application.GetRealWidth(12);
@@ -250,6 +341,16 @@
 #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鍑哄姏____________________________
@@ -257,7 +358,7 @@
         /// <summary>
         /// 璇ユ帶浠舵墍灞炵殑鐣岄潰鍚嶅瓧
         /// </summary>
-        private string formName = null;
+        public string formName = null;
         /// <summary>
         /// 鎺т欢鍚嶅瓧
         /// </summary>

--
Gitblit v1.8.0