黄学彪
2019-12-09 163777d8a2cb7cfa469f54a7042528870ebc10a3
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs
@@ -30,20 +30,18 @@
                else { this.SetClickStatu(); }
            }
        }
        /// <summary>
        /// 是否是长按状态
        /// 圆角度
        /// </summary>
        private bool isLongClick = false;
        public int RadiusEx
        {
            set { this.Radius = (uint)Application.GetRealHeight(value); }
        }
        /// <summary>
        /// 控件的点击事件(自定义封装事件,此事件被认可为执行按钮按下事件,受CanClick属性控制)
        /// </summary>
        public Action<Button, MouseEventArgs> ButtonClickEvent = null;
        /// <summary>
        /// (★当前不要使用★)控件的长按事件,当事件为null时,代表长按结束(自定义封装事件,此事件被认可为执行按钮长按事件,受CanClick属性控制)
        /// </summary>
        public Action<Button, MouseEventArgs> ButtonLongClickEvent = null;
        /// <summary>
        /// 控件的按下事件(自定义封装事件,此事件被认可为执行按钮按下事件,受CanClick属性控制)
        /// </summary>
@@ -68,8 +66,6 @@
            this.MouseUpEventHandler += ButtonBase_MouseUpEventHandler;
            //按下事件
            this.MouseDownEventHandler += ButtonBase_MouseDownEventHandler;
            //长按事件
            this.MouseLongEventHandler += ButtonBase_MouseLongEventHandler;
        }
        /// <summary>
@@ -146,15 +142,7 @@
                try
                {
                    if (this.isLongClick == false)
                    {
                        this.ButtonClickEvent(this, e);
                    }
                    else if (ButtonLongClickEvent != null)
                    {
                        //长按结束
                        this.ButtonLongClickEvent(this, null);
                    }
                    this.ButtonClickEvent(this, e);
                }
                catch (Exception ex)
                {
@@ -165,8 +153,6 @@
                    HdlLogLogic.Current.WriteLog(ex);
                }
            }
            //状态还原
            this.isLongClick = false;
        }
        #endregion
@@ -180,9 +166,6 @@
        /// <param name="e"></param>
        private void ButtonBase_MouseDownEventHandler(object sender, MouseEventArgs e)
        {
            //还原状态
            this.isLongClick = false;
            if (CanClick == false || this.ButtonDownClickEvent == null)
            {
                //不能点击
@@ -200,45 +183,6 @@
                alert.Show();
                //Log出力
                HdlLogLogic.Current.WriteLog(ex);
            }
        }
        #endregion
        #region ■ 长按事件___________________________
        /// <summary>
        /// 长按事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonBase_MouseLongEventHandler(object sender, MouseEventArgs e)
        {
            //长按状态
            this.isLongClick = true;
            if (ButtonLongClickEvent == null)
            {
                this.MouseLongEventHandler -= ButtonBase_MouseLongEventHandler;
                return;
            }
            if (CanClick == true)
            {
                //Log出力
                this.WriteLog(1);
                try
                {
                    this.ButtonLongClickEvent(this, e);
                }
                catch (Exception ex)
                {
                    //出现未知错误
                    var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError));
                    alert.Show();
                    //Log出力
                    HdlLogLogic.Current.WriteLog(ex);
                }
            }
        }
@@ -271,7 +215,6 @@
        {
            ButtonClickEvent = null;
            ButtonDownClickEvent = null;
            ButtonLongClickEvent = null;
            base.RemoveFromParent();
        }