public void UserMsgBox(MsgBox.MsgTypes msgType, string msg) { Form owner = SharedObjects.MainWin; MsgBox.MsgButtons msgButtons = MsgButtons.Ok; MsgBox.MsgResult defaultMsgResult = MsgBox.MsgResult.OK; int num = (int)UserMsgBox(owner, msgType, msgButtons, defaultMsgResult, msg); }
private void ClearTxQueueQuestion() { int qlength = dataQ.GetQLength(); if (qlength > 0) { string msg = "There Are " + qlength.ToString() + " Pending Transmit Messages\nDo You Want To Clear All Pending Transmit Messages?\n"; if (DisplayMsgCallback != null) { DisplayMsgCallback(SharedAppObjs.MsgType.Warning, msg); } MsgBox.MsgResult msgResult = msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Warning, MsgBox.MsgButtons.YesNo, MsgBox.MsgResult.Yes, msg); if (DisplayMsgCallback != null) { DisplayMsgCallback(SharedAppObjs.MsgType.Info, "UserResponse = " + msgResult.ToString() + "\n"); } if (msgResult == MsgBox.MsgResult.Yes) { dataQ.ClearQ(); } } }
public MsgBox.MsgResult UserMsgBox(Form owner, MsgBox.MsgTypes msgType, MsgBox.MsgButtons msgButtons, MsgBox.MsgResult defaultMsgResult, string msg) { MsgBox.MsgResult msgResult = MsgBox.MsgResult.OK; try { if (SharedObjects.MainWin.InvokeRequired) { try { msgResult = (MsgBox.MsgResult)SharedObjects.MainWin.Invoke((Delegate) new MsgBox.UserMsgBoxDelegate(UserMsgBox), owner, msgType, msgButtons, defaultMsgResult, msg); } catch { } } else { string text = "UserMsgBox Called With No Message!\n"; if (msg != null && msg.Length > 0) { text = msg; } if (MsgBox.useConsoleMode) { WriteLogMsg(msgType, msg); msgResult = defaultMsgResult; } else { MessageBoxButtons buttons; switch (msgButtons) { case MsgButtons.Ok: buttons = MessageBoxButtons.OK; break; case MsgButtons.OkCancel: buttons = MessageBoxButtons.OKCancel; break; case MsgButtons.AbortRetryIgnore: buttons = MessageBoxButtons.AbortRetryIgnore; break; case MsgButtons.YesNoCancel: buttons = MessageBoxButtons.YesNoCancel; break; case MsgButtons.YesNo: buttons = MessageBoxButtons.YesNo; break; case MsgButtons.RetryCancel: buttons = MessageBoxButtons.RetryCancel; break; default: buttons = MessageBoxButtons.OK; break; } string msgBoxTitle = GetMsgBoxTitle(msgType); MessageBoxIcon icon; switch (msgType) { case MsgBox.MsgTypes.Fatal: icon = MessageBoxIcon.Hand; break; case MsgBox.MsgTypes.Error: icon = MessageBoxIcon.Hand; break; case MsgBox.MsgTypes.Warning: icon = MessageBoxIcon.Exclamation; break; case MsgBox.MsgTypes.Info: icon = MessageBoxIcon.Asterisk; break; default: icon = MessageBoxIcon.Hand; break; } if (MsgBox.useLoggingMode) { WriteLogMsg(msgType, msg); } MsgBox.msgBoxDisplayed = true; msgResult = owner != null ? (MsgBox.MsgResult)MessageBox.Show((IWin32Window)owner, text, msgBoxTitle, buttons, icon) : (MsgBox.MsgResult)MessageBox.Show(text, msgBoxTitle, buttons, icon); MsgBox.msgBoxDisplayed = false; } if (msgType == MsgBox.MsgTypes.Fatal) { sharedObjs.ApplicationExit(1); } } } catch { } return(msgResult); }