コード例 #1
0
ファイル: ErrorDialogService.cs プロジェクト: sbambach/ATF
        private void ShowError(string messageId, string message, OutputMessageType messageType)
        {
            messageId = messageId.Replace(Environment.NewLine, string.Empty);// remove newlines to ease persistence

            if (!m_suppressedMessages.Contains(messageId))
            {
                // Check for illegal cross-thread operation. m_owner may not be a Control and the InvokeIfRequired
                //  extension method will handle that.
                (m_owner as Control).InvokeIfRequired(() =>
                {
                    // lazily create error dialog
                    if (m_errorDialog == null)
                    {
                        m_errorDialog = new ErrorDialog();
                        m_errorDialog.StartPosition = FormStartPosition.CenterScreen;
                        m_errorDialog.SuppressMessageClicked += errorDialog_SuppressMessageClicked;
                        m_errorDialog.FormClosed += errorDialog_FormClosed;
                    }

                    if (messageType == OutputMessageType.Error)
                        m_errorDialog.Text = "Error!".Localize();
                    else if (messageType == OutputMessageType.Warning)
                        m_errorDialog.Text = "Warning".Localize();
                    else if (messageType == OutputMessageType.Info)
                        m_errorDialog.Text = "Info".Localize();

                    m_errorDialog.MessageId = messageId;
                    m_errorDialog.Message = message;
                    m_errorDialog.Visible = false; //Just in case a second error message comes through, because...
                    m_errorDialog.Show(m_owner); //if Visible is true, Show() crashes.
                });
            }
        }
コード例 #2
0
        private void ShowError(string messageId, string message, OutputMessageType messageType)
        {
            messageId = messageId.Replace(Environment.NewLine, string.Empty);// remove newlines to ease persistence

            if (!m_suppressedMessages.Contains(messageId))
            {
                // lazily create error dialog
                if (m_errorDialog == null)
                {
                    m_errorDialog = new ErrorDialog();
                    m_errorDialog.StartPosition = FormStartPosition.CenterScreen;
                    m_errorDialog.SuppressMessageClicked += errorDialog_SuppressMessageClicked;
                    m_errorDialog.FormClosed += errorDialog_FormClosed;
                }

                if (messageType == OutputMessageType.Error)
                    m_errorDialog.Text = "Error!".Localize();
                else if (messageType == OutputMessageType.Warning)
                    m_errorDialog.Text = "Warning".Localize();
                else if (messageType == OutputMessageType.Info)
                    m_errorDialog.Text = "Info".Localize();           

                m_errorDialog.MessageId = messageId;
                m_errorDialog.Message = message;
                m_errorDialog.Visible = false; //Just in case a second error message comes through, because...
                m_errorDialog.Show(m_owner); //if Visible is true, Show() crashes. Should this be the modal ShowDialog(m_owner)?
            }
        }
コード例 #3
0
ファイル: ErrorDialog.cs プロジェクト: JanDeHud/LevelEditor
 /// <summary>
 /// Shows a modal error dialog with the given message followed by the exception's text</summary>
 /// <param name="message">Text to be prepended to the exception's text</param>
 /// <param name="caption">Text to set the window's caption to</param>
 /// <param name="exception">Exception whose error message and call stack will be displayed</param>
 /// <returns>Currently, only DialogResult.OK will be returned</returns>
 public static DialogResult Show(string message, string caption, Exception exception)
 {
     var dlg = new ErrorDialog(message, caption, exception);
     return dlg.ShowDialog();
 }
コード例 #4
0
ファイル: ErrorDialog.cs プロジェクト: zparr/ATF
        /// <summary>
        /// Shows a modal error dialog with the given message followed by the exception's text</summary>
        /// <param name="message">Text to be prepended to the exception's text</param>
        /// <param name="caption">Text to set the window's caption to</param>
        /// <param name="exception">Exception whose error message and call stack will be displayed</param>
        /// <returns>Currently, only DialogResult.OK will be returned</returns>
        public static DialogResult Show(string message, string caption, Exception exception)
        {
            var dlg = new ErrorDialog(message, caption, exception);

            return(dlg.ShowDialog());
        }