public void HideMessage() { if (null != ownerContainer) { UXMessageMask.HideMessage(ownerContainer); } }
/// <summary> /// 显示表单 /// </summary> /// <param name="ownerContainer">所属容器</param> /// <param name="form">表单控件</param> public static void ShowForm(Control ownerContainer, Control form) { HideMessage(ownerContainer); var msgPnl = new UXMessageMask() { Name = "msgPnl" }; msgPnl.Left = 0; msgPnl.Top = 0; msgPnl.Width = ownerContainer.Width; msgPnl.Height = ownerContainer.Height; msgPnl.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; ownerContainer.Controls.Add(msgPnl); msgPnl.BringToFront(); var x = (ownerContainer.Width - form.Width) / 2; var y = (ownerContainer.Height - form.Height) / 2; form.Location = new Point(x, y); msgPnl.Controls.Add(form); form.Disposed += (obj, args) => { HideMessage(ownerContainer); }; }
public void ShowMessage(bool isModal, string msg, MessageBoxButtonsType btnType, MessageBoxIcon boxIcon , Action okAction = null, Action cancelAction = null, Action noAction = null) { if (null != ownerContainer) { UXMessageMask.ShowMessage(ownerContainer, isModal, msg, btnType, boxIcon, okAction, cancelAction, noAction); } }
/// <summary> /// 显示消息 /// </summary> /// <param name="ownerContainer">所属容器</param> /// <param name="isModal">是否模态框显示</param> /// <param name="msg">消息</param> /// <param name="btnType">按钮类型</param> /// <param name="boxIcon">图标</param> /// <param name="okAction">ok回调</param> /// <param name="cancelAction">cancel回调</param> /// <param name="noAction">no回调</param> public static void ShowMessage(Control ownerContainer, bool isModal, string msg, MessageBoxButtonsType btnType, MessageBoxIcon boxIcon , Action okAction = null, Action cancelAction = null, Action noAction = null) { HideMessage(ownerContainer); var msgPnl = new UXMessageMask() { Name = "msgPnl" }; msgPnl.Left = 0; msgPnl.Top = 0; msgPnl.Width = ownerContainer.Width; msgPnl.Height = ownerContainer.Height; msgPnl.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; ownerContainer.Controls.Add(msgPnl); msgPnl.BringToFront(); if (isModal) { var win = new UXMessageWindow() { Message = msg, MessageBoxButtonsType = btnType, MessageBoxIcon = boxIcon, OKAction = okAction, CancelAction = cancelAction, NoAction = noAction, Owner = ownerContainer.FindForm() }; win.FormClosed += (sender, args) => { HideMessage(ownerContainer); }; win.ShowDialog(); } else { var msgBox = new UXMessagePanel() { Message = msg, MessageBoxButtonsType = btnType, MessageBoxIcon = boxIcon, OKAction = okAction, CancelAction = cancelAction, NoAction = noAction }; var x = (ownerContainer.Width - msgBox.Width) / 2; var y = (ownerContainer.Height - msgBox.Height) / 2; msgBox.Location = new Point(x, y); msgBox.Disposed += (obj, args) => { HideMessage(ownerContainer); }; msgPnl.Controls.Add(msgBox); } }