public Form GetForm(ErrorContext context) { if (null == context) { throw new ArgumentNullException(nameof(context)); } var errorFormTemplate = new ErrorFormTemplate(context.Caption, context.Message); errorFormTemplate.SetTemplateInternals(nameof(ErrorForm), null); if (null != context.Details) { errorFormTemplate.Details = context.Details; } switch (context.Level) { case ErrorContext.ErrorLevel.Error: errorFormTemplate.Level = ErrorLevel.Error; break; case ErrorContext.ErrorLevel.Warning: errorFormTemplate.Level = ErrorLevel.Warning; break; default: throw new ArgumentOutOfRangeException(nameof(context)); } return(new ErrorForm(errorFormTemplate)); }
private void mBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (IsDisposed) { return; } mFlowLayoutPanel.Enabled = true; previousButton.Enabled = true; nextButton.Enabled = true; mToolStripProgressBar.Visible = false; var error = e.Error; if (null != error) { if (null != ErrorAction) { ErrorAction(error); } else { var errorFormTemplate = new ErrorFormTemplate { Caption = error.GetType().Name, Message = error.Message, Details = error.ToString() }; errorFormTemplate.SetTemplateInternals(_templateName, _templateBaseDirectory); ErrorForm.ShowDialog(this, errorFormTemplate); } return; } var values = e.Result as Dictionary <string, object>; if (_currentShapeIndex + 1 < _steps.Count) { _currentShapeIndex++; ApplyShape(values); previousButton.Visible = true; return; } if (null != FinalAction) { if (!FinalAction(values)) { return; } } DialogResult = DialogResult.OK; Close(); }
public static void ShowDialog(IWin32Window window, ErrorFormTemplate errorFormTemplate) { if (null == errorFormTemplate) { throw new ArgumentNullException(nameof(errorFormTemplate)); } var errorForm = new ErrorForm(errorFormTemplate); errorForm.ShowDialog(window); }
private void mBackgroundWorker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) { if (IsDisposed) { return; } var error = e.Error; if (null != error) { mProgressBar.Style = ProgressBarStyle.Blocks; mProgressBar.Value = 100; if (!ApplicationUtility.IsRunningOnMono) { SetState(mProgressBar, 2); } string connectionString = string.Empty; var connectionSettings = _session.AuthenticationService.GetConnectionSettings(); if (null != connectionSettings) { connectionString = connectionSettings.ConnectionString; } string caption = Resources.ProgressForm_mBackgroundWorker_RunWorkerCompleted_Connection_error; string message = string.Format(Resources.ProgressForm_mBackgroundWorker_RunWorkerCompleted_Could_not_connect_to_the_database_with_connection_string___0___, connectionString); var errorFormTemplate = new ErrorFormTemplate(caption, message) { Details = error.ToString() }; errorFormTemplate.SetTemplateInternals(ExtensionCatalog.Enter, null); ErrorForm.ShowDialog(this, errorFormTemplate); DialogResult = DialogResult.Cancel; } else { DialogResult = DialogResult.OK; } }
public ErrorForm(ErrorFormTemplate errorFormTemplate) { if (null == errorFormTemplate) { throw new ArgumentNullException(nameof(errorFormTemplate)); } if (ApplicationUtility.IsRunningOnMono) { Font = new Font("Arial", 8); } InitializeComponent(); _originalCaption = errorFormTemplate.OriginalCaption ?? throw new BadTemplateException("null == errorFormTemplate.Caption"); Text = errorFormTemplate.Caption; captionLabel.Text = errorFormTemplate.Caption; messageRichTextBox.Text = errorFormTemplate.Message ?? throw new BadTemplateException("null == errorFormTemplate.Message"); if (null != errorFormTemplate.Details) { detailsRichTextBox.Text = errorFormTemplate.Details; } _errorLevel = errorFormTemplate.Level; ((ISupportInitialize)iconPictureBox).BeginInit(); switch (errorFormTemplate.Level) { case ErrorLevel.Error: iconPictureBox.Image = iconImageList.Images[0]; break; case 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 + reportButton.Height + reportButton.Margin.Top + reportButton.Margin.Bottom; HideDetails(); _detailsVisible = false; if (null == errorFormTemplate.Details) { detailsButton.Enabled = false; } reportButton.Enabled = null != SupportAction; }