private static OSMessageBoxResult ShowCore(string message, string title, Exception exception, string reportText, OSMessageBoxButton buttons, Dictionary <OSMessageBoxButton, string> customButtonLabels, OSMessageBoxIcon icon, OSMessageBoxResult defaultResult, Action <OSMessageBoxResult> onComplete) { var result = OSMessageBoxResult.None; var useErrorReport = exception != null; var reportException = useErrorReport; if (useErrorReport) { foreach (Predicate <Exception> predicate in _exceptionFilters.GetInvocationList()) { reportException = predicate(exception); if (!reportException) { break; } } } var hideExtraButtons = false; #if USE_BETA_ERROR_REPORT useErrorReport = true; hideExtraButtons = exception == null; #endif // USE_BETA_ERROR_REPORT if (useErrorReport) { var messageLine = message; var dialog = ReportDialog.Create(title, messageLine); dialog.Exception = reportException ? exception : null; dialog.ReportText = reportText; dialog.ShowCopyToClipboardButton = !hideExtraButtons; dialog.ShowSendEmailButton = !hideExtraButtons; var buttonText = GetCustomTextForButton(OSMessageBoxButton.OK, null, buttons); var showResult = dialog.ShowDialog(buttonText); if (showResult.HasValue) { result = showResult.Value ? OSMessageBoxResult.OK : OSMessageBoxResult.Cancel; if (buttons != OSMessageBoxButton.OK) { result = showResult.Value ? OSMessageBoxResult.Yes : OSMessageBoxResult.No; } } } else { var dialogMessage = new System.Text.StringBuilder(message); if (!string.IsNullOrWhiteSpace(reportText)) { dialogMessage.AppendLine().AppendLine().Append(reportText); } result = PlatformShowCore(dialogMessage.ToString(), title, exception, buttons, customButtonLabels, icon, defaultResult, onComplete); } return(result); }
/// <summary> /// Creates a new instance of the ReportDialog. /// </summary> /// <param name="title">The title for the dialog.</param> /// <param name="message">The message to display in the dialog.</param> /// <returns>The dialog instance.</returns> public static ReportDialog Create(string title, string message) { var dialog = new ReportDialog(title, message); return(dialog); }