Пример #1
0
        private static async Task HandleClosingErrorAsync(Window window, Exception ex)
        {
            var message = string.IsNullOrEmpty(ex.Message) ? ex.ToString() : ex.Message;

            IsClosingConfirmed = false;

            var closingDetails = new ClosingDetails
            {
                Window        = window,
                Exception     = ex,
                CanBeClosed   = true,
                CanKeepOpened = true,
                Message       = $"Error. The application will be forced to close:\n{message}"
            };

            foreach (var watcher in Watchers)
            {
                watcher.ClosingFailed(closingDetails);
            }

            if (string.IsNullOrEmpty(closingDetails.Message) &&
                !closingDetails.CanBeClosed &&
                closingDetails.CanKeepOpened)
            {
                return;
            }

            var messageButton = MessageButton.OKCancel;

            if (!closingDetails.CanKeepOpened)
            {
                messageButton = MessageButton.OK;
            }

            if (await MessageService.ShowAsync(closingDetails.Message, "Error", messageButton, MessageImage.Error) == MessageResult.OK)
            {
                await CloseWindow(window).ConfigureAwait(false);
            }
        }
Пример #2
0
 protected virtual void ClosingFailed(ClosingDetails appClosingFaultDetails)
 {
 }