From fe3b2466c68b5db70d38e78039703add3b8b1dfe Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 31 十二月 2020 19:29:43 +0800
Subject: [PATCH] 合并了代码

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/FrameLayoutControls/FrameLayoutStatuControl.cs |  366 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 366 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/FrameLayoutControls/FrameLayoutStatuControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/FrameLayoutControls/FrameLayoutStatuControl.cs
new file mode 100644
index 0000000..32a5655
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/FrameLayoutControls/FrameLayoutStatuControl.cs
@@ -0,0 +1,366 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shared.Phone.UserCenter
+{
+    /// <summary>
+    /// 鍋氭垚涓�涓偣鍑诲悗鑳藉鏄剧ず鐐瑰嚮鐘舵�佺殑鎺т欢(鍩哄眰鎺т欢)
+    /// </summary>
+    public class FrameLayoutStatuControl : FrameLayoutBase
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// 鐘舵�佽缃殑浜嬩欢(浼氶噸杞藉簳灞傛晥鏋�)
+        /// </summary>
+        public Action<bool> SelectStatuEvent;
+        /// <summary>
+        /// 鏄惁鍚敤鐐逛寒鍔熻兘(榛樿鍚敤)
+        /// </summary>
+        public bool UseClickStatu = true;
+        /// <summary>
+        /// 鍘熸潵鐨勮儗鏅壊
+        /// </summary>
+        private uint oldBackColor = 0;
+        /// <summary>
+        /// 褰撳墠鏄惁宸茬粡澶勪簬閫夋嫨鐘舵��
+        /// </summary>
+        private bool IsSelectStatu = false;
+        /// <summary>
+        /// 瀛愭帶浠禮杞村亸绉婚噺(鍏遍�氬畾涔夎�屽凡)
+        /// </summary>
+        public int chidrenYaxis = 0;
+        /// <summary>
+        /// 鍦嗚搴�
+        /// </summary>
+        public int RadiusEx
+        {
+            set { this.Radius = (uint)Application.GetRealHeight(value); }
+        }
+
+        #endregion
+
+        #region 鈻� 鍒濆鍖朹____________________________
+
+        /// <summary>
+        /// 鍋氭垚涓�涓偣鍑诲悗鑳藉鏄剧ず鐐瑰嚮鐘舵�佺殑鎺т欢
+        /// </summary>
+        /// <param name="i_ChidrenYaxis">瀛愭帶浠禮杞村亸绉婚噺(銆愬垪琛ㄦ帶浠剁殑rowSpace/2銆戝嵆鍙�,涓嶆噦榛樿涓�0鍗冲彲)</param>
+        public FrameLayoutStatuControl(int i_ChidrenYaxis = 0)
+        {
+            this.chidrenYaxis = i_ChidrenYaxis;
+
+            //缃┖搴曞眰鐨勪簨浠�
+            this.MouseUpEventHandler = null;
+            this.MouseUpEventHandler += ChildrenUpEvent;
+            this.MouseDownEventHandler += ChildrenDownEvent;
+        }
+
+        #endregion
+
+        #region 鈻� 缁戝畾浜嬩欢___________________________
+
+        /// <summary>
+        /// 鍙樻洿瀛愭帶浠剁殑缁戝畾妯″紡
+        /// </summary>
+        /// <param name="view">瀛愭帶浠�</param>
+        /// <param name="chidrenBindMode">鍙樻洿鐨勭粦瀹氭ā寮�</param>
+        public void ChangedChidrenBindMode(View view, ChidrenBindMode chidrenBindMode)
+        {
+            if (view is ButtonBase)
+            {
+                //瀛愭帶浠剁Щ闄や簨浠�
+                ButtonBase button = (ButtonBase)view;
+                button.ButtonClickEvent -= ChildrenUpEvent;
+                button.MouseDownEventHandler -= ChildrenDownEvent;
+
+                this.BindChidrenEvent(view, chidrenBindMode);
+            }
+            else if (view is ImageView)
+            {
+                view.MouseUpEventHandler -= ChildrenUpEvent;
+                view.MouseDownEventHandler -= ChildrenDownEvent;
+
+                this.BindChidrenEvent(view, chidrenBindMode);
+            }
+            else if (view is ViewGroup)
+            {
+                ViewGroup groupContr = (ViewGroup)view;
+                for (int i = 0; i < groupContr.ChildrenCount; i++)
+                {
+                    var myView = groupContr.GetChildren(i);
+                    if (myView == null)
+                    {
+                        break;
+                    }
+                    if (myView is ButtonBase)
+                    {
+                        //瀛愭帶浠剁Щ闄や簨浠�
+                        ButtonBase button = (ButtonBase)myView;
+                        button.ButtonClickEvent -= ChildrenUpEvent;
+                        button.MouseDownEventHandler -= ChildrenDownEvent;
+                    }
+                }
+                //鑷韩绉婚櫎浜嬩欢
+                groupContr.MouseUpEventHandler -= ChildrenUpEvent;
+                groupContr.MouseDownEventHandler -= ChildrenDownEvent;
+
+                this.BindChidrenEvent(view, chidrenBindMode);
+            }
+        }
+
+        /// <summary>
+        /// 缁戝畾瀛愭帶浠朵簨浠�(濡傛灉鏄鍚堟帶浠�,鍦ㄥ垵濮嬪寲瀹屾垚鍚�,璋冪敤ChangedChidrenBindMode)
+        /// </summary>
+        /// <param name="view"></param>
+        /// <param name="chidrenBindMode"></param>
+        private void BindChidrenEvent(View view, ChidrenBindMode chidrenBindMode)
+        {
+            if (chidrenBindMode == ChidrenBindMode.NotBind)
+            {
+                return;
+            }
+            if (view is ButtonBase)
+            {
+                //涓哄瓙鎺т欢娣诲姞浜嬩欢
+                ButtonBase button = (ButtonBase)view;
+                button.ButtonClickEvent -= ChildrenUpEvent;
+                button.MouseDownEventHandler -= ChildrenDownEvent;
+
+                button.ButtonClickEvent += ChildrenUpEvent;
+                button.MouseDownEventHandler += ChildrenDownEvent;
+            }
+            else if (view is ImageView)
+            {
+                //鑷韩涔熸坊鍔犱簨浠�
+                view.MouseUpEventHandler -= ChildrenUpEvent;
+                view.MouseDownEventHandler -= ChildrenDownEvent;
+
+                view.MouseUpEventHandler += ChildrenUpEvent;
+                view.MouseDownEventHandler += ChildrenDownEvent;
+            }
+            else if (view is ViewGroup)
+            {
+                //涓哄瓙鎺т欢娣诲姞浜嬩欢
+                ViewGroup groupContr = (ViewGroup)view;
+                for (int i = 0; i < groupContr.ChildrenCount; i++)
+                {
+                    var myView = groupContr.GetChildren(i);
+                    if (myView == null)
+                    {
+                        break;
+                    }
+                    if (myView is ButtonBase)
+                    {
+                        //涓哄瓙鎺т欢娣诲姞浜嬩欢
+                        ButtonBase button = (ButtonBase)myView;
+                        button.ButtonClickEvent -= ChildrenUpEvent;
+                        button.MouseDownEventHandler -= ChildrenDownEvent;
+
+                        button.ButtonClickEvent += ChildrenUpEvent;
+                        button.MouseDownEventHandler += ChildrenDownEvent;
+                    }
+                }
+                //鑷韩涔熸坊鍔犱簨浠�
+                groupContr.MouseUpEventHandler -= ChildrenUpEvent;
+                groupContr.MouseDownEventHandler -= ChildrenDownEvent;
+
+                groupContr.MouseUpEventHandler += ChildrenUpEvent;
+                groupContr.MouseDownEventHandler += ChildrenDownEvent;
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 娣诲姞瀛愭帶浠禵________________________
+
+        /// <summary>
+        /// 娣诲姞瀛愭帶浠�
+        /// </summary>
+        /// <param name="view">瀛愭帶浠�</param>
+        /// <param name="chidrenBindMode">缁戝畾妯″紡</param>
+        public void AddChidren(View view, ChidrenBindMode chidrenBindMode = ChidrenBindMode.BindEvent)
+        {
+            this.oldBackColor = this.BackgroundColor;
+
+            base.AddChidren(view);
+
+            //缁戝畾瀛愭帶浠朵簨浠�
+            this.BindChidrenEvent(view, chidrenBindMode);
+        }
+
+        /// <summary>
+        /// 娣诲姞瀛愭帶浠�
+        /// </summary>
+        /// <param name="view"></param>
+        public override void AddChidren(View view)
+        {
+            this.AddChidren(view, ChidrenBindMode.NotBind);
+        }
+
+        #endregion
+
+        #region 鈻� 鎺т欢浜嬩欢___________________________
+
+        /// <summary>
+        /// 鐐瑰嚮鎸変笅浜嬩欢(鐐逛寒)
+        /// </summary>
+        /// <param name="sender">Sender.</param>
+        /// <param name="e">E.</param>
+        private void ChildrenDownEvent(object sender, MouseEventArgs e)
+        {
+            if (this.UseClickStatu == false || this.CanClick == false)
+            {
+                return;
+            }
+            this.StartSelectStatuAppeal(ControlCommonResourse.StatuChangedWaitTime);
+        }
+
+        /// <summary>
+        /// 鐐瑰嚮鏉惧紑浜嬩欢
+        /// </summary>
+        /// <param name="sender">Sender.</param>
+        /// <param name="e">E.</param>
+        private void ChildrenUpEvent(object sender, MouseEventArgs e)
+        {
+            if (this.CanClick == false)
+            {
+                //涓嶅厑璁哥偣鍑�
+                return;
+            }
+            if (sender is FrameLayoutStatuControl)
+            {
+                //LOG鍑哄姏
+                this.WriteLog();
+            }
+            try
+            {
+                //璋冪敤濮旀墭
+                ButtonClickEvent?.Invoke(sender, 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>
+        public void SetClickNotSelectStatu()
+        {
+            this.IsSelectStatu = false;
+            if (this.SelectStatuEvent != null)
+            {
+                this.SelectStatuEvent(false);
+                return;
+            }
+
+            this.BackgroundColor = this.oldBackColor;
+        }
+
+        /// <summary>
+        /// 璁剧疆鍗曞嚮鏃剁殑鐘舵��
+        /// </summary>
+        public void SetClickSelectStatu()
+        {
+            this.IsSelectStatu = true;
+            if (this.SelectStatuEvent != null)
+            {
+                this.SelectStatuEvent(true);
+                return;
+            }
+
+            this.BackgroundColor = UserCenterColor.Current.RowSelectBackColor;
+        }
+
+        #endregion
+
+        #region 鈻� 涓�鑸柟娉昣__________________________
+
+        /// <summary>
+        /// 寮哄埗瀹炴柦鎺т欢閫変腑鐘舵�佺殑鐗规晥
+        /// </summary>
+        /// <param name="waiTime"></param>
+        public void StartSelectStatuAppeal(int waiTime)
+        {
+            if (this.IsSelectStatu == true)
+            {
+                return;
+            }
+            this.IsSelectStatu = true;
+
+            //璁剧疆閫夋嫨鐘舵��
+            this.SetClickSelectStatu();
+            HdlThreadLogic.Current.RunThread(() =>
+            {
+                System.Threading.Thread.Sleep(waiTime);
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    //璁剧疆涓嶉�夋嫨鐘舵��
+                    this.SetClickNotSelectStatu();
+                });
+            });
+        }
+
+        /// <summary>
+        /// 绉婚櫎搴曞眰鎺т欢鑷韩鐨勫崟鍑讳簨浠�
+        /// </summary>
+        public void RemoveBaseClickEvent()
+        {
+            this.MouseUpEventHandler -= ChildrenUpEvent;
+            this.MouseDownEventHandler -= ChildrenDownEvent;
+        }
+
+        /// <summary>
+        /// 鎺т欢鎽ф瘉
+        /// </summary>
+        public override void RemoveFromParent()
+        {
+            this.SelectStatuEvent = null;
+
+            base.RemoveFromParent();
+        }
+
+        #endregion
+
+        #region 鈻� Log鍑哄姏____________________________
+
+        /// <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;
+                }
+            }
+            HdlLogLogic.Current.WriteLog(1, formName + ".FrameLayoutControl 琚偣鍑�");
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.8.0