| | |
| | | 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>
|
| | |
| | | this.MouseUpEventHandler += ButtonBase_MouseUpEventHandler;
|
| | | //按下事件
|
| | | this.MouseDownEventHandler += ButtonBase_MouseDownEventHandler;
|
| | | //长按事件
|
| | | this.MouseLongEventHandler += ButtonBase_MouseLongEventHandler;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | |
|
| | | try
|
| | | {
|
| | | if (this.isLongClick == false)
|
| | | {
|
| | | this.ButtonClickEvent(this, e);
|
| | | }
|
| | | else if (ButtonLongClickEvent != null)
|
| | | {
|
| | | //长按结束
|
| | | this.ButtonLongClickEvent(this, null);
|
| | | }
|
| | | this.ButtonClickEvent(this, e);
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | |
| | | HdlLogLogic.Current.WriteLog(ex);
|
| | | }
|
| | | }
|
| | | //状态还原
|
| | | this.isLongClick = false;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// <param name="e"></param>
|
| | | private void ButtonBase_MouseDownEventHandler(object sender, MouseEventArgs e)
|
| | | {
|
| | | //还原状态
|
| | | this.isLongClick = false;
|
| | |
|
| | | if (CanClick == false || this.ButtonDownClickEvent == null)
|
| | | {
|
| | | //不能点击
|
| | |
| | | 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);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | ButtonClickEvent = null;
|
| | | ButtonDownClickEvent = null;
|
| | | ButtonLongClickEvent = null;
|
| | |
|
| | | base.RemoveFromParent();
|
| | | }
|