/// <summary> /// 显示提示框 /// </summary> /// <param name="frm">父窗体</param> /// <param name="result">校验结果</param> /// <param name="action">回调方法</param> /// <param name="intAutoColseTime">自动关闭倒计时(ms:毫秒)</param> /// <returns>FrmToastr.</returns> private static void ShowAlter(Form frm, ValidationResult result, Action <object> action, int intAutoColseTime = 0) { if (frmAlert != null) { ClearAlert(); } frmAlert = new FrmAlert(); frmAlert.ParentForm = frm; frmAlert.CallBackEvent = action; frmAlert.Size = new Size(350, 65); frmAlert.lblMsg.ForeColor = Color.Black; frmAlert.pctStat.Image = UC.Controls.Properties.Resources.Fail; frmAlert.BackColor = Color.White; frmAlert.lblMsg.Text = result.Errors.FirstOrDefault().ErrorMessage; frmAlert.CloseTime = intAutoColseTime; frmAlert.ValidateName = result.Errors.FirstOrDefault().PropertyName; frmAlert.Owner = frm; frmAlert.BringToFront(); frmAlert.Show(frm); lock (frmAlert) { if (frmAlert != null) { Size size = Screen.PrimaryScreen.Bounds.Size; frmAlert.Location = new Point((size.Width - frmAlert.Width) / 2, size.Height - (size.Height - (frmAlert.Height + 10)) / 2 - (frmAlert.Height + 10)); } } }
/// <summary> /// 警告提示框 /// </summary> /// <param name="frm">当前父窗体</param> /// <param name="strMsg">提示信息</param> /// <returns>FrmToastr.</returns> public static void Alert(Form frm, ValidationResult result, Action <object> action) { FrmAlert.ShowAlter(frm, result, action, 2000); }