コード例 #1
0
        internal static AlertForm CreateAlertForm(string title, string message,
                                                  AlertType alertType,
                                                  AlertButtons alertButtons)
        {
            var image = GetGifImage(alertType);
            var sound = GetPopupSound(alertType);

            switch (alertButtons)
            {
            case AlertButtons.Ok:
            {
                return(new AlertForm().SetDetail(title, message, image, sound,
                                                 new List <AlertButtonViewModel>
                    {
                        AlertStaticButtons.OkButton(GetOkButtonPenColour(alertType))
                    }));
            }

            case AlertButtons.OkCancel:
            {
                return(new AlertForm().SetDetail(title, message, image, sound,
                                                 new List <AlertButtonViewModel>
                    {
                        AlertStaticButtons.OkButton(),
                        AlertStaticButtons.CancelButton()
                    }));
            }

            case AlertButtons.AbortRetryIgnore:
            {
                return(new AlertForm().SetDetail(title, message, image, sound,
                                                 new List <AlertButtonViewModel>
                    {
                        AlertStaticButtons.OkButton(),
                        AlertStaticButtons.RetryButton(),
                        AlertStaticButtons.IgnoreButton()
                    }));
            }

            case AlertButtons.YesNoCancel:
            {
                return(new AlertForm().SetDetail(title, message, image, sound,
                                                 new List <AlertButtonViewModel>
                    {
                        AlertStaticButtons.YesButton(),
                        AlertStaticButtons.NoButton(),
                        AlertStaticButtons.CancelButton()
                    }));
            }

            case AlertButtons.YesNo:
            {
                return(new AlertForm().SetDetail(title, message, image, sound,
                                                 new List <AlertButtonViewModel>
                    {
                        AlertStaticButtons.YesButton(),
                        AlertStaticButtons.NoButton()
                    }));
            }

            case AlertButtons.RetryCancel:
            {
                return(new AlertForm().SetDetail(title, message, image, sound,
                                                 new List <AlertButtonViewModel>
                    {
                        AlertStaticButtons.RetryButton(),
                        AlertStaticButtons.CancelButton()
                    }));
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(alertButtons), alertButtons, null);
            }
        }
コード例 #2
0
        internal static AlertForm CreateAlertForm(Control parentControl, string title, string message,
                                                  string messagesTitle, string exceptionDetail, string rtf,
                                                  AlertType alertType, AlertButtons alertButtons)
        {
            var image        = GetGifImage(alertType);
            var sound        = GetPopupSound(alertType);
            var isErrorAlert = alertType == AlertType.Error;

            var alertForm = new AlertForm
            {
                ParentControl   = HelperMethods.GetCurrentlyActiveForm(parentControl),
                FormTitle       = title,
                MessagesTitle   = messagesTitle,
                FormImage       = image,
                FormMessage     = message,
                SystemSound     = sound,
                IsErrorAlert    = isErrorAlert,
                ExceptionDetail = exceptionDetail,
                Rtf             = rtf
            };

            switch (alertButtons)
            {
            case AlertButtons.Ok:
            {
                alertForm.FormButtons = new List <AlertButtonViewModel>
                {
                    AlertStaticButtons.OkButton(GetOkButtonPenColour(alertType))
                };
                break;
            }

            case AlertButtons.OkCancel:
            {
                alertForm.FormButtons = new List <AlertButtonViewModel>
                {
                    AlertStaticButtons.OkButton(),
                        AlertStaticButtons.CancelButton()
                };
                break;
            }

            case AlertButtons.AbortRetryIgnore:
            {
                alertForm.FormButtons = new List <AlertButtonViewModel>
                {
                    AlertStaticButtons.OkButton(),
                        AlertStaticButtons.RetryButton(),
                        AlertStaticButtons.IgnoreButton()
                };
                break;
            }

            case AlertButtons.YesNoCancel:
            {
                alertForm.FormButtons = new List <AlertButtonViewModel>
                {
                    AlertStaticButtons.YesButton(),
                        AlertStaticButtons.NoButton(),
                        AlertStaticButtons.CancelButton()
                };
                break;
            }

            case AlertButtons.YesNo:
            {
                alertForm.FormButtons = new List <AlertButtonViewModel>
                {
                    AlertStaticButtons.YesButton(),
                        AlertStaticButtons.NoButton()
                };
                break;
            }

            case AlertButtons.RetryCancel:
            {
                alertForm.FormButtons = new List <AlertButtonViewModel>
                {
                    AlertStaticButtons.RetryButton(),
                        AlertStaticButtons.CancelButton()
                };
                break;
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(alertButtons), alertButtons, null);
            }

            return(alertForm);
        }