黄学彪
2019-10-10 2ed75b8b337048e5d75e6d9ec8307633134f02fd
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/ButtonBase.cs
@@ -124,7 +124,23 @@
            }
            if (CanClick == true)
            {
                this.ButtonClickEvent?.Invoke(this, e);
                //Log出力
                this.WriteLog();
                try
                {
                    this.ButtonClickEvent?.Invoke(this, e);
                }
                catch (Exception ex)
                {
                    //出现未知错误,数据丢失
                    var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnknownErrorAndDataLost));
                    alert.Show();
                    //Log出力
                    string msg = ex.Message + "\r\n";
                    msg += ex.TargetSite.ToString();
                    HdlLogLogic.Current.WriteLog(-1, msg);
                }
            }
        }
@@ -218,6 +234,68 @@
            return Application.GetRealWidth(realWidth);
        }
        /// <summary>
        /// 添加底部阴影特效(确保拥有父控件后才调用)
        /// </summary>
        public void AddBottomShadow()
        {
            var btnShadow = new PicViewControl(this.Width, Application.GetMinRealAverage(45), false);
            btnShadow.X = this.X;
            btnShadow.Y = this.Bottom - 1;
            btnShadow.UnSelectedImagePath = "Item/BottomShadow.png";
            this.Parent.AddChidren(btnShadow);
        }
        #endregion
        #region ■ Log出力____________________________
        /// <summary>
        /// 该控件所属的界面名字
        /// </summary>
        private string formName = null;
        /// <summary>
        /// 控件名字
        /// </summary>
        private string controlName = null;
        /// <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;
                }
                if (string.IsNullOrEmpty(this.Text) == false)
                {
                    //这个控件的文本
                    controlName = this.Text;
                }
                else
                {
                    //如果没有文本的话,它应该是一张图片
                    controlName = this.UnSelectedImagePath;
                }
            }
            HdlLogLogic.Current.WriteLog(1, formName + "的[" + controlName + "]按键被点击");
        }
        #endregion
    }
}