コード例 #1
0
        protected override IMessageBoxOption CreateMessageBoxOption(string message, string title,
                                                                    MessageIconType iconType)
        {
            var p = new MessageBoxOption(iconType)
            {
                Title   = title,
                Message = message,
                View    = Container.GetInstance <IShellMessageBoxView>() as FrameworkElement
            };

            p.View.DataContext = p;

            switch (iconType)
            {
            case MessageIconType.Info:
            case MessageIconType.Alert:
                p.Buttons = DialogButtons.Ok;
                break;

            case MessageIconType.Confirm:
                p.Buttons = DialogButtons.YesNo;
                break;

            //case MessageIconType.Custom:
            default:
                throw new ArgumentOutOfRangeException(nameof(iconType), iconType, null);
            }
            return(p);
        }
コード例 #2
0
 /// <summary>
 /// Displays a modal dialog box that contains a system icon, a set of buttons, and a brief application-specific message, such as status or error information. The message box returns an integer value that indicates which button the user clicked.
 /// </summary>
 /// <param name="text">The message to be displayed. If the string consists of more than one line, you can separate the lines using a carriage return and/or linefeed character between each line.</param>
 /// <param name="title">The dialog box title. If this parameter is NULL, the default title is Error.</param>
 /// <param name="buttons">The buttons displayed in the message box.</param>
 /// <param name="icon">Icon in the message box.</param>
 /// <returns></returns>
 public static DialogResult ShowMessageBox(string text,
                                           string title,
                                           MessageBoxButtons buttons             = MessageBoxButtons.Ok,
                                           MessageBoxIcon icon                   = MessageBoxIcon.None,
                                           MessageBoxDefaultButton defaultButton = MessageBoxDefaultButton.Button1,
                                           MessageBoxModality modality           = MessageBoxModality.AppModal,
                                           MessageBoxOption option               = 0)
 {
     return((DialogResult)MessageBox(IntPtr.Zero, text, title, (int)buttons | (int)icon | (int)defaultButton | (int)modality | (int)option));
 }
コード例 #3
0
        void ShowMessageBox(string message, string caption, MessageBoxOption options, Action <MessageBoxResult> resultAction)
        {
            var dispatcher = this.ContentItem.Screen.Details.Dispatcher;

            if (!dispatcher.CheckAccess())
            {
                //call ourselves on the proper thread
                Action action = delegate { this.ShowMessageBox(message, caption, options, resultAction); };
                dispatcher.BeginInvoke(action);
            }
            else
            {
                //we're on the UI thread, so show the message box and execute the result action
                var    result = this.ContentItem.Screen.ShowMessageBox(message, caption, options);
                Action action = delegate { resultAction(result); };
                Dispatchers.Main.BeginInvoke(action);
            }
        }