public ErrorForm(ErrorContext errorContext)
        {
            if (null == errorContext)
            {
                throw new ArgumentNullException(nameof(errorContext));
            }

            if (null != Type.GetType("Mono.Runtime"))
            {
                Font = new Font("Arial", 8);
            }

            InitializeComponent();

            Text = errorContext.Caption ?? string.Empty;
            captionLabel.Text       = errorContext.Caption ?? string.Empty;
            messageRichTextBox.Text = errorContext.Message ?? string.Empty;

            if (null != errorContext.Details)
            {
                detailsRichTextBox.Text = errorContext.Details;
            }

            _errorLevel = errorContext.Level;

            ((ISupportInitialize)iconPictureBox).BeginInit();
            switch (errorContext.Level)
            {
            case ErrorContext.ErrorLevel.Error:
                iconPictureBox.Image = iconImageList.Images[0];
                break;

            case ErrorContext.ErrorLevel.Warning:
                iconPictureBox.Image = iconImageList.Images[1];
                break;
            }
            ((ISupportInitialize)iconPictureBox).EndInit();

            _heightDifference = detailsRichTextBox.Height +
                                detailsRichTextBox.Margin.Top +
                                detailsRichTextBox.Margin.Bottom +
                                separatorLabel.Height +
                                separatorLabel.Margin.Top +
                                separatorLabel.Margin.Bottom;

            HideDetails();
            _detailsVisible = false;

            if (null == errorContext.Details)
            {
                detailsButton.Enabled = false;
            }
        }
Example #2
0
        public static Form BuildErrorForm(ExtensionManager extensionManager, string caption, string message,
                                          ErrorContext.ErrorLevel level = ErrorContext.ErrorLevel.Warning)
        {
            if (null == extensionManager)
            {
                throw new ArgumentNullException(nameof(extensionManager));
            }

            if (null == caption)
            {
                throw new ArgumentNullException(nameof(caption));
            }

            if (null == message)
            {
                throw new ArgumentNullException(nameof(message));
            }

            var errorContext = new ErrorContext(caption, message, level);

            return(extensionManager.GetErrorFormProvider().GetForm(errorContext));
        }