using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone { /// /// FrameLayout的最初原型 /// public class FrameLayoutBase : FrameLayout { #region ■ 变量声明___________________________ /// /// 设置能否触点击事件 /// public bool CanClick = true; /// /// 声明此变量,旨在子线程也能够去获取一个控件的主键 /// public string MainKey = string.Empty; /// /// 控件的点击事件(自定义封装事件,此事件被认可为执行按钮按下事件,受CanClick属性控制) /// public Action ButtonClickEvent = null; #endregion #region ■ 初始化_____________________________ /// /// FrameLayout的最初原型 /// public FrameLayoutBase() { //点击事件 this.MouseUpEventHandler += ButtonBase_MouseUpEventHandler; } #endregion #region ■ 点击事件___________________________ /// /// 点击事件 /// /// /// private void ButtonBase_MouseUpEventHandler(object sender, MouseEventArgs e) { if (ButtonClickEvent == null) { this.MouseUpEventHandler -= ButtonBase_MouseUpEventHandler; return; } //2020.05.14追加IsFormAdding:界面还在加载中,不能再点击 if (CanClick == true && HdlControlResourse.IsFormAdding == false) { //Log出力 this.WriteLog(); try { this.ButtonClickEvent(this, e); } catch (Exception ex) { //出现未知错误 var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError)); alert.Show(); //Log出力 HdlLogLogic.Current.WriteLog(ex); } } } #endregion #region ■ 一般方法___________________________ /// /// 计算图片的真实高宽度 /// /// /// public int GetPictrueRealSize(int i_size) { return HdlControlLogic.Current.GetPictrueRealSize(i_size); } /// /// 控件摧毁 /// public override void RemoveFromParent() { ButtonClickEvent = null; if (this.Parent != null) { base.RemoveFromParent(); } } /// /// ☆☆移除全部控件☆☆ /// public override void RemoveAll() { if (this.Parent != null) { base.RemoveAll(); } } #endregion #region ■ Log出力____________________________ /// /// 该控件所属的界面名字 /// public string formName = null; /// /// Log出力 /// 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 + "的[Y" + this.Y + "]被点击"); } #endregion } }