Пример #1
0
        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 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);
        }
Пример #3
0
        //public string MailClientName
        //{
        //    get;
        //    set;
        //}

        //public string SendMailMessage
        //{
        //    get;
        //    set;
        //}

        //public bool SkipSendMailMessage
        //{
        //    get;
        //    set;
        //}

        //public string MailSubjectFormat
        //{
        //    get;
        //    set;
        //}

        //public string MailBodyIntroFormat
        //{
        //    get;
        //    set;
        //}

        //public string MailBodyShortIntroFormat
        //{
        //    get;
        //    set;
        //}

        //public bool DoNotAttachScreenshot
        //{
        //    get;
        //    set;
        //}

        #endregion

        #region Methods

        public static MessageFormSettings Merge(MessageFormSettings destination, MessageFormSettings source)
        {
            if (string.IsNullOrEmpty(destination.DefaultDisplayText))
            {
                destination.DefaultDisplayText = source.DefaultDisplayText;
            }

            if (string.IsNullOrEmpty(destination.CopyButtonText))
            {
                destination.CopyButtonText = source.CopyButtonText;
            }

            if (string.IsNullOrEmpty(destination.DetailsButtonText))
            {
                destination.DetailsButtonText = source.DetailsButtonText;
            }

            if (string.IsNullOrEmpty(destination.OkButtonText))
            {
                destination.OkButtonText = source.OkButtonText;
            }

            if (string.IsNullOrEmpty(destination.CancelButtonText))
            {
                destination.CancelButtonText = source.CancelButtonText;
            }

            if (string.IsNullOrEmpty(destination.YesButtonText))
            {
                destination.YesButtonText = source.YesButtonText;
            }

            if (string.IsNullOrEmpty(destination.NoButtonText))
            {
                destination.NoButtonText = source.NoButtonText;
            }

            if (string.IsNullOrEmpty(destination.AbortButtonText))
            {
                destination.AbortButtonText = source.AbortButtonText;
            }

            if (string.IsNullOrEmpty(destination.RetryButtonText))
            {
                destination.RetryButtonText = source.RetryButtonText;
            }

            if (string.IsNullOrEmpty(destination.IgnoreButtonText))
            {
                destination.IgnoreButtonText = source.IgnoreButtonText;
            }

            return(destination);
        }
Пример #4
0
            public static MessageFormSettings GetDefaultMessageFormSettings()
            {
                var settings = new MessageFormSettings
                {
                    DefaultDisplayText = DISPLAY_TEXT,
                    HideCopyButton     = false,
                    CopyButtonText     = COPY_BUTTON_TEXT,
                    HideDetailsButton  = false,
                    DetailsButtonText  = DETAILS_BUTTON_TEXT,
                    OkButtonText       = OK_BUTTON_TEXT,
                    CancelButtonText   = CANCEL_BUTTON_TEXT,
                    YesButtonText      = YES_BUTTON_TEXT,
                    NoButtonText       = NO_BUTTON_TEXT,
                    AbortButtonText    = ABORT_BUTTON_TEXT,
                    RetryButtonText    = RETRY_BUTTON_TEXT,
                    IgnoreButtonText   = IGNORE_BUTTON_TEXT,
                };

                return(settings);
            }
        public static MessageFormSettings Merge(MessageFormSettings destination, MessageFormSettings source)
        {
            if (string.IsNullOrEmpty(destination.DefaultDisplayText))
            {
                destination.DefaultDisplayText = source.DefaultDisplayText;
            }

            if (string.IsNullOrEmpty(destination.CopyButtonText))
            {
                destination.CopyButtonText = source.CopyButtonText;
            }

            if (string.IsNullOrEmpty(destination.DetailsButtonText))
            {
                destination.DetailsButtonText = source.DetailsButtonText;
            }

            if (string.IsNullOrEmpty(destination.OkButtonText))
            {
                destination.OkButtonText = source.OkButtonText;
            }

            if (string.IsNullOrEmpty(destination.CancelButtonText))
            {
                destination.CancelButtonText = source.CancelButtonText;
            }

            if (string.IsNullOrEmpty(destination.YesButtonText))
            {
                destination.YesButtonText = source.YesButtonText;
            }

            if (string.IsNullOrEmpty(destination.NoButtonText))
            {
                destination.NoButtonText = source.NoButtonText;
            }

            if (string.IsNullOrEmpty(destination.AbortButtonText))
            {
                destination.AbortButtonText = source.AbortButtonText;
            }

            if (string.IsNullOrEmpty(destination.RetryButtonText))
            {
                destination.RetryButtonText = source.RetryButtonText;
            }

            if (string.IsNullOrEmpty(destination.IgnoreButtonText))
            {
                destination.IgnoreButtonText = source.IgnoreButtonText;
            }

            return destination;
        }
            public static MessageFormSettings GetDefaultMessageFormSettings()
            {
                var settings = new MessageFormSettings
                {
                    DefaultDisplayText = DISPLAY_TEXT,
                    HideCopyButton = false,
                    CopyButtonText = COPY_BUTTON_TEXT,
                    HideDetailsButton = false,
                    DetailsButtonText = DETAILS_BUTTON_TEXT,
                    OkButtonText = OK_BUTTON_TEXT,
                    CancelButtonText = CANCEL_BUTTON_TEXT,
                    YesButtonText = YES_BUTTON_TEXT,
                    NoButtonText = NO_BUTTON_TEXT,
                    AbortButtonText = ABORT_BUTTON_TEXT,
                    RetryButtonText = RETRY_BUTTON_TEXT,
                    IgnoreButtonText = IGNORE_BUTTON_TEXT,
                };

                return settings;
            }
        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;
     }
 }
Пример #9
0
        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);
        }
Пример #10
0
 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);
     }
 }