| | |
| | | else { this.SetClickStatu(); }
|
| | | }
|
| | | }
|
| | | /// <summary>
|
| | | /// 圆角度
|
| | | /// </summary>
|
| | | public int RadiusEx
|
| | | {
|
| | | set { this.Radius = (uint)Application.GetRealHeight(value); }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 控件的点击事件(此事件被认可为执行按钮按下事件,受CanClick属性控制)
|
| | | /// 控件的点击事件(自定义封装事件,此事件被认可为执行按钮按下事件,受CanClick属性控制)
|
| | | /// </summary>
|
| | | public Action<Button, MouseEventArgs> ButtonClickEvent = null;
|
| | | /// <summary>
|
| | | /// 底部阴影控件1
|
| | | /// 控件的按下事件(自定义封装事件,此事件被认可为执行按钮按下事件,受CanClick属性控制)
|
| | | /// </summary>
|
| | | private Button btnBottomShadowView1 = null;
|
| | | /// <summary>
|
| | | /// 底部阴影控件2
|
| | | /// </summary>
|
| | | private Button btnBottomShadowView2 = null;
|
| | | public Action<Button, MouseEventArgs> ButtonDownClickEvent = null;
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | |
|
| | | //点击事件
|
| | | this.MouseUpEventHandler += ButtonBase_MouseUpEventHandler;
|
| | | //按下事件
|
| | | this.MouseDownEventHandler += ButtonBase_MouseDownEventHandler;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | if (CanClick == true)
|
| | | {
|
| | | //Log出力
|
| | | this.WriteLog();
|
| | | this.WriteLog(0);
|
| | |
|
| | | try
|
| | | {
|
| | | this.ButtonClickEvent?.Invoke(this, e);
|
| | | this.ButtonClickEvent(this, e);
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | |
| | | //Log出力
|
| | | HdlLogLogic.Current.WriteLog(ex);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 按下事件___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 按下事件
|
| | | /// </summary>
|
| | | /// <param name="sender"></param>
|
| | | /// <param name="e"></param>
|
| | | private void ButtonBase_MouseDownEventHandler(object sender, MouseEventArgs e)
|
| | | {
|
| | | if (CanClick == false || this.ButtonDownClickEvent == null)
|
| | | {
|
| | | //不能点击
|
| | | return;
|
| | | }
|
| | |
|
| | | try
|
| | | {
|
| | | this.ButtonDownClickEvent(this, e);
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | //出现未知错误
|
| | | var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError));
|
| | | alert.Show();
|
| | | //Log出力
|
| | | HdlLogLogic.Current.WriteLog(ex);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 重置单击事件(此操作委托会变null)
|
| | | /// </summary>
|
| | | public void ResetClickEvent()
|
| | | {
|
| | | ButtonClickEvent = null;
|
| | | this.MouseUpEventHandler -= this.ButtonBase_MouseUpEventHandler;
|
| | | this.MouseUpEventHandler += this.ButtonBase_MouseUpEventHandler;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 控件摧毁
|
| | | /// </summary>
|
| | | public override void RemoveFromParent()
|
| | | {
|
| | | ButtonClickEvent = null;
|
| | | ButtonDownClickEvent = null;
|
| | |
|
| | | base.RemoveFromParent();
|
| | | }
|
| | |
|
| | |
| | | return Application.GetRealWidth(realWidth + 20);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 添加底部阴影特效(确保拥有父控件后才调用)
|
| | | /// </summary>
|
| | | /// <param name="view">为哪个控件添加阴影特效,省略时,为当前控件添加</param>
|
| | | /// <param name="average">添加的阴影特效是否按平均值设置高宽度</param>
|
| | | public void AddBottomShadow(View view = null, bool average = false)
|
| | | {
|
| | | //需要扩大的高度
|
| | | int heightValue = 21;
|
| | | //需要扩大的宽度
|
| | | int widthValue = 15;
|
| | | //最大高度
|
| | | int maxHeight = 0;
|
| | | if (average == false)
|
| | | {
|
| | | heightValue = Application.GetRealHeight(heightValue);
|
| | | widthValue = Application.GetRealWidth(widthValue);
|
| | | maxHeight = Application.GetRealHeight(460);
|
| | | }
|
| | | else
|
| | | {
|
| | | heightValue = Application.GetMinRealAverage(heightValue);
|
| | | widthValue = Application.GetMinRealAverage(widthValue);
|
| | | maxHeight = Application.GetMinRealAverage(460);
|
| | | }
|
| | | if (view == null)
|
| | | {
|
| | | //省略时,指定为当前控件
|
| | | view = this;
|
| | | }
|
| | | //先移除
|
| | | this.btnBottomShadowView1?.RemoveFromParent();
|
| | | this.btnBottomShadowView2?.RemoveFromParent();
|
| | |
|
| | | int realHeight = view.Height + heightValue * 2;
|
| | | if (realHeight <= maxHeight)
|
| | | {
|
| | | //阴影控件
|
| | | this.btnBottomShadowView1 = new Button();
|
| | | btnBottomShadowView1.UnSelectedImagePath = "Item/BottomShadow.png";
|
| | | btnBottomShadowView1.Height = realHeight;
|
| | | btnBottomShadowView1.Width = view.Width + widthValue * 2;
|
| | | btnBottomShadowView1.X = view.X - widthValue;
|
| | | btnBottomShadowView1.Y = view.Y;
|
| | | view.Parent.AddChidren(btnBottomShadowView1);
|
| | | view.BringToFront();
|
| | | }
|
| | | else
|
| | | {
|
| | | //超过最大时,特殊处理
|
| | | this.btnBottomShadowView1 = new Button();
|
| | | btnBottomShadowView1.UnSelectedImagePath = "Item/BottomShadow.png";
|
| | | btnBottomShadowView1.Height = view.Height - heightValue * 2;
|
| | | btnBottomShadowView1.Width = view.Width + widthValue * 2;
|
| | | btnBottomShadowView1.X = view.X - widthValue;
|
| | | btnBottomShadowView1.Y = view.Y + heightValue * 2;
|
| | | view.Parent.AddChidren(btnBottomShadowView1);
|
| | |
|
| | | this.btnBottomShadowView2 = new Button();
|
| | | btnBottomShadowView2.UnSelectedImagePath = "Item/BottomShadow.png";
|
| | | btnBottomShadowView2.Height = maxHeight;
|
| | | btnBottomShadowView2.Width = view.Width + widthValue * 2;
|
| | | btnBottomShadowView2.X = view.X - widthValue;
|
| | | btnBottomShadowView2.Y = view.Bottom - maxHeight + heightValue * 2;
|
| | | view.Parent.AddChidren(btnBottomShadowView2);
|
| | | view.BringToFront();
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ Log出力____________________________
|
| | |
| | | /// <summary>
|
| | | /// Log出力
|
| | | /// </summary>
|
| | | private void WriteLog()
|
| | | private void WriteLog(int div)
|
| | | {
|
| | | if (formName == null)
|
| | | {
|
| | |
| | | controlName = this.UnSelectedImagePath;
|
| | | }
|
| | | }
|
| | | HdlLogLogic.Current.WriteLog(1, formName + "的[" + controlName + "]按键被点击");
|
| | | if (div == 0)
|
| | | {
|
| | | HdlLogLogic.Current.WriteLog(1, formName + "的[" + controlName + "]按键被点击");
|
| | | }
|
| | | else
|
| | | {
|
| | | HdlLogLogic.Current.WriteLog(1, formName + "的[" + controlName + "]按键被长按");
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|