// --
 // -- advanced error dialog with Exception object
 // --
 public static DialogResult ShowDialog(string strWhatHappened,
                                       string strHowUserAffected,
                                       string strWhatUserCanDo,
                                       System.Exception objException,
                                       MessageBoxButtons Buttons            = System.Windows.Forms.MessageBoxButtons.OK,
                                       MessageBoxIcon Icon                  = System.Windows.Forms.MessageBoxIcon.Warning,
                                       UserErrorDefaultButton DefaultButton = UserErrorDefaultButton.Default)
 {
     _blnHaveException = true;
     // Warning!!! Optional parameters not supported
     // Warning!!! Optional parameters not supported
     // Warning!!! Optional parameters not supported
     _strExceptionType = objException.GetType().FullName;
     return(ShowDialogInternal(strWhatHappened, strHowUserAffected, strWhatUserCanDo, ExceptionToMore(objException), Buttons, Icon, DefaultButton));
 }
示例#2
0
            /// <summary>
            /// Shows the dialog internal.
            /// </summary>
            /// <param name="whatHappened">The what happened.</param>
            /// <param name="howUserAffected">The how user affected.</param>
            /// <param name="whatUserCanDo">The what user can do.</param>
            /// <param name="moreDetails">The more details.</param>
            /// <param name="buttons">The buttons.</param>
            /// <param name="icon">The icon.</param>
            /// <param name="defaultButton">The default button.</param>
            /// <param name="owner">The owner.</param>
            /// <returns></returns>
            private static DialogResult ShowDialogInternal(string whatHappened, string howUserAffected, string whatUserCanDo, string moreDetails, MessageBoxButtons buttons, MessageBoxIcon icon, UserErrorDefaultButton defaultButton, IWin32Window owner)
            {
                DialogResult result;

                //-- set default values, etc
                ProcessStrings(ref whatHappened, ref howUserAffected, ref whatUserCanDo, ref moreDetails);

                using (ExceptionDialog objForm = new ExceptionDialog())
                {
                    objForm.Text           = ReplaceStringVals(objForm.Text);
                    objForm.ErrorBox.Text  = whatHappened;
                    objForm.ScopeBox.Text  = howUserAffected;
                    objForm.ActionBox.Text = whatUserCanDo;
                    objForm.txtMore.Text   = moreDetails;

                    //-- determine what button text, visibility, and defaults are
                    switch (buttons)
                    {
                    case MessageBoxButtons.AbortRetryIgnore:
                        objForm.btn1.Text    = "&Abort";
                        objForm.btn2.Text    = "&Retry";
                        objForm.btn3.Text    = "&Ignore";
                        objForm.AcceptButton = objForm.btn2;
                        objForm.CancelButton = objForm.btn3;
                        break;

                    case MessageBoxButtons.OK:
                        objForm.btn3.Text    = "OK";
                        objForm.btn2.Visible = false;
                        objForm.btn1.Visible = false;
                        objForm.AcceptButton = objForm.btn3;
                        break;

                    case MessageBoxButtons.OKCancel:
                        objForm.btn3.Text    = "Cancel";
                        objForm.btn2.Text    = "OK";
                        objForm.btn1.Visible = false;
                        objForm.AcceptButton = objForm.btn2;
                        objForm.CancelButton = objForm.btn3;
                        break;

                    case MessageBoxButtons.RetryCancel:
                        objForm.btn3.Text    = "Cancel";
                        objForm.btn2.Text    = "&Retry";
                        objForm.btn1.Visible = false;
                        objForm.AcceptButton = objForm.btn2;
                        objForm.CancelButton = objForm.btn3;
                        break;

                    case MessageBoxButtons.YesNo:
                        objForm.btn3.Text    = "&No";
                        objForm.btn2.Text    = "&Yes";
                        objForm.btn1.Visible = false;
                        break;

                    case MessageBoxButtons.YesNoCancel:
                        objForm.btn3.Text    = "Cancel";
                        objForm.btn2.Text    = "&No";
                        objForm.btn1.Text    = "&Yes";
                        objForm.CancelButton = objForm.btn3;
                        break;
                    }

                    //'-- set the proper dialog icon
                    MessageBoxIcon PictureBox1 = icon;
                    if (PictureBox1 == MessageBoxIcon.Hand)
                    {
                        objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap();
                    }
                    else if (PictureBox1 == MessageBoxIcon.Hand)
                    {
                        objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap();
                    }
                    else if (PictureBox1 == MessageBoxIcon.Exclamation)
                    {
                        objForm.PictureBox1.Image = SystemIcons.Exclamation.ToBitmap();
                    }
                    else if (PictureBox1 == MessageBoxIcon.Asterisk)
                    {
                        objForm.PictureBox1.Image = SystemIcons.Information.ToBitmap();
                    }
                    else if (PictureBox1 == MessageBoxIcon.Question)
                    {
                        objForm.PictureBox1.Image = SystemIcons.Question.ToBitmap();
                    }
                    else
                    {
                        objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap();
                    }

                    //-- override the default button
                    switch (defaultButton)
                    {
                    case UserErrorDefaultButton.Button1:
                        objForm.AcceptButton  = objForm.btn1;
                        objForm.btn1.TabIndex = 0;
                        break;

                    case UserErrorDefaultButton.Button2:
                        objForm.AcceptButton  = objForm.btn2;
                        objForm.btn2.TabIndex = 0;
                        break;

                    case UserErrorDefaultButton.Button3:
                        objForm.AcceptButton  = objForm.btn3;
                        objForm.btn3.TabIndex = 0;
                        break;
                    }

                    if (_blnEmailError)
                    {
                        SendNotificationEmail(whatHappened, howUserAffected, whatUserCanDo, moreDetails);
                    }

                    //-- show the user our error dialog
                    if (owner == null)
                    {
                        result = objForm.ShowDialog();
                    }
                    else
                    {
                        result = objForm.ShowDialog(owner);
                    }

                    return(result);
                }
            }
示例#3
0
 /// <summary>
 /// Shows the advanced error dialog with More string.
 /// leave "more" string blank to get the default
 /// </summary>
 /// <param name="whatHappened">The what happened.</param>
 /// <param name="howUserAffected">The how user affected.</param>
 /// <param name="whatUserCanDo">The what user can do.</param>
 /// <param name="moreDetails">The more details.</param>
 /// <param name="owner">The owner.</param>
 /// <param name="buttons">The buttons.</param>
 /// <param name="icon">The icon.</param>
 /// <param name="defaultButton">The default button.</param>
 /// <returns></returns>
 public static DialogResult ShowDialog(string whatHappened, string howUserAffected, string whatUserCanDo, string moreDetails, IWin32Window owner = null, MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.Warning, UserErrorDefaultButton defaultButton = UserErrorDefaultButton.Default)
 {
     _blnHaveException = false;
     return(ShowDialogInternal(whatHappened, howUserAffected, whatUserCanDo, moreDetails, buttons, icon, defaultButton, owner));
 }
示例#4
0
 /// <summary>
 /// Shows the advanced error dialog with Exception object.
 /// </summary>
 /// <param name="whatHappened">The what happened.</param>
 /// <param name="howUserAffected">The how user affected.</param>
 /// <param name="whatUserCanDo">The what user can do.</param>
 /// <param name="exception">The exception.</param>
 /// <param name="owner">The owner.</param>
 /// <param name="buttons">The buttons.</param>
 /// <param name="icon">The icon.</param>
 /// <param name="defaultButton">The default button.</param>
 /// <returns></returns>
 public static DialogResult ShowDialog(string whatHappened, string howUserAffected, string whatUserCanDo, System.Exception exception, IWin32Window owner = null, MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.Warning, UserErrorDefaultButton defaultButton = UserErrorDefaultButton.Default)
 {
     _blnHaveException = true;
     _strExceptionType = exception.GetType().FullName;
     return(ShowDialogInternal(whatHappened, howUserAffected, whatUserCanDo, ExceptionToMore(exception), buttons, icon, defaultButton, owner));
 }
        private static DialogResult ShowDialogInternal(string strWhatHappened, string strHowUserAffected, string strWhatUserCanDo, string strMoreDetails, MessageBoxButtons Buttons, MessageBoxIcon Icon, UserErrorDefaultButton DefaultButton)
        {
            ProcessStrings(ref strWhatHappened, ref strHowUserAffected, ref strWhatUserCanDo, ref strMoreDetails);

            var objForm = new ExceptionDialog();

            objForm.Text           = ReplaceStringVals(objForm.Text);
            objForm.ErrorBox.Text  = strWhatHappened;
            objForm.ScopeBox.Text  = strHowUserAffected;
            objForm.ActionBox.Text = strWhatUserCanDo;
            objForm.txtMore.Text   = strMoreDetails;

            switch (((int)Buttons))
            {
            case 0:
                objForm.btn3.Text    = "OK";
                objForm.btn2.Visible = false;
                objForm.btn1.Visible = false;
                objForm.AcceptButton = objForm.btn3;
                break;

            case 1:
                objForm.btn3.Text    = "Cancel";
                objForm.btn2.Text    = "OK";
                objForm.btn1.Visible = false;
                objForm.AcceptButton = objForm.btn2;
                objForm.CancelButton = objForm.btn3;
                break;

            case 2:
                objForm.btn1.Text    = "&Abort";
                objForm.btn2.Text    = "&Retry";
                objForm.btn3.Text    = "&Ignore";
                objForm.AcceptButton = objForm.btn2;
                objForm.CancelButton = objForm.btn3;
                break;

            case 3:
                objForm.btn3.Text    = "Cancel";
                objForm.btn2.Text    = "&No";
                objForm.btn1.Text    = "&Yes";
                objForm.CancelButton = objForm.btn3;
                break;

            case 4:
                objForm.btn3.Text    = "&No";
                objForm.btn2.Text    = "&Yes";
                objForm.btn1.Visible = false;
                break;

            case 5:
                objForm.btn3.Text    = "Cancel";
                objForm.btn2.Text    = "&Retry";
                objForm.btn1.Visible = false;
                objForm.AcceptButton = objForm.btn2;
                objForm.CancelButton = objForm.btn3;
                break;
            }

            if (Icon == MessageBoxIcon.Hand)
            {
                objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap();
            }
            else if (Icon == MessageBoxIcon.Hand)
            {
                objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap();
            }
            else if (Icon == MessageBoxIcon.Exclamation)
            {
                objForm.PictureBox1.Image = SystemIcons.Exclamation.ToBitmap();
            }
            else if (Icon == MessageBoxIcon.Asterisk)
            {
                objForm.PictureBox1.Image = SystemIcons.Information.ToBitmap();
            }
            else if (Icon == MessageBoxIcon.Question)
            {
                objForm.PictureBox1.Image = SystemIcons.Question.ToBitmap();
            }
            else
            {
                objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap();
            }

            switch (((int)DefaultButton))
            {
            case 1:
                objForm.AcceptButton  = objForm.btn1;
                objForm.btn1.TabIndex = 0;
                break;

            case 2:
                objForm.AcceptButton  = objForm.btn2;
                objForm.btn2.TabIndex = 0;
                break;

            case 3:
                objForm.AcceptButton  = objForm.btn3;
                objForm.btn3.TabIndex = 0;
                break;
            }

            return(objForm.ShowDialog());
        }
 public static DialogResult ShowDialog(string strWhatHappened, string strHowUserAffected, string strWhatUserCanDo, string strMoreDetails, MessageBoxButtons Buttons, MessageBoxIcon Icon, UserErrorDefaultButton DefaultButton)
 {
     return(ShowDialogInternal(strWhatHappened, strHowUserAffected, strWhatUserCanDo, strMoreDetails, Buttons, Icon, DefaultButton));
 }
        // --
        // -- internal method to show error dialog
        // --
        public static DialogResult ShowDialogInternal(string strWhatHappened, string strHowUserAffected, string strWhatUserCanDo, string strMoreDetails, MessageBoxButtons Buttons, MessageBoxIcon Icon, UserErrorDefaultButton DefaultButton)
        {
            // -- set default values, etc
            // ProcessStrings(ref strWhatHappened, ref strHowUserAffected, ref strWhatUserCanDo, ref strMoreDetails);
            return(DialogResult.OK);
            // Error objForm = new Error();



            /*
             * ExceptionDialog objForm = new ExceptionDialog();
             * // With...
             * strHowUserAffected.ActionBox.Text = strMoreDetails;
             * strWhatHappened.ScopeBox.Text = strMoreDetails;
             * ReplaceStringVals(objForm.Text).ErrorBox.Text = strMoreDetails;
             * objForm.Text = strMoreDetails;
             * // -- determine what button text, visibility, and defaults are
             * // With...
             * switch (Buttons) {
             * }
             * "&Ignore".AcceptButton = objForm.btn3;
             * "&Retry".btn3.Text = objForm.btn3;
             * "&Abort".btn2.Text = objForm.btn3;
             * MessageBoxButtons.AbortRetryIgnore.btn1.Text = objForm.btn3;
             * false.AcceptButton = objForm.btn3;
             * false.btn1.Visible = objForm.btn3;
             * "OK".btn2.Visible = objForm.btn3;
             * MessageBoxButtons.OK.btn3.Text = objForm.btn3;
             * objForm.btn2.CancelButton = objForm.btn3;
             * false.AcceptButton = objForm.btn3;
             * "OK".btn1.Visible = objForm.btn3;
             * "Cancel".btn2.Text = objForm.btn3;
             * MessageBoxButtons.OKCancel.btn3.Text = objForm.btn3;
             * objForm.btn2.CancelButton = objForm.btn3;
             * false.AcceptButton = objForm.btn3;
             * "&Retry".btn1.Visible = objForm.btn3;
             * "Cancel".btn2.Text = objForm.btn3;
             * MessageBoxButtons.RetryCancel.btn3.Text = objForm.btn3;
             * "&Yes".btn1.Visible = false;
             * "&No".btn2.Text = false;
             * MessageBoxButtons.YesNo.btn3.Text = false;
             * "&Yes".CancelButton = objForm.btn3;
             * "&No".btn1.Text = objForm.btn3;
             * "Cancel".btn2.Text = objForm.btn3;
             * MessageBoxButtons.YesNoCancel.btn3.Text = objForm.btn3;
             */
            //    }
            //}
            //// -- override the default button
            //switch (DefaultButton) {
            //    case UserErrorDefaultButton.Button1:
            //        objForm.AcceptButton = objForm.btn1;
            //        objForm.btn1.TabIndex = 0;
            //        break;
            //    case UserErrorDefaultButton.Button2:
            //        objForm.AcceptButton = objForm.btn2;
            //        objForm.btn2.TabIndex = 0;
            //        break;
            //    case UserErrorDefaultButton.Button3:
            //        objForm.AcceptButton = objForm.btn3;
            //        objForm.btn3.TabIndex = 0;
            //        break;
            //}
            //if (_blnEmailError) {
            //    SendNotificationEmail(strWhatHappened, strHowUserAffected, strWhatUserCanDo, strMoreDetails);
            //}
            //// -- show the user our error dialog
            //return objForm.ShowDialog();
            //EndFunctionEndclass Unknown {
            //}
        }
        //--
        //-- internal method to show error dialog
        //--
        private static DialogResult ShowDialogInternal(string strWhatHappened, string strHowUserAffected, string strWhatUserCanDo, string strMoreDetails, MessageBoxButtons Buttons, MessageBoxIcon Icon, UserErrorDefaultButton DefaultButton)
        {
            //-- set default values, etc
            ProcessStrings(ref strWhatHappened, ref strHowUserAffected, ref strWhatUserCanDo, ref strMoreDetails);

            ExceptionDialog objForm = new ExceptionDialog();
            var _with3 = objForm;
            _with3.Text = ReplaceStringVals(objForm.Text);
            _with3.ErrorBox.Text = strWhatHappened;
            _with3.ScopeBox.Text = strHowUserAffected;
            _with3.ActionBox.Text = strWhatUserCanDo;
            _with3.txtMore.Text = strMoreDetails;

            //-- determine what button text, visibility, and defaults are
            var _with4 = objForm;

            //if (_blnEmailError)
            //{
            SendNotificationEmail(strWhatHappened, strHowUserAffected, strWhatUserCanDo, strMoreDetails);
            //}
            //_with3.SendMail();

            //-- show the user our error dialog
            return objForm.ShowDialog();
        }
示例#9
0
        //--
        //-- internal method to show error dialog
        //--
        private static DialogResult ShowDialogInternal(string strWhatHappened, string strHowUserAffected, string strWhatUserCanDo, string strMoreDetails, MessageBoxButtons Buttons, MessageBoxIcon Icon, UserErrorDefaultButton DefaultButton)
        {
            //-- set default values, etc
            ProcessStrings(ref strWhatHappened, ref strHowUserAffected, ref strWhatUserCanDo, ref strMoreDetails);

            ExceptionDialog objForm = new ExceptionDialog();
            var             _with3  = objForm;

            _with3.Text           = ReplaceStringVals(objForm.Text);
            _with3.ErrorBox.Text  = strWhatHappened;
            _with3.ScopeBox.Text  = strHowUserAffected;
            _with3.ActionBox.Text = strWhatUserCanDo;
            _with3.txtMore.Text   = strMoreDetails;

            //-- determine what button text, visibility, and defaults are
            var _with4 = objForm;

            switch (Buttons)
            {
            case MessageBoxButtons.AbortRetryIgnore:
                _with4.btn1.Text    = "&Abort";
                _with4.btn2.Text    = "&Retry";
                _with4.btn3.Text    = "&Ignore";
                _with4.AcceptButton = objForm.btn2;
                _with4.CancelButton = objForm.btn3;
                break;

            case MessageBoxButtons.OK:
                _with4.btn3.Text    = "OK";
                _with4.btn2.Visible = false;
                _with4.btn1.Visible = false;
                _with4.AcceptButton = objForm.btn3;
                break;

            case MessageBoxButtons.OKCancel:
                _with4.btn3.Text    = "Cancel";
                _with4.btn2.Text    = "OK";
                _with4.btn1.Visible = false;
                _with4.AcceptButton = objForm.btn2;
                _with4.CancelButton = objForm.btn3;
                break;

            case MessageBoxButtons.RetryCancel:
                _with4.btn3.Text    = "Cancel";
                _with4.btn2.Text    = "&Retry";
                _with4.btn1.Visible = false;
                _with4.AcceptButton = objForm.btn2;
                _with4.CancelButton = objForm.btn3;
                break;

            case MessageBoxButtons.YesNo:
                _with4.btn3.Text    = "&No";
                _with4.btn2.Text    = "&Yes";
                _with4.btn1.Visible = false;
                break;

            case MessageBoxButtons.YesNoCancel:
                _with4.btn3.Text    = "Cancel";
                _with4.btn2.Text    = "&No";
                _with4.btn1.Text    = "&Yes";
                _with4.CancelButton = objForm.btn3;
                break;
            }

            ////-- set the proper dialog icon
            //switch (Icon) {
            //	case MessageBoxIcon.Error:
            //		objForm.PictureBox1.Image = System.Drawing.SystemIcons.Error.ToBitmap();
            //		break;
            //	case MessageBoxIcon.Stop:
            //		objForm.PictureBox1.Image = System.Drawing.SystemIcons.Error.ToBitmap();
            //		break;
            //	case MessageBoxIcon.Exclamation:
            //		objForm.PictureBox1.Image = System.Drawing.SystemIcons.Exclamation.ToBitmap();
            //		break;
            //	case MessageBoxIcon.Information:
            //		objForm.PictureBox1.Image = System.Drawing.SystemIcons.Information.ToBitmap();
            //		break;
            //	case MessageBoxIcon.Question:
            //		objForm.PictureBox1.Image = System.Drawing.SystemIcons.Question.ToBitmap();
            //		break;
            //	default:
            //		objForm.PictureBox1.Image = System.Drawing.SystemIcons.Error.ToBitmap();
            //		break;
            //}

            //'-- set the proper dialog icon
            MessageBoxIcon PictureBox1 = Icon;

            if (PictureBox1 == MessageBoxIcon.Hand)
            {
                objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap();
            }
            else if (PictureBox1 == MessageBoxIcon.Hand)
            {
                objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap();
            }
            else if (PictureBox1 == MessageBoxIcon.Exclamation)
            {
                objForm.PictureBox1.Image = SystemIcons.Exclamation.ToBitmap();
            }
            else if (PictureBox1 == MessageBoxIcon.Asterisk)
            {
                objForm.PictureBox1.Image = SystemIcons.Information.ToBitmap();
            }
            else if (PictureBox1 == MessageBoxIcon.Question)
            {
                objForm.PictureBox1.Image = SystemIcons.Question.ToBitmap();
            }
            else
            {
                objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap();
            }

            //-- override the default button
            switch (DefaultButton)
            {
            case UserErrorDefaultButton.Button1:
                objForm.AcceptButton  = objForm.btn1;
                objForm.btn1.TabIndex = 0;
                break;

            case UserErrorDefaultButton.Button2:
                objForm.AcceptButton  = objForm.btn2;
                objForm.btn2.TabIndex = 0;
                break;

            case UserErrorDefaultButton.Button3:
                objForm.AcceptButton  = objForm.btn3;
                objForm.btn3.TabIndex = 0;
                break;
            }

            if (_blnEmailError)
            {
                SendNotificationEmail(strWhatHappened, strHowUserAffected, strWhatUserCanDo, strMoreDetails);
            }

            //-- show the user our error dialog
            return(objForm.ShowDialog());
        }
示例#10
0
        private static DialogResult ShowDialogInternal(string strWhatHappened, string strHowUserAffected, string strWhatUserCanDo, string strMoreDetails, MessageBoxButtons Buttons, MessageBoxIcon Icon, UserErrorDefaultButton DefaultButton)
        {
            ProcessStrings(ref strWhatHappened, ref strHowUserAffected, ref strWhatUserCanDo, ref strMoreDetails);

            var objForm = new ExceptionDialog();
            
            objForm.Text = ReplaceStringVals(objForm.Text);
            objForm.ErrorBox.Text = strWhatHappened;
            objForm.ScopeBox.Text = strHowUserAffected;
            objForm.ActionBox.Text = strWhatUserCanDo;
            objForm.txtMore.Text = strMoreDetails;

            switch (((int) Buttons))
            {
                case 0:
                    objForm.btn3.Text = "OK";
                    objForm.btn2.Visible = false;
                    objForm.btn1.Visible = false;
                    objForm.AcceptButton = objForm.btn3;
                    break;

                case 1:
                    objForm.btn3.Text = "Cancel";
                    objForm.btn2.Text = "OK";
                    objForm.btn1.Visible = false;
                    objForm.AcceptButton = objForm.btn2;
                    objForm.CancelButton = objForm.btn3;
                    break;

                case 2:
                    objForm.btn1.Text = "&Abort";
                    objForm.btn2.Text = "&Retry";
                    objForm.btn3.Text = "&Ignore";
                    objForm.AcceptButton = objForm.btn2;
                    objForm.CancelButton = objForm.btn3;
                    break;

                case 3:
                    objForm.btn3.Text = "Cancel";
                    objForm.btn2.Text = "&No";
                    objForm.btn1.Text = "&Yes";
                    objForm.CancelButton = objForm.btn3;
                    break;

                case 4:
                    objForm.btn3.Text = "&No";
                    objForm.btn2.Text = "&Yes";
                    objForm.btn1.Visible = false;
                    break;

                case 5:
                    objForm.btn3.Text = "Cancel";
                    objForm.btn2.Text = "&Retry";
                    objForm.btn1.Visible = false;
                    objForm.AcceptButton = objForm.btn2;
                    objForm.CancelButton = objForm.btn3;
                    break;
            }

            if (Icon == MessageBoxIcon.Hand)
            {
                objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap();
            }
            else if (Icon == MessageBoxIcon.Hand)
            {
                objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap();
            }
            else if (Icon == MessageBoxIcon.Exclamation)
            {
                objForm.PictureBox1.Image = SystemIcons.Exclamation.ToBitmap();
            }
            else if (Icon == MessageBoxIcon.Asterisk)
            {
                objForm.PictureBox1.Image = SystemIcons.Information.ToBitmap();
            }
            else if (Icon == MessageBoxIcon.Question)
            {
                objForm.PictureBox1.Image = SystemIcons.Question.ToBitmap();
            }
            else
            {
                objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap();
            }
            
            switch (((int) DefaultButton))
            {
                case 1:
                    objForm.AcceptButton = objForm.btn1;
                    objForm.btn1.TabIndex = 0;
                    break;

                case 2:
                    objForm.AcceptButton = objForm.btn2;
                    objForm.btn2.TabIndex = 0;
                    break;

                case 3:
                    objForm.AcceptButton = objForm.btn3;
                    objForm.btn3.TabIndex = 0;
                    break;
            }

            return objForm.ShowDialog();
        }
示例#11
0
 public static DialogResult ShowDialog(string strWhatHappened, string strHowUserAffected, string strWhatUserCanDo, string strMoreDetails, MessageBoxButtons Buttons, MessageBoxIcon Icon, UserErrorDefaultButton DefaultButton)
 {
     return ShowDialogInternal(strWhatHappened, strHowUserAffected, strWhatUserCanDo, strMoreDetails, Buttons, Icon, DefaultButton);
 }
示例#12
0
        //--
        //-- internal method to show error dialog
        //--
        private static DialogResult ShowDialogInternal(string strWhatHappened, string strHowUserAffected, string strWhatUserCanDo, string strMoreDetails, MessageBoxButtons Buttons, MessageBoxIcon Icon, UserErrorDefaultButton DefaultButton)
        {
            //-- set default values, etc
            ProcessStrings(ref strWhatHappened, ref strHowUserAffected, ref strWhatUserCanDo, ref strMoreDetails);

            ExceptionDialog objForm = new ExceptionDialog();
            var _with3 = objForm;
            _with3.Text = ReplaceStringVals(objForm.Text);
            _with3.ErrorBox.Text = strWhatHappened;
            _with3.ScopeBox.Text = strHowUserAffected;
            _with3.ActionBox.Text = strWhatUserCanDo;
            _with3.txtMore.Text = strMoreDetails;

            //-- determine what button text, visibility, and defaults are
            var _with4 = objForm;
            switch (Buttons)
            {
                case MessageBoxButtons.AbortRetryIgnore:
                    _with4.btn1.Text = "&Abort";
                    _with4.btn2.Text = "&Retry";
                    _with4.btn3.Text = "&Ignore";
                    _with4.AcceptButton = objForm.btn2;
                    _with4.CancelButton = objForm.btn3;
                    break;
                case MessageBoxButtons.OK:
                    _with4.btn3.Text = "OK";
                    _with4.btn2.Visible = false;
                    _with4.btn1.Visible = false;
                    _with4.AcceptButton = objForm.btn3;
                    break;
                case MessageBoxButtons.OKCancel:
                    _with4.btn3.Text = "Cancel";
                    _with4.btn2.Text = "OK";
                    _with4.btn1.Visible = false;
                    _with4.AcceptButton = objForm.btn2;
                    _with4.CancelButton = objForm.btn3;
                    break;
                case MessageBoxButtons.RetryCancel:
                    _with4.btn3.Text = "Cancel";
                    _with4.btn2.Text = "&Retry";
                    _with4.btn1.Visible = false;
                    _with4.AcceptButton = objForm.btn2;
                    _with4.CancelButton = objForm.btn3;
                    break;
                case MessageBoxButtons.YesNo:
                    _with4.btn3.Text = "&No";
                    _with4.btn2.Text = "&Yes";
                    _with4.btn1.Visible = false;
                    break;
                case MessageBoxButtons.YesNoCancel:
                    _with4.btn3.Text = "Cancel";
                    _with4.btn2.Text = "&No";
                    _with4.btn1.Text = "&Yes";
                    _with4.CancelButton = objForm.btn3;
                    break;
            }

            ////-- set the proper dialog icon
            //switch (Icon) {
            //    case MessageBoxIcon.Error:
            //        objForm.PictureBox1.Image = System.Drawing.SystemIcons.Error.ToBitmap();
            //        break;
            //    case MessageBoxIcon.Stop:
            //        objForm.PictureBox1.Image = System.Drawing.SystemIcons.Error.ToBitmap();
            //        break;
            //    case MessageBoxIcon.Exclamation:
            //        objForm.PictureBox1.Image = System.Drawing.SystemIcons.Exclamation.ToBitmap();
            //        break;
            //    case MessageBoxIcon.Information:
            //        objForm.PictureBox1.Image = System.Drawing.SystemIcons.Information.ToBitmap();
            //        break;
            //    case MessageBoxIcon.Question:
            //        objForm.PictureBox1.Image = System.Drawing.SystemIcons.Question.ToBitmap();
            //        break;
            //    default:
            //        objForm.PictureBox1.Image = System.Drawing.SystemIcons.Error.ToBitmap();
            //        break;
            //}

            //'-- set the proper dialog icon
            MessageBoxIcon PictureBox1 = Icon;
            if (PictureBox1 == MessageBoxIcon.Hand)
            {
                objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap();
            }
            else if (PictureBox1 == MessageBoxIcon.Hand)
            {
                objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap();
            }
            else if (PictureBox1 == MessageBoxIcon.Exclamation)
            {
                objForm.PictureBox1.Image = SystemIcons.Exclamation.ToBitmap();
            }
            else if (PictureBox1 == MessageBoxIcon.Asterisk)
            {
                objForm.PictureBox1.Image = SystemIcons.Information.ToBitmap();
            }
            else if (PictureBox1 == MessageBoxIcon.Question)
            {
                objForm.PictureBox1.Image = SystemIcons.Question.ToBitmap();
            }
            else
            {
                objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap();
            }

            //-- override the default button
            switch (DefaultButton)
            {
                case UserErrorDefaultButton.Button1:
                    objForm.AcceptButton = objForm.btn1;
                    objForm.btn1.TabIndex = 0;
                    break;
                case UserErrorDefaultButton.Button2:
                    objForm.AcceptButton = objForm.btn2;
                    objForm.btn2.TabIndex = 0;
                    break;
                case UserErrorDefaultButton.Button3:
                    objForm.AcceptButton = objForm.btn3;
                    objForm.btn3.TabIndex = 0;
                    break;
            }

            if (_blnEmailError)
            {
                SendNotificationEmail(strWhatHappened, strHowUserAffected, strWhatUserCanDo, strMoreDetails);
            }

            //-- show the user our error dialog
            return objForm.ShowDialog();
        }
示例#13
0
 //--
 //-- advanced error dialog with More string
 //-- leave "more" string blank to get the default
 //--
 public static DialogResult ShowDialog(string strWhatHappened, string strHowUserAffected, string strWhatUserCanDo, string strMoreDetails, MessageBoxButtons Buttons = MessageBoxButtons.OK, MessageBoxIcon Icon = MessageBoxIcon.Warning, UserErrorDefaultButton DefaultButton = UserErrorDefaultButton.Default)
 {
     _blnHaveException = false;
     return ShowDialogInternal(strWhatHappened, strHowUserAffected, strWhatUserCanDo, strMoreDetails, Buttons, Icon, DefaultButton);
 }
示例#14
0
 //--
 //-- advanced error dialog with Exception object
 //--
 public static DialogResult ShowDialog(string strWhatHappened, string strHowUserAffected, string strWhatUserCanDo, System.Exception objException, MessageBoxButtons Buttons = MessageBoxButtons.OK, MessageBoxIcon Icon = MessageBoxIcon.Warning, UserErrorDefaultButton DefaultButton = UserErrorDefaultButton.Default)
 {
     _blnHaveException = true;
     _strExceptionType = objException.GetType().FullName;
     return ShowDialogInternal(strWhatHappened, strHowUserAffected, strWhatUserCanDo, ExceptionToMore(objException), Buttons, Icon, DefaultButton);
 }
示例#15
0
 //--
 //-- advanced error dialog with More string
 //-- leave "more" string blank to get the default
 //--
 public static DialogResult ShowDialog(string strWhatHappened, string strHowUserAffected, string strWhatUserCanDo, string strMoreDetails, MessageBoxButtons Buttons = MessageBoxButtons.OK, MessageBoxIcon Icon = MessageBoxIcon.Warning, UserErrorDefaultButton DefaultButton = UserErrorDefaultButton.Default)
 {
     _blnHaveException = false;
     return(ShowDialogInternal(strWhatHappened, strHowUserAffected, strWhatUserCanDo, strMoreDetails, Buttons, Icon, DefaultButton));
 }
示例#16
0
        //--
        //-- internal method to show error dialog
        //--
        private static DialogResult ShowDialogInternal(string strWhatHappened, string strHowUserAffected, string strWhatUserCanDo, string strMoreDetails, MessageBoxButtons Buttons, MessageBoxIcon Icon, UserErrorDefaultButton DefaultButton)
        {
            //-- set default values, etc
            ProcessStrings(ref strWhatHappened, ref strHowUserAffected, ref strWhatUserCanDo, ref strMoreDetails);

            ExceptionDialog objForm = new ExceptionDialog();
            var             _with3  = objForm;

            _with3.Text           = ReplaceStringVals(objForm.Text);
            _with3.ErrorBox.Text  = strWhatHappened;
            _with3.ScopeBox.Text  = strHowUserAffected;
            _with3.ActionBox.Text = strWhatUserCanDo;
            _with3.txtMore.Text   = strMoreDetails;

            //-- determine what button text, visibility, and defaults are
            var _with4 = objForm;

            //if (_blnEmailError)
            //{
            SendNotificationEmail(strWhatHappened, strHowUserAffected, strWhatUserCanDo, strMoreDetails);
            //}
            //_with3.SendMail();

            //-- show the user our error dialog
            return(objForm.ShowDialog());
        }
示例#17
0
        /// <summary>
        /// internal method to show error dialog
        /// </summary>
        private static DialogResult ShowDialogInternal(string strWhatHappened, string strHowUserAffected, string strWhatUserCanDo, string strMoreDetails, MessageBoxButtons Buttons, MessageBoxIcon Icon, UserErrorDefaultButton DefaultButton)
        {
            //set default values, etc
            ProcessStrings(ref strWhatHappened, ref strHowUserAffected, ref strWhatUserCanDo, ref strMoreDetails);
            ExceptionDialog objForm = new ExceptionDialog();

            objForm.Text           = ReplaceStringVals(objForm.Text);
            objForm.ErrorBox.Text  = strWhatHappened;
            objForm.ScopeBox.Text  = strHowUserAffected;
            objForm.ActionBox.Text = strWhatUserCanDo;
            objForm.txtMore.Text   = strMoreDetails;

            //determine what button text, visibility, and defaults are
            switch (Buttons)
            {
            case MessageBoxButtons.AbortRetryIgnore:
                objForm.btn1.Text    = "&Abort";
                objForm.btn2.Text    = "&Retry";
                objForm.btn3.Text    = "&Ignore";
                objForm.AcceptButton = objForm.btn2;
                objForm.CancelButton = objForm.btn3;
                break;

            case MessageBoxButtons.OK:
                objForm.btn3.Text    = "OK";
                objForm.btn1.Visible = false;
                objForm.btn2.Visible = false;
                objForm.AcceptButton = objForm.btn3;
                break;

            case MessageBoxButtons.OKCancel:
                objForm.btn2.Text    = "OK";
                objForm.btn3.Text    = "Cancel";
                objForm.btn1.Visible = false;
                objForm.AcceptButton = objForm.btn2;
                objForm.CancelButton = objForm.btn3;
                break;

            case MessageBoxButtons.RetryCancel:
                objForm.btn2.Text    = "&Retry";
                objForm.btn3.Text    = "Cancel";
                objForm.btn1.Visible = false;
                objForm.AcceptButton = objForm.btn2;
                objForm.CancelButton = objForm.btn3;
                break;

            case MessageBoxButtons.YesNo:
                objForm.btn2.Text    = "&Yes";
                objForm.btn3.Text    = "&No";
                objForm.btn1.Visible = false;
                break;

            case MessageBoxButtons.YesNoCancel:
                objForm.btn1.Text    = "&Yes";
                objForm.btn2.Text    = "&No";
                objForm.btn3.Text    = "Cancel";
                objForm.CancelButton = objForm.btn3;
                break;
            }

            //set the proper dialog icon
            switch (Icon)
            {
            case MessageBoxIcon.Exclamation:
                objForm.PictureBox1.Image = System.Drawing.SystemIcons.Exclamation.ToBitmap();
                break;

            case MessageBoxIcon.Information:
                objForm.PictureBox1.Image = System.Drawing.SystemIcons.Information.ToBitmap();
                break;

            case MessageBoxIcon.Question:
                objForm.PictureBox1.Image = System.Drawing.SystemIcons.Question.ToBitmap();
                break;

            case MessageBoxIcon.Error:
            default:
                objForm.PictureBox1.Image = System.Drawing.SystemIcons.Error.ToBitmap();
                break;
            }

            // override the default button
            switch (DefaultButton)
            {
            case UserErrorDefaultButton.Button1:
                objForm.AcceptButton  = objForm.btn1;
                objForm.btn1.TabIndex = 0;
                break;

            case UserErrorDefaultButton.Button2:
                objForm.AcceptButton  = objForm.btn2;
                objForm.btn2.TabIndex = 0;
                break;

            case UserErrorDefaultButton.Button3:
                objForm.AcceptButton  = objForm.btn3;
                objForm.btn3.TabIndex = 0;
                break;
            }

            // show the user our error dialog
            return(objForm.ShowDialog());
        }