Esempio n. 1
0
        private void MessageMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            e.Handled = true;
            if (!(sender is ContentControl contentControl))
            {
                return;
            }

            if (!(contentControl.DataContext is Message message))
            {
                return;
            }

            if (!(contentControl.Tag is MessagePanel messagePanel))
            {
                return;
            }

            var messageBoxSettings = new MessageBoxSettings
            {
                Text                   = string.IsNullOrWhiteSpace(message.TextVerbose) ? message.Text : message.TextVerbose,
                Title                  = message.Title,
                MessageType            = message.MessageType,
                MessageBoxButtons      = MessageBoxButtons.Ok,
                CopyToClipboardEnabled = true,
                MessageBoxText         = new MessageBoxText {
                    TextAlignment = messagePanel.ShowMessageTextAlignment
                }
            };

            Dialog.ShowMessage(messageBoxSettings);
        }
Esempio n. 2
0
        /// <summary>
        /// Shows a message and returns the users response.
        /// </summary>
        /// <param name="messageBoxSettings">The message to show including text, title and
        /// message type, buttons and whether to enable copying the message to a clipboard</param>
        /// <returns>The users response to the message.</returns>
        public static MessageBoxResult ShowMessage(MessageBoxSettings messageBoxSettings)
        {
            var model = new MessageBoxViewModel(messageBoxSettings);
            var view  = new MessageBoxView();

            view.DataContext = model;
            view.ShowDialog();
            messageBoxSettings.MessageBoxResult = model.MessageBoxResult;
            return(messageBoxSettings.MessageBoxResult);
        }
Esempio n. 3
0
        /// <summary>
        /// Shows a message and returns the users response.
        /// </summary>
        /// <param name="text">The message text.</param>
        /// <param name="title">The message title.</param>
        /// <param name="messageType">The message type.</param>
        /// <param name="buttons">The buttons to display.</param>
        /// <param name="copyToClipboardEnabled">Enable copying message to the clipboard. Defaults is false.</param>
        /// <returns>The users response to the message.</returns>
        public static MessageBoxResult ShowMessage(string text, string title, MessageType messageType,
                                                   MessageBoxButtons buttons, bool copyToClipboardEnabled = false)
        {
            var message = new MessageBoxSettings()
            {
                Text                   = text,
                Title                  = title,
                MessageType            = messageType,
                MessageBoxButtons      = buttons,
                CopyToClipboardEnabled = copyToClipboardEnabled
            };

            return(ShowMessage(message));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageBoxViewModel"/>.
        /// </summary>
        /// <param name="messageBoxSettings">The settings of the messsage to display.</param>
        public MessageBoxViewModel(MessageBoxSettings messageBoxSettings)
        {
            this.messageBoxSettings = messageBoxSettings;

            TextAlignment = messageBoxSettings.MessageBoxText.TextAlignment;

            CopyToClipboardEnabled = messageBoxSettings.CopyToClipboardEnabled;

            switch (messageBoxSettings.MessageBoxButtons)
            {
            case MessageBoxButtons.Ok:
                ButtonLeftVisible   = false;
                ButtonLeftText      = String.Empty;
                ButtonCentreVisible = true;
                ButtonCentreText    = OK;
                ButtonRightVisible  = false;
                ButtonRightText     = String.Empty;
                break;

            case MessageBoxButtons.OkCancel:
                ButtonLeftVisible   = true;
                ButtonLeftText      = OK;
                ButtonCentreVisible = false;
                ButtonCentreText    = String.Empty;
                ButtonRightVisible  = true;
                ButtonRightText     = CANCEL;
                break;

            case MessageBoxButtons.YesNo:
                ButtonLeftVisible   = true;
                ButtonLeftText      = YES;
                ButtonCentreVisible = false;
                ButtonCentreText    = String.Empty;
                ButtonRightVisible  = true;
                ButtonRightText     = NO;
                break;

            case MessageBoxButtons.YesNoCancel:
                ButtonLeftVisible   = true;
                ButtonLeftText      = YES;
                ButtonCentreVisible = true;
                ButtonCentreText    = NO;
                ButtonRightVisible  = true;
                ButtonRightText     = CANCEL;
                break;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Shows a message and returns the users response.
        /// </summary>
        /// <param name="messageBoxSettings">The message to show including text, title and
        /// message type, buttons and whether to enable copying the message to a clipboard</param>
        /// <returns>The users response to the message.</returns>
        public static MessageBoxResult ShowMessage(MessageBoxSettings messageBoxSettings)
        {
            if (messageBoxSettings == null)
            {
                throw new ArgumentNullException(nameof(messageBoxSettings));
            }

            var model = new MessageBoxViewModel(messageBoxSettings);
            var view  = new MessageBoxView
            {
                DataContext = model
            };

            view.ShowDialog();
            messageBoxSettings.MessageBoxResult = model.MessageBoxResult;
            return(messageBoxSettings.MessageBoxResult);
        }