Exemplo n.º 1
0
 public static DialogResult XtraMessageBoxForm(string message, string caption)
 {
     try
     {
         WaitFormUtils.CloseWaitForm();
         XtraMessageBoxArgs xtraMessageBoxArgs = new XtraMessageBoxArgs(null, message, caption, MessageBoxButtonsToDialogResults(MessageBoxButtons.YesNo), MessageBoxIconToIcon(MessageBoxIcon.Question), MessageBoxDefaultButtonToInt(MessageBoxDefaultButton.Button1));
         XtraMessageBoxForm form = new XtraMessageBoxForm();
         foreach (Control ctr in form.Controls)
         {
             if (ctr is SimpleButton)
             {
                 ((SimpleButton)ctr).Appearance.Font = new System.Drawing.Font("宋体", 18, System.Drawing.FontStyle.Regular);
             }
         }
         form.Font = new System.Drawing.Font("宋体", 18, System.Drawing.FontStyle.Regular);
         return(form.ShowMessageBoxDialog(xtraMessageBoxArgs));
     }
     finally
     {
         ProcessUtils.ClearMemory();
     }
 }
Exemplo n.º 2
0
        private static DialogResult[] MessageBoxButtonsToDialogResults(MessageBoxButtons buttons)
        {
            try
            {
                if (!Enum.IsDefined(typeof(MessageBoxButtons), buttons))
                {
                    throw new InvalidEnumArgumentException("buttons", (int)buttons, typeof(DialogResult));
                }
                switch (buttons)
                {
                case MessageBoxButtons.OK:
                {
                    return(new DialogResult[]
                        {
                            DialogResult.OK
                        });
                }

                case MessageBoxButtons.OKCancel:
                {
                    return(new DialogResult[]
                        {
                            DialogResult.OK,
                            DialogResult.Cancel
                        });
                }

                case MessageBoxButtons.AbortRetryIgnore:
                {
                    return(new DialogResult[]
                        {
                            DialogResult.Abort,
                            DialogResult.Retry,
                            DialogResult.Ignore
                        });
                }

                case MessageBoxButtons.YesNoCancel:
                {
                    return(new DialogResult[]
                        {
                            DialogResult.Yes,
                            DialogResult.No,
                            DialogResult.Cancel
                        });
                }

                case MessageBoxButtons.YesNo:
                {
                    return(new DialogResult[]
                        {
                            DialogResult.Yes,
                            DialogResult.No
                        });
                }

                case MessageBoxButtons.RetryCancel:
                {
                    return(new DialogResult[]
                        {
                            DialogResult.Retry,
                            DialogResult.Cancel
                        });
                }

                default:
                {
                    throw new ArgumentException("buttons");
                }
                }
            }
            finally
            {
                ProcessUtils.ClearMemory();
            }
        }