public static MsgBoxResult Show(string messageBoxText, string caption, string details, MsgBoxButtons buttonOption, MsgBoxImage image, MsgBoxResult btnDefault = MsgBoxResult.None, object helpLink = null, string helpLinkTitle = "", string helpLabel = "", Func <object, bool> navigateHelplinkMethod = null, bool enableCopyFunction = false) { // Construct the message box viewmodel ViewModel.MsgBoxViewModel viewModel = new ViewModel.MsgBoxViewModel(messageBoxText, caption, details, buttonOption, image, btnDefault, helpLink, helpLinkTitle, navigateHelplinkMethod, enableCopyFunction); viewModel.HyperlinkLabel = helpLabel; // Construct the message box view and add the viewmodel to it MsgBox.mMessageBox = new MsgBox(); MsgBox.mMessageBox.DataContext = viewModel; MsgBox.mMessageBox.ShowDialog(); return(viewModel.Result); }
public static MsgBoxResult Show(Exception exp, string caption, MsgBoxButtons buttonOption, MsgBoxImage image, MsgBoxResult btnDefault = MsgBoxResult.None, object helpLink = null, string helpLinkTitle = "", string helpLabel = "", Func <object, bool> navigateHelplinkMethod = null, bool enableCopyFunction = false) { string sMess = "Unknown error occured."; string messageBoxText = string.Empty; if (true) { try { messageBoxText = exp.Message; Exception innerEx = exp.InnerException; for (int i = 0; innerEx != null; i++, innerEx = innerEx.InnerException) { string spaces = string.Empty; for (int j = 0; j < i; j++) { spaces += " "; } messageBoxText += "\n" + spaces + "+->" + innerEx.Message; } sMess = exp.ToString(); } catch { } } // Construct the message box viewmodel ViewModel.MsgBoxViewModel viewModel = new ViewModel.MsgBoxViewModel(messageBoxText, caption, sMess, buttonOption, image, btnDefault, helpLink, helpLinkTitle, navigateHelplinkMethod, enableCopyFunction); viewModel.HyperlinkLabel = helpLabel; // Construct the message box view and add the viewmodel to it MsgBox.mMessageBox = new MsgBox(); MsgBox.mMessageBox.DataContext = viewModel; MsgBox.mMessageBox.ShowDialog(); return(viewModel.Result); }