Пример #1
0
        static void ShowDialog(string moreInfo, string message, string title, Exception e) {
            var app = Application.Current;
            var mainWindow = app == null || !MainWindowShown ? null : app.MainWindow;

            var vm = new ExceptionDialogViewModel(moreInfo) {
                // Not formatted... moreInfo == null ? null : HandleHyperlinks(Escape(moreInfo))
                Message = ParseMessage(message),
                Title = title,
                Exception = e
            };
            var window = new ExceptionDialogView {Owner = mainWindow, DataContext = vm};
            window.ShowDialog();
        }
Пример #2
0
        static bool ShowExceptionDialog(string message, string title, Exception e, object window = null) {
            message = new XmlSanitizer().SanitizeXmlString(message);

            var ev = new ExceptionDialogViewModel(e.Format()) {
                Message = message,
                Title = title,
                Exception = e
            };

            var w = new ExceptionDialogView {DataContext = ev};
            if (window == null)
                DialogHelper.SetMainWindowOwner(w);
            else
                w.Owner = (Window) window;
            w.ShowDialog();

            if (ev.Throw)
                throw new ExceptionDialogThrownException("Redirected exception", e);

            return ev.Cancel;
        }