public MessageForm(MessageFormType type, string message, string caption, ExceptionInfo exceptionInfo, MessageBoxButtons buttons, string[] attachedFilePathes, MessageFormSettings settingsOverrides)
        {
            var defaultSettings = DefaultMessageFormSettingsProvider.GetDefaultMessageFormSettings();
            _settings = MessageFormSettings.Merge(settingsOverrides, defaultSettings);
            _messageData = CreateMessageFormData(type, message, caption, exceptionInfo, _settings);
            _buttons = buttons;
            _attachedFilePathes = attachedFilePathes;

            InitializeComponent();

            this.Text = _messageData.Title;
            this.SetMessage(_messageData.DisplayText);
            this.SetIcon(type);

            switch (_messageData.MessageType)
            {
                case MessageFormType.Error:
                case MessageFormType.Warning:
                    this.ShowErrorDetails();
                    break;
            }

            this.InitializeButtons(type, buttons);
            this.ResizeView(_messageData.DisplayText);
        }
 public static DialogResult ShowMessage(MessageFormType type, string message, string caption, ExceptionInfo exceptionInfo, MessageBoxButtons buttons)
 {
     return ShowMessage(type, message, caption, exceptionInfo, buttons, null, new MessageFormSettings());
 }
 public static DialogResult ShowMessage(MessageFormType type, string message, string caption, ExceptionInfo exceptionInfo)
 {
     return ShowMessage(type, message, caption, exceptionInfo, DEFAULT_BUTTONS, null, new MessageFormSettings());
 }
 public static DialogResult ShowMessage(Exception exception)
 {
     var exceptionInfo = new ExceptionInfo(exception);
     return ShowMessage(MessageFormType.Error, null, null, exceptionInfo, DEFAULT_BUTTONS, null, new MessageFormSettings());
 }
        private static MessageFormData CreateMessageFormData(MessageFormType type, string message, string caption, ExceptionInfo exceptionInfo, MessageFormSettings settingsOverrides)
        {
            var messageData = new MessageFormData
            {
                MessageType = type,
                EnvironmentInfo = EnvironmentInfo.GetEnvironmentInfo(),
                ExceptionInfo = exceptionInfo,
            };

            if (!string.IsNullOrEmpty(message))
            {
                messageData.DisplayText = message;
            }
            else
            {
                if (exceptionInfo != null && !string.IsNullOrEmpty(exceptionInfo.Message))
                {
                    messageData.DisplayText = exceptionInfo.Message;
                }
                else
                {
                    messageData.DisplayText = settingsOverrides.DefaultDisplayText;
                }
            }

            if (!string.IsNullOrEmpty(caption))
            {
                messageData.Title = caption;
            }
            else
            {
                messageData.Title = messageData.EnvironmentInfo.ProductName;
            }

            return messageData;
        }
 public static DialogResult ShowMessage(MessageFormType type, string message, string caption, ExceptionInfo exceptionInfo, MessageBoxButtons buttons, string[] attachedFilePathes, MessageFormSettings settings)
 {
     using (var view = new MessageForm(type, message, caption, exceptionInfo, buttons, attachedFilePathes, settings))
     {
         TraceMessageData(type, view._messageData);
         var result = view.ShowDialog();
         return result;
     }
 }
            private static void SerializeShortExceptionInfoToStringBuilder(ExceptionInfo info, StringBuilder sb)
            {
                if (info == null)
                {
                    return;
                }

                sb.Append(FIELD_LP);
                sb.Append(SerializeValue(info.Message));
                sb.Append(FIELD_RP);
                sb.Append(FIELD_LP);
                sb.Append(SerializeValue(info.ExceptionTypeName));
                sb.Append(FIELD_RP);
                sb.Append(FIELD_LP);
                sb.Append(SerializeValue(info.LocalDateTime));
                sb.Append(FIELD_RP);
                sb.Append(FIELD_LP);
                SerializeContextValues(sb, info.ContextValues);
                sb.Append(FIELD_RP);
                sb.Append(FIELD_LP);
                SerializeStackTrace(sb, info.StackTrace);
                sb.Append(FIELD_RP);
            }