/// <summary> /// Shows the Ok/Cancel list dialog. /// </summary> /// <param name="owner">The owner.</param> /// <param name="title">The title.</param> /// <param name="headerMessage">The header message.</param> /// <param name="listLines">The list lines.</param> /// <param name="footerMessage">The footer message.</param> /// <returns></returns> public bool ShowOkCancelList(IWin32Window owner, string title, string headerMessage, IList <string> listLines, string footerMessage) { Assert.ArgumentNotNullOrEmpty(title, nameof(title)); Assert.ArgumentNotNullOrEmpty(headerMessage, nameof(headerMessage)); Assert.ArgumentNotNull(listLines, nameof(listLines)); _msg.Info(headerMessage); string msg = MsgBase.ReplaceBreakTags(headerMessage); DialogResult result = ShowListBox(ChooseOwner(owner), title, msg, listLines, footerMessage, MessageBoxButtons.OKCancel, MessageBoxIcon.Question); _msg.DebugFormat("OK CANCEL List Dialog: {0}, '{1}'. Answer: '{2}'", msg, title, result); return(result == DialogResult.OK); }
/// <summary> /// Shows the error dialog. /// </summary> /// <param name="owner">The owner.</param> /// <param name="message">The message.</param> /// <param name="title">The title.</param> /// <param name="e">The exception.</param> /// <param name="msg">The message sink. Allows to log the error using the logger /// of the calling context.</param> public void ShowError(IWin32Window owner, string title, string message, Exception e, IMsg msg) { Assert.ArgumentNotNullOrEmpty(title, nameof(title)); Assert.ArgumentNotNullOrEmpty(message, nameof(message)); if (msg == null) { msg = _msg; } // write to log if (e != null) { msg.Error(message, e); } else { msg.Error(message); } Show(owner, MsgBase.ReplaceBreakTags(message), title, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); }
/// <summary> /// Shows the warning dialog. /// </summary> /// <param name="owner">The owner.</param> /// <param name="message">The message.</param> /// <param name="title">The title.</param> public void ShowWarning(IWin32Window owner, string title, string message) { Assert.ArgumentNotNullOrEmpty(title, nameof(title)); Assert.ArgumentNotNullOrEmpty(message, nameof(message)); _msg.Warn(message); Show(owner, MsgBase.ReplaceBreakTags(message), title, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); }
/// <summary> /// Shows the Yes/No/Cancel dialog. /// </summary> /// <param name="owner">The owner.</param> /// <param name="message">The message.</param> /// <param name="title">The title.</param> /// <param name="defaultResult">The default result.</param> /// <returns></returns> public YesNoCancelDialogResult ShowYesNoCancel(IWin32Window owner, string title, string message, YesNoCancelDialogResult defaultResult) { Assert.ArgumentNotNullOrEmpty(title, nameof(title)); Assert.ArgumentNotNullOrEmpty(message, nameof(message)); _msg.Info(message); string msg = MsgBase.ReplaceBreakTags(message); MessageBoxDefaultButton defaultButton; switch (defaultResult) { case YesNoCancelDialogResult.Yes: defaultButton = MessageBoxDefaultButton.Button1; break; case YesNoCancelDialogResult.No: defaultButton = MessageBoxDefaultButton.Button2; break; case YesNoCancelDialogResult.Cancel: defaultButton = MessageBoxDefaultButton.Button3; break; default: throw new ArgumentException( string.Format( "Invalid default result ({0})", defaultResult), nameof(defaultResult)); } DialogResult result = Show(owner, msg, title, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, defaultButton); _msg.DebugFormat("YES NO CANCEL Dialog: {0}, '{1}'. Answer: '{2}'", msg, title, result); return(GetYesNoCancelAnswer(result)); }
/// <summary> /// Shows the info list box dialog. /// </summary> /// <param name="owner">The owner.</param> /// <param name="title">The title.</param> /// <param name="headerMessage">The header message.</param> /// <param name="listLines">The list lines.</param> /// <param name="footerMessage">The footer message.</param> public void ShowInfoList(IWin32Window owner, string title, string headerMessage, IList <string> listLines, string footerMessage) { Assert.ArgumentNotNullOrEmpty(title, nameof(title)); Assert.ArgumentNotNullOrEmpty(headerMessage, nameof(headerMessage)); Assert.ArgumentNotNull(listLines, nameof(listLines)); _msg.Info(headerMessage); ShowListBox(ChooseOwner(owner), title, MsgBase.ReplaceBreakTags(headerMessage), listLines, footerMessage, MessageBoxButtons.OK, MessageBoxIcon.Information); }
/// <summary> /// Shows the Yes/No dialog. /// </summary> /// <param name="owner">The owner.</param> /// <param name="message">The message.</param> /// <param name="title">The title.</param> /// <returns></returns> public bool ShowYesNo(IWin32Window owner, string title, string message) { Assert.ArgumentNotNullOrEmpty(title, nameof(title)); Assert.ArgumentNotNullOrEmpty(message, nameof(message)); _msg.Info(message); string msg = MsgBase.ReplaceBreakTags(message); DialogResult result = Show(owner, msg, title, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); _msg.DebugFormat("YES NO Dialog: {0}, '{1}'. Answer: '{2}'", msg, title, result); return(result == DialogResult.Yes); }
/// <summary> /// Shows the Ok/Cancel dialog. /// </summary> /// <param name="owner">The owner.</param> /// <param name="title">The title.</param> /// <param name="message">The message.</param> /// <param name="defaultIsCancel">if set to <c>true</c> the default button is 'Cancel'. Otherswise, 'Ok' is the default.</param> /// <returns></returns> public bool ShowOkCancel(IWin32Window owner, string title, string message, bool defaultIsCancel = false) { Assert.ArgumentNotNullOrEmpty(title, nameof(title)); Assert.ArgumentNotNullOrEmpty(message, nameof(message)); _msg.Info(message); string msg = MsgBase.ReplaceBreakTags(message); DialogResult result = Show(owner, msg, title, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, defaultIsCancel ? MessageBoxDefaultButton.Button2 : MessageBoxDefaultButton.Button1); _msg.DebugFormat("OK CANCEL Dialog: {0}, '{1}'. Answer: '{2}'", msg, title, result); return(result == DialogResult.OK); }