Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
 public override void ShowException(Exception ex, string message)
 {
     SD.Log.Error(message, ex);
     SD.Log.Warn("Stack trace of last exception log:\n" + Environment.StackTrace);
     if (ex != null)
     {
         ExceptionBox.ShowErrorBox(ex, message);
     }
     else
     {
         ShowError(message);
     }
 }
        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();
            }
        }