private void OpenMessageBox(object parameter)
        {
            var message = new Message() {Text = MessageBoxText, Title = String.Format("Show {0}", MessageIcon)};
            SetMessageImage(message, MessageIcon);

            var messageBoxSettings = new MessageBoxSettings() {Message = message};

            switch (MessageBoxButton)
            {
                case "Ok":
                    messageBoxSettings.MessageBoxButtons = MessageBoxButtonsEnum.Ok;
                    break;
                case "Ok Cancel":
                    messageBoxSettings.MessageBoxButtons = MessageBoxButtonsEnum.OkCancel;
                    break;
                case "Yes No":
                    messageBoxSettings.MessageBoxButtons = MessageBoxButtonsEnum.YesNo;
                    break;
                case "Yes No Cancel":
                    messageBoxSettings.MessageBoxButtons = MessageBoxButtonsEnum.YesNoCancel;
                    break;
            }

            var result = ShowMessageBox(messageBoxSettings);
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageBoxViewModel"/>.
        /// </summary>
        /// <param name="message">The message to display.</param>
        /// <param name="messageBoxButtons">The buttons to display.</param>
        /// <param name="copyToClipboardEnabled">Indicates whether to enable copy to clipboard.</param>
        public MessageBoxViewModel(Message message, MessageBoxButtonsEnum messageBoxButtons, bool copyToClipboardEnabled)
        {
            this.message = message;
            CopyToClipboardEnabled = copyToClipboardEnabled;

            switch (messageBoxButtons)
            {
                case MessageBoxButtonsEnum.Ok:
                    ButtonLeftVisible = false;
                    ButtonLeftText = String.Empty;
                    ButtonCentreVisible = true;
                    ButtonCentreText = OK;
                    ButtonRightVisible = false;
                    ButtonRightText = String.Empty;
                    break;
                case MessageBoxButtonsEnum.OkCancel:
                    ButtonLeftVisible = true;
                    ButtonLeftText = OK;
                    ButtonCentreVisible = false;
                    ButtonCentreText = String.Empty;
                    ButtonRightVisible = true;
                    ButtonRightText = CANCEL;
                    break;
                case MessageBoxButtonsEnum.YesNo:
                    ButtonLeftVisible = true;
                    ButtonLeftText = YES;
                    ButtonCentreVisible = false;
                    ButtonCentreText = String.Empty;
                    ButtonRightVisible = true;
                    ButtonRightText = NO;
                    break;
                case MessageBoxButtonsEnum.YesNoCancel:
                    ButtonLeftVisible = true;
                    ButtonLeftText = YES;
                    ButtonCentreVisible = true;
                    ButtonCentreText = NO;
                    ButtonRightVisible = true;
                    ButtonRightText = CANCEL;
                    break;
            }
        }
Пример #3
0
 private void ShowMessage(object parameter)
 {
     var message = new Message() { Text = MessageText };
     SetMessageImage(message, MessageType);
     ShowMessage(message, true);
 }
Пример #4
0
 private void SetMessageImage(Message message, string image)
 {
     switch (image)
     {
         case "Info":
             message.MessageType = MessageTypeEnum.Info;
             break;
         case "Warn":
             message.MessageType = MessageTypeEnum.Warn;
             break;
         case "Error":
             message.MessageType = MessageTypeEnum.Error;
             break;
         case "Question":
             message.MessageType = MessageTypeEnum.Question;
             break;
     }
 }
Пример #5
0
 /// <summary>
 /// Adds a message to the message collection and then shows it.
 /// </summary>
 /// <param name="message">The message to add.</param>
 /// <param name="appendMessage">Indicates whether the message is to be  
 /// appened to existing messages or existing messages are first cleared.</param>
 protected void ShowMessage(Message message, bool appendMessage = false)
 {
     var messagesToShow = new List<Message>();
     messagesToShow.Add(message);
     ShowMessages(messagesToShow, appendMessage);
 }