void ShowAssertionDialog(string message, string detailMessage, string stackTrace, bool canDebug) { message = message + Environment.NewLine + detailMessage + Environment.NewLine + stackTrace; List<string> buttonTexts = new List<string> { "Show Stacktrace", "Debug", "Ignore", "Ignore All" }; if (!canDebug) { buttonTexts.RemoveAt(1); } CustomDialog inputBox = new CustomDialog("Assertion Failed", message.TakeStartEllipsis(750), -1, 2, buttonTexts.ToArray()); try { while (true) { // show the dialog repeatedly until an option other than 'Show Stacktrace' is selected if (SD.MainThread.InvokeRequired) { inputBox.ShowDialog(); } else { inputBox.ShowDialog(SD.WinForms.MainWin32Window); } int result = inputBox.Result; if (!canDebug && result >= 1) result++; switch (result) { case 0: ExceptionBox.ShowErrorBox(null, message); break; // show the custom dialog again case 1: Debugger.Break(); return; case 2: return; case 3: lock (ignoredStacks) { ignoredStacks.Add(stackTrace); } return; } } } finally { dialogIsOpen.Reset(); inputBox.Dispose(); } }
public int ShowCustomDialog(string caption, string dialogText, int acceptButtonIndex, int cancelButtonIndex, params string[] buttontexts) { int result = 0; Invoke( delegate { using (CustomDialog messageBox = new CustomDialog(caption, dialogText, acceptButtonIndex, cancelButtonIndex, buttontexts)) { messageBox.ShowDialog(DialogOwner); result = messageBox.Result; } }); return result; }
void ShowAssertionDialog(string message, string detailMessage, string stackTrace, ref bool debug) { message = message + Environment.NewLine + detailMessage + Environment.NewLine + stackTrace; string[] buttonTexts = { "Show Stacktrace", "Debug", "Ignore", "Ignore All" }; CustomDialog inputBox = new CustomDialog("Assertion Failed", message.TakeStartEllipsis(750), -1, 2, buttonTexts); try { while (true) { // show the dialog repeatedly until an option other than 'Show Stacktrace' is selected inputBox.ShowDialog(); int result = inputBox.Result; switch (result) { case 0: ExceptionBox.ShowErrorBox(null, message); break; // show the custom dialog again case 1: debug = true; return; case 2: return; case 3: lock (ignoredStacks) { ignoredStacks.Add(stackTrace); } return; } } } finally { dialogIsOpen.Reset(); inputBox.Dispose(); } }