Beispiel #1
0
 public static void popup(string message, MessageBoxImage mbi)
 {
     mainWindow.Dispatcher.Invoke(mainWindow.DelShowOkMsg, message, mbi);
     mainWindow.Dispatcher.BeginInvoke(mainWindow.DelWriteLog, message);
     Trace.WriteLine(message);
     Trace.Flush();
 }
Beispiel #2
0
 public AlertDialogBackend()
 {
     this.buttons = MessageBoxButton.OKCancel;
     this.icon = MessageBoxImage.None;
     this.options = MessageBoxOptions.None;
     this.defaultResult = MessageBoxResult.Cancel;
 }
Beispiel #3
0
 public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)
 {
     if (_provider != null)
         return _provider.Show(messageBoxText, caption, button, icon, defaultResult);
     else
         return MessageBox.Show(messageBoxText, caption, button, icon, defaultResult);
 }
Beispiel #4
0
        public Task<MessageBoxResult> ShowAsync(string message, string title, MessageBoxButton buttons, MessageBoxImage image)
        {
            var tcs = new TaskCompletionSource<MessageBoxResult>();

            _dispatcherService.CurrentDispatcher.BeginInvoke(new Action(() =>
            {
                MessageBoxResult result;
                Window activeWindow = null;
                for (var i = 0; i < Application.Current.Windows.Count; i++)
                {
                    var win = Application.Current.Windows[i];
                    if ((win != null) && (win.IsActive))
                    {
                        activeWindow = win;
                        break;
                    }
                }

                if (activeWindow != null)
                {
                    result = MessageBox.Show(activeWindow, message, title, buttons, image);
                }
                else
                {
                    result = MessageBox.Show(message, title, buttons, image);
                }

                tcs.SetResult(result);
            }));


            return tcs.Task;
        }
Beispiel #5
0
        public static MessageBoxResult Show(Window parent, string msg, string title, MessageBoxButton btns, MessageBoxImage icon)
        {
            // Create a callback delegate
            _hookProcDelegate = new Win32.WindowsHookProc(HookCallback);

            // Remember the title & message that we'll look for.
            // The hook sees *all* windows, so we need to make sure we operate on the right one.
            _msg = msg;
            _title = title;

            // Set the hook.
            // Suppress "GetCurrentThreadId() is deprecated" warning.
            // It's documented that Thread.ManagedThreadId doesn't work with SetWindowsHookEx()
            #pragma warning disable 0618
            _hHook = Win32.SetWindowsHookEx(Win32.WH_CBT, _hookProcDelegate, IntPtr.Zero, AppDomain.GetCurrentThreadId());
            #pragma warning restore 0618

            // Pop a standard MessageBox. The hook will center it.
             MessageBoxResult rslt;
             if (parent == null)
                 rslt = MessageBox.Show(msg, title, btns, icon);
             else
                 rslt = MessageBox.Show(parent, msg, title, btns, icon);

            // Release hook, clean up (may have already occurred)
            Unhook();

            return rslt;
        }
        public static MessageBoxResult Show(
            Action<Window> setOwner,
            string messageBoxText, 
            string caption, 
            MessageBoxButton button, 
            MessageBoxImage icon, 
            MessageBoxResult defaultResult, 
            MessageBoxOptions options)
        {
            if ((options & MessageBoxOptions.DefaultDesktopOnly) == MessageBoxOptions.DefaultDesktopOnly)
            {
                throw new NotImplementedException();
            }

            if ((options & MessageBoxOptions.ServiceNotification) == MessageBoxOptions.ServiceNotification)
            {
                throw new NotImplementedException();
            }

            _messageBoxWindow = new WpfMessageBoxWindow();

            setOwner(_messageBoxWindow);

            PlayMessageBeep(icon);

            _messageBoxWindow._viewModel = new MessageBoxViewModel(_messageBoxWindow, caption, messageBoxText, button, icon, defaultResult, options);
            _messageBoxWindow.DataContext = _messageBoxWindow._viewModel;
            _messageBoxWindow.ShowDialog();
            return _messageBoxWindow._viewModel.Result;
        }
        private static MessageBoxResult DisplayMessage(string message, MessageBoxImage image, MessageBoxButton button, Window owner)
        {
            var dialogOwner = owner;
            var result = MessageBoxResult.None;

            if (dialogOwner != null)
            {
                if (dialogOwner.Dispatcher != null)
                {
                    dialogOwner.Dispatcher.adoptAsync(() =>
                    {
                        result = MessageBox.Show(dialogOwner, message, "MeTL", button, image);
                    });
                } else
                {
                    Application.Current.Dispatcher.adoptAsync(() =>
                    {
                        result = MessageBox.Show(dialogOwner, message, "MeTL", button, image);
                    });

                }
            }
            else
            {
                // calling from non-ui thread
                if (Application.Current != null && Application.Current.Dispatcher != null)
                    Application.Current.Dispatcher.adoptAsync(() =>
                    {
                        dialogOwner = GetMainWindow();
                        result = MessageBox.Show(dialogOwner, message, "MeTL", button, image);
                    });
            }

            return result;
        }
 public MoqPopup(string headerText, string discriptionText, MessageBoxImage imageType, MessageBoxButton buttons)
 {
     Header = headerText;
     Description = discriptionText;
     ImageType = imageType;
     Buttons = buttons;
 }
 ///////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Displays a customized message box in front of the specified window.
 /// </summary>
 /// <param name="owner">Owner window of the message box.</param>
 /// <param name="messageBoxText">Text to display.</param>
 /// <param name="caption">Title bar caption to display.</param>
 /// <param name="button">A value that specifies which button or buttons to display.</param>
 /// <param name="icon">Icon to display.</param>
 /// <returns>Button value which message box is clicked by the user.</returns>
 public static MessageBoxExButtonType Show(Window owner, string messageBoxText, string caption,
                                           MessageBoxButtons button, MessageBoxImage icon)
 {
     bool checkBoxState = false; // NOTE: ignored
     MessageBoxEx msbBox = new MessageBoxEx();
     return msbBox._Show(owner, messageBoxText, caption, button, icon, null, ref checkBoxState);
 }
Beispiel #10
0
 public MessageBoxMessage(string text, string caption, MessageBoxImage image)
 {
     this.Text = text;
     this.Caption = caption;
     this.Button = MessageBoxButton.OK;
     this.Image = image;
 }
 public static ImageSource MessageBoxImageToImageSource(MessageBoxImage image)
 {
     Icon icon;
     switch (image)
     {
         case MessageBoxImage.None:
             icon = null;
             break;
         case MessageBoxImage.Error: // also MessageBoxImage.Hand ans MessageBoxImage.Stop:
             icon = SystemIcons.Hand;
             break;
         case MessageBoxImage.Question:
             icon = SystemIcons.Question;
             break;
         case MessageBoxImage.Warning: // also MessageBoxImage.Exclamation
             icon = SystemIcons.Exclamation;
             break;
         case MessageBoxImage.Information: //case MessageBoxImage.Asterisk
             icon = SystemIcons.Asterisk;
             break;
         default:
             icon = SystemIcons.Application;
             break;
     }
     return (icon == null) ? null : Imaging.CreateBitmapSourceFromHIcon(icon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
 }
Beispiel #12
0
        private static MessageIcon GetMessageIcon(MessageBoxImage image)
        {
            MessageIcon icon;
            switch (image)
            {
                case MessageBoxImage.Exclamation:
                    icon = MessageIcon.Warning;
                    break;

                case MessageBoxImage.Asterisk:
                    icon = MessageIcon.Information;
                    break;

                case MessageBoxImage.Hand:
                    icon = MessageIcon.Error;
                    break;

                case MessageBoxImage.Question:
                    icon = MessageIcon.Question;
                    break;

                default:
                    icon = MessageIcon.None;
                    break;
            }
            return icon;
        }
Beispiel #13
0
 public static MessageBoxResult MyMessageBox(string p_strMessage, MessageBoxButton p_objButtons,MessageBoxImage p_objImage = MessageBoxImage.Question)
 {
     return MessageBox.Show(p_strMessage, APP_NAME,
                            p_objButtons,
                            p_objImage,
                            MessageBoxResult.OK);
 }
        public static MessageBoxResult Show(
            Action<Window> setOwner,
            CultureInfo culture,
            string messageBoxText,
            string caption,
            WPFMessageBoxButton button,
            MessageBoxImage icon,
            MessageBoxResult defaultResult,
            MessageBoxOptions options)
        {
            if ((options & MessageBoxOptions.DefaultDesktopOnly) == MessageBoxOptions.DefaultDesktopOnly)
            {
                throw new NotImplementedException();
            }

            if ((options & MessageBoxOptions.ServiceNotification) == MessageBoxOptions.ServiceNotification)
            {
                throw new NotImplementedException();
            }
            //LocalizeDictionary.Instance.Culture = CultureInfo.GetCultureInfo("de");
            _messageBoxWindow = new WPFMessageBoxWindow();

            setOwner(_messageBoxWindow);

            PlayMessageBeep(icon);
            //FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(
            //            XmlLanguage.GetLanguage(culture.IetfLanguageTag)));
            _messageBoxWindow._viewModel = new MessageBoxViewModel(_messageBoxWindow, culture, caption, messageBoxText, button, icon, defaultResult, options);
            _messageBoxWindow.DataContext = _messageBoxWindow._viewModel;
            _messageBoxWindow.ShowDialog();
            return _messageBoxWindow._viewModel.Result;
        }
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="ErrorCd">メッセージコード</param>
 /// <param name="DialogType">ダイアログの種類</param>
 public DialogErrorEntity(MessageBoxImage DialogType, bool ContinueFlg, string ErrorCd, params string[] AddMessage)
 {
     this.ErrorCd = ErrorCd;
     this.ContinueFlg = ContinueFlg;
     this.DialogType = DialogType;
     this.AddMessage = AddMessage;
 }
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="MsgType">メッセージボックスに表示するアイコンの種類</param>
 /// <param name="ContinueFlg">処理を継続できるかのフラグ(true:可能、false:不可)</param>
 /// <param name="MsgCd">メッセージコード</param>
 /// <param name="AddMsg">追加メッセージ</param>
 public MessageEventArgs(MessageBoxImage MsgType, bool ContinueFlg, string MsgCd, params object[] AddMsg)
 {
     this.MsgType = MsgType;
     this.ContinueFlg = ContinueFlg;
     this.MsgCd = MsgCd;
     this.AddMsg = AddMsg;
 }
Beispiel #17
0
 public static void ShowAsync(string text, MessageBoxButton button = MessageBoxButton.OK,
     MessageBoxImage image = MessageBoxImage.Information, MessageBoxResult defaultButton = MessageBoxResult.OK)
 {
     new Thread(
         new ThreadStart(delegate { MessageBox.Show(text, Resources.AppName, button, image, defaultButton); }))
         .Start();
 }
		private static void PlayMessageBeep(MessageBoxImage icon)
		{
			switch (icon)
			{
				//case MessageBoxImage.Hand:
				//case MessageBoxImage.Stop:
				case MessageBoxImage.Error:
					SystemSounds.Hand.Play();
					break;

				//case MessageBoxImage.Exclamation:
				case MessageBoxImage.Warning:
					SystemSounds.Exclamation.Play();
					break;

				case MessageBoxImage.Question:
					SystemSounds.Question.Play();
					break;

				//case MessageBoxImage.Asterisk:
				case MessageBoxImage.Information:
					SystemSounds.Asterisk.Play();
					break;

				default:
					SystemSounds.Beep.Play();
					break;
			}
		}
        /// <summary>
        /// Shows MessageBox dialog with specified buttons texts
        /// </summary>
        /// <param name="message">Message to display</param>
        /// <param name="title">Title to display</param>
        /// <param name="buttons">Optonal buttons definiton</param>
        /// <param name="icon">Optional icon definition</param>
        /// <param name="buttonsTexts">Optional buttons texts</param>
        /// <returns></returns>
        public static MessageBoxResult ShowDialog(
            string message,
            string title,
            MessageBoxButton buttons = MessageBoxButton.OK,
            MessageBoxImage icon = MessageBoxImage.Information,
            Dictionary<Buttons, string> buttonsTexts = null)
        {
            try
            {
                // Register buttons texts
                if (buttonsTexts != null)
                {
                    foreach (Buttons button in buttonsTexts.Keys)
                    {
                        // Set given text to a proper buttons
                        switch (button)
                        {
                            case Buttons.OK:
                                MessageBoxManager.OK = buttonsTexts[button];
                                break;

                            case Buttons.YES:
                                MessageBoxManager.Yes = buttonsTexts[button];
                                break;

                            case Buttons.NO:
                                MessageBoxManager.No = buttonsTexts[button];
                                break;

                            case Buttons.CANCEL:
                                MessageBoxManager.Cancel = buttonsTexts[button];
                                break;
                        }
                    }

                    // Register buttons
                    MessageBoxManager.Register();
                }

                MessageBoxResult result =
                    System.Windows.MessageBox.Show(message, title, buttons, icon);

                return result;
            }
            catch (Exception ex)
            {
                Karafa.Errors.KarafaLogger.LogError(ex);

                return default(MessageBoxResult);
            }
            finally
            {
                if (buttonsTexts != null)
                {
                    // Unregister buttons
                    MessageBoxManager.Unregister();
                }
            }
        }
Beispiel #20
0
		public Command Run (WindowFrame transientFor, MessageDescription message)
		{
			this.icon = GetIcon (message.Icon);
			if (ConvertButtons (message.Buttons, out buttons)) {
				// Use a system message box
				if (message.SecondaryText == null)
					message.SecondaryText = String.Empty;
				else {
					message.Text = message.Text + "\r\n\r\n" + message.SecondaryText;
					message.SecondaryText = String.Empty;
				}
				var wb = (WindowFrameBackend)Toolkit.GetBackend (transientFor);
				if (wb != null) {
					this.dialogResult = MessageBox.Show (wb.Window, message.Text, message.SecondaryText,
														this.buttons, this.icon, this.defaultResult, this.options);
				}
				else {
					this.dialogResult = MessageBox.Show (message.Text, message.SecondaryText, this.buttons,
														this.icon, this.defaultResult, this.options);
				}
				return ConvertResultToCommand (this.dialogResult);
			}
			else {
				// Custom message box required
				Dialog dlg = new Dialog ();
				dlg.Resizable = false;
				dlg.Padding = 0;
				HBox mainBox = new HBox { Margin = 25 };

				if (message.Icon != null) {
					var image = new ImageView (message.Icon.WithSize (32,32));
					mainBox.PackStart (image, vpos: WidgetPlacement.Start);
				}
				VBox box = new VBox () { Margin = 3, MarginLeft = 8, Spacing = 15 };
				mainBox.PackStart (box, true);
				var text = new Label {
					Text = message.Text ?? ""
				};
				Label stext = null;
				box.PackStart (text);
				if (!string.IsNullOrEmpty (message.SecondaryText)) {
					stext = new Label {
						Text = message.SecondaryText
					};
					box.PackStart (stext);
				}
				dlg.Buttons.Add (message.Buttons.ToArray ());
				if (mainBox.Surface.GetPreferredSize (true).Width > 480) {
					text.Wrap = WrapMode.Word;
					if (stext != null)
						stext.Wrap = WrapMode.Word;
					mainBox.WidthRequest = 480;
				}
				var s = mainBox.Surface.GetPreferredSize (true);

				dlg.Content = mainBox;
				return dlg.Run ();
			}
		}
 public MessageBoxMessage(string text, string caption, MessageBoxButton button, MessageBoxImage icon)
 {
     this.Text = text;
     this.Caption = caption;
     this.Button = button;
     this.Icon = icon;
     this.Result = MessageBoxResult.None;
 }
Beispiel #22
0
 /// <summary>
 /// OKボタン付きのダイアログを表示する。
 /// </summary>
 /// <param name="message">表示メッセージ。</param>
 /// <param name="image">表示アイコン。</param>
 public static void ShowAlert(string message, MessageBoxImage image)
 {
     MessageBox.Show(
         message,
         res.Resources.Dialog_Caption,
         MessageBoxButton.OK,
         image);
 }
Beispiel #23
0
 public InformationMessage(string text, string caption, MessageBoxImage image, string messageKey)
     : base(messageKey)
 {
     Text = text;
     Caption = caption;
     MessageKey = messageKey;
     Image = image;
 }
Beispiel #24
0
 public MessageBoxMessage(string text, string caption, MessageBoxButton button, MessageBoxImage image, Action<MessageBoxResult> resultCallback)
 {
     this.Text = text;
     this.Caption = caption;
     this.Button = button;
     this.Image = image;
     this.ResultCallback = resultCallback;
 }
Beispiel #25
0
 public Warning(string text, string title, MessageBoxButton button, MessageBoxImage image)
 {
     messageTitle = title;
     messageText = text;
     messageImage = image;
     messageButton = button;
     result = MessageBox.Show(messageText, messageTitle, messageButton, messageImage);
 }
Beispiel #26
0
 public ViewModel(string message, string title, MessageBoxButton buttons, DialogType dialogType = DialogType.Large, MessageBoxImage icon = MessageBoxImage.Question)
 {
   Message = message;
   Title = title;
   DialogType = dialogType;
   Buttons = buttons;
   Icon  = GetIconName(icon);
 }
Beispiel #27
0
 /// <summary>
 /// メッセージボックスを表示します。
 /// </summary>
 /// <param name="message">メッセージテキスト</param>
 /// <param name="button">表示ボタン種別</param>
 /// <param name="icon">表示アイコン種別</param>
 /// <returns>メッセージボックス選択結果</returns>
 private MessageBoxResult Show(string message, MessageBoxButton button, MessageBoxImage icon)
 {
     var title = Products.Current.Title;
     var owner = ViewUtility.GetActiveWindow();
     return owner == null
         ? MessageDialog.Show(message, title, button, icon)
         : MessageDialog.Show(owner, message, title, button, icon);
 }
 // Shows a message box from a separate worker thread. The specified asynchronous 
 // result object allows the caller to monitor whether the message box has been 
 // closed. This is useful for showing only one message box at a time. 
 public void ShowMessageBoxAsync(string strMessage, string strCaption, MessageBoxButton enmButton, MessageBoxImage enmImage, ref IAsyncResult asyncResult)
 {
     if ((asyncResult == null) || asyncResult.IsCompleted)
     {
         ShowMessageBoxDelegate caller = new ShowMessageBoxDelegate(ShowMessageBox);
         asyncResult = caller.BeginInvoke(strMessage, strCaption, enmButton, enmImage, null, null);
     }
 }
 public ShowDialogMessage(string title, string content, MessageBoxImage icon, MessageBoxButton button, Action<MessageBoxResult> callback = null)
 {
     Title = title;
     Content = content;
     Icon = icon;
     Button = button;
     Callback = callback;
 }
Beispiel #30
0
        /// <summary>
        /// Displays the specified message box as a modal dialog.
        /// </summary>
        /// <param name="mb">The message box to display.</param>
        /// <param name="text">The text to display.</param>
        /// <param name="caption">The caption to display.</param>
        /// <param name="button">A <see cref="MessageBoxButton"/> value that specifies the set of buttons to display.</param>
        /// <param name="image">A <see cref="MessageBoxImage"/> value that specifies the image to display.</param>
        /// <param name="defaultResult">A <see cref="MessageBoxResult"/> value that specifies the message box's default option.</param>
        public static void Show(MessageBoxModal mb, String text, String caption, MessageBoxButton button, MessageBoxImage image, MessageBoxResult defaultResult)
        {
            Contract.Require(mb, "mb");
            
            mb.Prepare(text, caption, button, image, defaultResult);

            Modal.ShowDialog(mb);
        }
Beispiel #31
0
 private void ShowInfoMessage(string msg, MessageBoxImage icon = MessageBoxImage.Error)
 {
     MessageBox.Show(msg, "Informacja", MessageBoxButton.OK, icon);
 }
Beispiel #32
0
 /// <summary>
 /// Displays a <see cref="MessageBox"/> an returns the <see cref="MessageBoxResult"/> depending on the user's choice.
 /// </summary>
 /// <param name="owner">A <see cref="Window"/> that represents the owner window of the message box.</param>
 /// <param name="message">A <see cref="string"/> that specifies the text to display.</param>
 /// <param name="caption">A <see cref="string"/> that specifies the title bar caption to display.</param>
 /// <param name="button">A <see cref="MessageBoxButton"/> value that specifies which button or buttons to display</param>
 /// <param name="image">A <see cref="MessageBoxImage"/> value that specifies the icon to display.</param>
 /// <returns>A <see cref="MessageBoxResult"/> value that specifies which message box button is clicked by the user.</returns>
 public static MessageBoxResult Show(Window owner, string message, string caption, MessageBoxButton button, MessageBoxImage image)
 {
     return(Show(owner, message, caption, GetButtons(button), image));
 }
Beispiel #33
0
        public Task <MessageBoxResult> ShowMessageBox(string ownerViewKey, string message = "", MessageBoxImage messageBoxImage = MessageBoxImage.Information, MessageBoxButton messageBoxButton = MessageBoxButton.OK)
        {
            var modalViewInstanceKey = Guid.NewGuid().ToString("N");
            var navigationKey        = string.Format("{0}/{1}", ownerViewKey, modalViewInstanceKey);
            var viewInfo             = NavigateToInternal(navigationKey, null, true, true);

            // initialize messagebox informations
            var messageBoxControl = (MessageBoxControl)viewInfo.ViewInstance;

            messageBoxControl.ViewInstanceKey   = modalViewInstanceKey;
            messageBoxControl.NavigationManager = this;
            messageBoxControl.Message           = message;
            messageBoxControl.MessageBoxImage   = messageBoxImage;
            messageBoxControl.MessageBoxButton  = messageBoxButton;

            var modalHostControl = (ModalHostControl)viewInfo.ViewHostInstance.View;

            return(modalHostControl.ResultCompletionSource.Task
                   .ContinueWith(t => (MessageBoxResult)t.Result));
        }
Beispiel #34
0
 public MessageBoxResult Show(string caption, string text, MessageBoxImage image)
 => this.Show(caption, text, MessageBoxButton.OK, image);
Beispiel #35
0
 public static void ShowMessage(string msg, string caption, MessageBoxButton button, MessageBoxImage image)
 {
     Application.Current.Dispatcher.Invoke(() =>
                                           MessageBox.Show(msg, caption, button, image));
 }
Beispiel #36
0
        private void btnReturn_Click(object sender, RoutedEventArgs e)
        {
            string           sMessageBoxText = "Are all rows accounted for?";
            string           sCaption        = "Return borrowed items";
            MessageBoxButton btnMessageBox   = MessageBoxButton.YesNoCancel;
            MessageBoxImage  icnMessageBox   = MessageBoxImage.Warning;

            MessageBoxResult dr = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);

            switch (dr)
            {
            case MessageBoxResult.Yes:
                foreach (var row in list)
                {
                    var check = list.FirstOrDefault(x => (x.isReturned == true));
                    if (check != null)
                    {
                        SqlCeConnection conn = DBUtils.GetDBConnection();
                        conn.Open();
                        using (SqlCeCommand cmd = new SqlCeCommand("UPDATE tbl_Items set quantityOnStock = quantityOnStock + @qty where ItemCode = @itemCode", conn))
                        {
                            cmd.Parameters.AddWithValue("@qty", row.qty);
                            cmd.Parameters.AddWithValue("@itemCode", row.itemCode);
                            try
                            {
                                cmd.ExecuteNonQuery();
                                using (SqlCeCommand cmd1 = new SqlCeCommand("INSERT into tbl_Return (StudentId, ItemCode, BorrowID, DateReturned, ReceivedBy, Remarks, qtyReturned) SELECT StudentID, ItemCode, BorrowID, @dateReturned, @ReceivedBy, @Remarks, @qtyReturned) from tbl_Borrow where transactID = @transactID", conn))
                                {
                                    cmd1.Parameters.AddWithValue("@transactID", row.transactNo);
                                    cmd1.Parameters.AddWithValue("@dateReturned", DateTime.Today);
                                    cmd1.Parameters.AddWithValue("@receivedBy", "dummy");
                                    cmd1.Parameters.AddWithValue("@qtyReturned", row.qty);
                                    if (string.IsNullOrEmpty(row.remarks))
                                    {
                                        cmd1.Parameters.AddWithValue("@remarks", "none");
                                    }
                                    else
                                    {
                                        cmd1.Parameters.AddWithValue("@remarks", row.remarks);
                                    }
                                    try
                                    {
                                        cmd1.ExecuteNonQuery();
                                        using (SqlCeCommand cmd2 = new SqlCeCommand("DELETE from tbl_Borrow where transactID = @transactID", conn))
                                        {
                                            cmd2.Parameters.AddWithValue("@transactID", row.transactNo);
                                            try
                                            {
                                                cmd2.ExecuteNonQuery();
                                            }
                                            catch (SqlCeException ex)
                                            {
                                                MessageBox.Show("Error! Log has been updated with the error." + ex);
                                                return;
                                            }
                                        }
                                        MessageBox.Show("Borrowed item(s) has been returned!");
                                        LoadCollectionData();
                                    }
                                    catch (SqlCeException ex)
                                    {
                                        MessageBox.Show("Error! Log has been updated with the error." + ex);
                                        return;
                                    }
                                }
                            }
                            catch (SqlCeException ex)
                            {
                                MessageBox.Show("Error! Log has been updated with the error.");
                                return;
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("There are no data to be returned!");
                    }
                }
                break;

            case MessageBoxResult.No:
                break;
            }
        }
Beispiel #37
0
 public void ShowMessage(string message, string caption = "Info", MessageBoxButton button = MessageBoxButton.OK,
                         MessageBoxImage image          = MessageBoxImage.None)
 {
     MessageBox.Show(message, caption, button, image);
 }
        MessageBoxResult IMessageBox.Show(Window owner, string text, string caption, MessageBoxButton messageBoxButtons, MessageBoxImage messageBoxIcon, MessageBoxResult defaultResult, MessageBoxOptions messageBoxOptions, params string[] args)
        {
            Message.MessageResult messageResult;

            try
            {
                messageResult = this.GetMessage(text);

                if (messageResult == null)
                {
                    return(System.Windows.MessageBox.Show(owner, text.Translate(args), caption.Translate(), messageBoxButtons, messageBoxIcon, defaultResult, messageBoxOptions));
                }

                if (text.Contains("^"))
                {
                    args = text.Substring(text.IndexOf('^') + 1).Split('^');
                }

                if (!messageResult.Result)
                {
                    return(System.Windows.MessageBox.Show(owner, messageResult.Message.Translate(args), caption.Translate(), messageBoxButtons, messageBoxIcon, defaultResult, messageBoxOptions));
                }

                return(((IMessageBox)this).Show(owner, messageResult.Message, messageResult.Title, this.MessageBoxButtonConvert(messageResult.MessageBoxButtons), this.MessageBoxIconConvert(messageResult.MessageBoxIcon), args));
            }
            catch (Exception ex)
            {
                Diagnostics.DiagnosticsTool.MyTrace(ex);
                return(System.Windows.MessageBox.Show(owner, text.Translate(args), caption.Translate(), messageBoxButtons, messageBoxIcon, defaultResult, messageBoxOptions));
            }
        }
Beispiel #39
0
        public static MessageBoxResult ToUser(eUserMsgKeys messageKey, params object[] messageArgs)
        {
            UserMessage     messageToShow = null;
            string          messageText   = string.Empty;
            MessageBoxImage messageImage  = MessageBoxImage.None;

            try
            {
                //get the message from pool
                if ((UserMessagesPool != null) && UserMessagesPool.Keys.Contains(messageKey))
                {
                    messageToShow = UserMessagesPool[messageKey];
                }
                if (messageToShow == null)
                {
                    // We do want to pop the error message so below is just in case...
                    string mess = "";
                    foreach (object o in messageArgs)
                    {
                        mess += o.ToString() + " ";
                    }
                    MessageBox.Show(messageKey.ToString() + " - " + mess);

                    ToLog(eLogLevel.WARN, "The user message with key: '" + messageKey + "' was not found! and won't show to the user!");
                    return(MessageBoxResult.None);
                }

                //set the message type
                switch (messageToShow.MessageType)
                {
                case eMessageType.ERROR:
                    messageImage = MessageBoxImage.Error;
                    break;

                case eMessageType.INFO:
                    messageImage = MessageBoxImage.Information;
                    break;

                case eMessageType.QUESTION:
                    messageImage = MessageBoxImage.Question;
                    break;

                case eMessageType.WARN:
                    messageImage = MessageBoxImage.Warning;
                    break;

                default:
                    messageImage = MessageBoxImage.Information;
                    break;
                }

                //enter message args if exist
                if (messageArgs.Length > 0)
                {
                    messageText = string.Format(messageToShow.Message, messageArgs);
                }
                else
                {
                    messageText = messageToShow.Message;
                }

                //show the messege and return user selection
                //adding owner window to the message so it will appear on top of any other window including splash screen
                //return MessageBox.Show(messageText, messageToShow.Caption, messageToShow.ButtonsType, messageImage, messageToShow.DefualtResualt);

                if (CurrentAppLogLevel == eAppLogLevel.Debug)
                {
                    ToLog(eLogLevel.INFO, "Showing User Message (Pop-Up): '" + messageText + "'");
                }
                else if (AddAllReportingToConsole)
                {
                    ToConsole("Showing User Message (Pop-Up): '" + messageText + "'");
                }

                MessageBoxResult userSelection = MessageBoxResult.None; //????

                //Show msgbox from Main Window STA
                if (!RunningFromConfigFile)
                {
                    MainWindowDispatcher.Invoke(() =>
                    {
                        Window msgOwnerWin = new Window
                        {
                            Width                 = 0.001,
                            Height                = 0.001,
                            Topmost               = true,
                            ShowInTaskbar         = false,
                            ShowActivated         = true,
                            WindowStyle           = WindowStyle.None,
                            WindowStartupLocation = WindowStartupLocation.CenterScreen
                        };
                        msgOwnerWin.Show();
                        msgOwnerWin.Hide();
                        userSelection = MessageBox.Show(msgOwnerWin, messageText, messageToShow.Caption, messageToShow.ButtonsType,
                                                        messageImage, messageToShow.DefualtResualt);
                        msgOwnerWin.Close();
                        return(userSelection);
                    });
                }

                if (CurrentAppLogLevel == eAppLogLevel.Debug)
                {
                    ToLog(eLogLevel.INFO, "User Selection for Pop-Up Message: '" + userSelection.ToString() + "'");
                }
                else if (AddAllReportingToConsole)
                {
                    ToConsole("User Selection for Pop-Up Message: '" + userSelection.ToString() + "'");
                }

                return(userSelection);
            }
            catch (Exception ex)
            {
                ToLog(eLogLevel.ERROR, "Failed to show the user message with the key: " + messageKey, ex);
                MessageBox.Show("Failed to show the user message with the key: " + messageKey);
                return(MessageBoxResult.None);
            }
        }
Beispiel #40
0
 /// <summary>
 /// Begins an asynchronous operation showing a dialog.
 /// </summary>
 /// <param name="title">The title to display on the dialog, if any.</param>
 /// <param name="content">The message to be displayed to the user.</param>
 /// <param name="defaultCommandIndex">
 /// The index of the command you want to use as the default. This is the command that fires
 /// by default when users press the ENTER key.
 /// </param>
 /// <param name="cancelCommandIndex">
 /// The index of the command you want to use as the cancel command. This is the command that
 /// fires when users press the ESC key.
 /// </param>
 /// <param name="messageBoxImage">The icon to show on the dialog</param>
 /// <param name="commands">
 /// An array of commands that appear in the command bar of the message dialog. These commands
 /// makes the dialog actionable.
 /// </param>
 /// <returns>An object that represents the asynchronous operation.</returns>
 public Task ShowAsync(string title, string content, uint defaultCommandIndex, uint cancelCommandIndex, MessageBoxImage messageBoxImage, CauldronUICommandCollection commands)
 {
     return(this.Dispatcher.RunAsync(async() => await this.navigator.NavigateAsync <MessageDialogViewModel>(new Func <Task>(() => Task.FromResult(0)), title, content, (int)messageBoxImage, defaultCommandIndex, cancelCommandIndex, commands)));
 }
Beispiel #41
0
 public MessageBoxResult Show(string caption, string text, MessageBoxButton buttons, MessageBoxImage image)
 {
     return(MessageBox.Show(caption, text, buttons, image));
 }
Beispiel #42
0
 /// <summary>
 /// Show a message box. This is mostly a pass-thru for non UI elements that need one.
 /// </summary>
 public MessageBoxResult ShowMessageBox(string text, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult, MessageBoxOptions options = MessageBoxOptions.None) => MessageBox.Show(this, text, caption, button, icon, defaultResult, options);
Beispiel #43
0
 public static MessageBoxResult ShowMessage(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon)
 {
     return(DialogsHandler.ShowMessage(messageBoxText, caption, button, icon));
 }
Beispiel #44
0
 public MvvmMessageBoxEventArgs(Action<MessageBoxResult> resultAction, string messageBoxText, string caption = "", MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.None, MessageBoxOptions options = MessageBoxOptions.None)
 {
     this.resultAction = resultAction;
     this.messageBoxText = messageBoxText;
     this.caption = caption;
     this.button = button;
     this.icon = icon;
     this.defaultResult = defaultResult;
     this.options = options;
 }
Beispiel #45
0
        public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon)
        {
            MessageBoxWindow messageBox = new MessageBoxWindow(messageBoxText, caption, button, icon);

            messageBox.ShowDialog();
            return(messageBox.Result);
        }
Beispiel #46
0
 public MessageBoxNotificationEventArgs(string message, string caption, MessageBoxButton buttons, MessageBoxImage icon, string propertyName = "")
 {
     Message      = message;
     Caption      = caption;
     Buttons      = buttons;
     Icon         = icon;
     PropertyName = propertyName;
 }
 public MessageBoxResult Show(string text, string caption, MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage image = MessageBoxImage.None)
 {
     return(MessageBox.Show(text, caption, button, image));
 }
Beispiel #48
0
        protected void OnDisplayMessage(string message, string caption, MessageBoxButton buttons, MessageBoxImage icon, string propertyName = "")
        {
            var eventDelegate = DisplayMessage;

            eventDelegate?.Invoke(this, new MessageBoxNotificationEventArgs(message, caption, buttons, icon, propertyName));
        }
Beispiel #49
0
        /// <summary>
        /// Displays a <see cref="MessageBox"/> an returns the <see cref="MessageBoxResult"/> depending on the user's choice.
        /// </summary>
        /// <param name="owner">A <see cref="Window"/> that represents the owner window of the message box.</param>
        /// <param name="message">A <see cref="string"/> that specifies the text to display.</param>
        /// <param name="caption">A <see cref="string"/> that specifies the title bar caption to display.</param>
        /// <param name="buttons">A n enumeration of <see cref="DialogButtonInfo"/> that specifies buttons to display</param>
        /// <param name="image">A <see cref="MessageBoxImage"/> value that specifies the icon to display.</param>
        /// <returns>A <see cref="MessageBoxResult"/> value that specifies which message box button is clicked by the user.</returns>
        public static MessageBoxResult Show(Window owner, string message, string caption, IEnumerable <DialogButtonInfo> buttons, MessageBoxImage image)
        {
            var messageBox = new MessageBox
            {
                Owner = owner,
                WindowStartupLocation = owner != null ? WindowStartupLocation.CenterOwner : WindowStartupLocation.CenterScreen,
                Title         = caption,
                Content       = message,
                ButtonsSource = buttons.ToList(),
            };

            SetImage(messageBox, image);
            return((MessageBoxResult)messageBox.ShowInternal());
        }
 protected void MessageBox_Show(Action <MessageBoxResult> resultAction, string messageBoxText, string caption = "", MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.None, MessageBoxOptions options = MessageBoxOptions.None)
 {
     if (MessageBoxRequest != null)
     {
         MessageBoxRequest(this, new MvvmMessageBoxEventArgs(resultAction, messageBoxText, caption, button, icon, defaultResult, options));
     }
 }
Beispiel #51
0
 public static MessageBoxResult MessageBox(string message, MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.Information, params object[] parameters)
 {
     return(System.Windows.MessageBox.Show(string.Format(message, parameters), "ABPHelper", button, icon));
 }
Beispiel #52
0
 public static MessageBoxResult Show(string message, string caption, MessageBoxButton messageBoxButton, MessageBoxImage messageBoxImage)
 {
     if (!CommandLineParser.CommandLineArgs.ContainsKey("quiet"))
     {
         return(MessageBox.Show(message, caption, messageBoxButton, messageBoxImage));
     }
     return(MessageBoxResult.None);
 }
Beispiel #53
0
        internal static MessageBoxResult Show(Window owner, string messageBoxText, string caption,
                                              MessageBoxButton button, MessageBoxImage icon,
                                              MessageBoxResult defaultResult)
        {
            MessageWindow MW = new MessageWindow(owner);

            MW.TextBlockMessageText.Text = messageBoxText;
            MW.Title = caption;

            switch (button)
            {
            case MessageBoxButton.OK:
                MW.ButtonYes.Content = AppLanguage.Get("LangButtonOK");
                MW.ButtonYes.Focus();
                break;

            case MessageBoxButton.OKCancel:
                MW.ButtonYes.Content       = AppLanguage.Get("LangButtonOK");
                MW.ButtonCancel.Visibility = Visibility.Visible;
                break;

            case MessageBoxButton.YesNo:
                MW.ButtonNo.Visibility = Visibility.Visible;
                break;

            case MessageBoxButton.YesNoCancel:
                MW.ButtonCancel.Visibility = Visibility.Visible;
                MW.ButtonNo.Visibility     = Visibility.Visible;
                break;

            default:
                break;
            }

            switch (icon)
            {
            case MessageBoxImage.Question:
                break;

            case MessageBoxImage.Error:
                break;

            case MessageBoxImage.Information:
                break;

            case MessageBoxImage.Warning:
                break;

            case MessageBoxImage.None:
            default:
                MW.MessageImage.Visibility = Visibility.Collapsed;
                break;
            }

            switch (defaultResult)
            {
            case MessageBoxResult.No:
                MW.ButtonNo.IsDefault = true;
                MW.ButtonNo.Focus();
                break;

            case MessageBoxResult.OK:
            case MessageBoxResult.Yes:
                MW.ButtonYes.IsDefault = true;
                MW.ButtonYes.Focus();
                break;

            default:
                MW.ButtonCancel.IsDefault = true;
                MW.ButtonCancel.Focus();
                break;
            }

            MW.ShowDialog();
            if (MW.DialogResult.HasValue)
            {
                if (MW.DialogResult.Value)
                {
                    return(MessageBoxResult.Yes);
                }
                else
                {
                    return(MessageBoxResult.No);
                }
            }
            else
            {
                return(MessageBoxResult.Cancel);
            }
        }
Beispiel #54
0
        /// <summary>
        /// Brings up a message box and asks for confirmation.
        /// </summary>
        /// <param name="icon">The icon for the message box.</param>
        /// <param name="format">The text to display.</param>
        /// <param name="args">The arguments.</param>
        /// <returns>true if the user has confirmed the message box, otherwise false.</returns>
        public static bool ConfirmMessageBox(MessageBoxImage icon, string format, params object[] args)
        {
            string message = string.Format(format, args);

            return(MessageBox.Show(message, "Bestätigung", MessageBoxButton.YesNo, icon) == MessageBoxResult.Yes);
        }
Beispiel #55
0
        public MessageBoxResult MessageBoxFlyoutShow(string message, string caption, MessageBoxButton buttons, MessageBoxImage image)
        {
            var uc = new MessageBoxFlyout(message, caption, buttons, image);

            StartFlyoverModal(uc);
            return(uc.Result);
        }
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            btnUpdate.IsEnabled = false;
            btnDelete.IsEnabled = false;
            if (btnAdd.Content.Equals("Add"))
            {
                clearInputControl();
                setEditableInputControl();
                txtName.Focusable = true;
                Keyboard.Focus(txtName);
                btnAdd.Content = "Save";
            }
            else if (btnAdd.Content.Equals("Save"))
            {
                bool isValid = true;
                validInputControl(ref isValid);

                if (isValid && !Validation.GetHasError(txtName) &&
                    !Validation.GetHasError(txtAge) && !Validation.GetHasError(txtPhone))
                {
                    Int16    age          = Int16.Parse(txtAge.Text.ToString());
                    string   date         = "";
                    DateTime?selectedDate = dpkDate.SelectedDate;
                    if (selectedDate.HasValue)
                    {
                        date = selectedDate.Value.ToString("MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
                    }
                    string g1     = rdbFemale.Content.ToString();
                    string gender = (Convert.ToBoolean(rdbMale.IsChecked) ? rdbMale.Content.ToString() : g1);

                    Customer newCustomer = new Customer();
                    newCustomer.Name     = txtName.Text;
                    newCustomer.Age      = age;
                    newCustomer.Phone    = txtPhone.Text;
                    newCustomer.Gender   = gender;
                    newCustomer.Service  = serviceMaleList[cbxServiceList.SelectedIndex - 1];
                    newCustomer.Provider = providerList[cbxProvider.SelectedIndex - 1];
                    newCustomer.Date     = date;
                    newCustomer.Time     = timeList[cbxTime.SelectedIndex - 1];
                    newCustomer.Location = locationList[cbxLocation.SelectedIndex - 1];


                    int flag = checkValidateInputControl(newCustomer);
                    if (flag == 0)
                    {
                        Schedule.Insert(0, newCustomer);
                        appointments.AddItem(newCustomer);
                        gridSchedule.ItemsSource = (gridSchedule.ItemsSource != Schedule) ? Schedule : gridSchedule.ItemsSource;
                        clearInputControl();
                        getTotalRecords();
                        saveToXML();
                    }
                    else if (checkValidateInputControl(newCustomer) == 1)
                    {
                        MessageBox.Show("This booked has been saved in the system.\nPlease enter new booked.", "Notification",
                                        MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else if (flag == 2)
                    {
                        MessageBox.Show("This booking was unsuccessful, because of the previous reservation.\nPlease enter new booked.",
                                        "Notification",
                                        MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else if (flag == 3)
                    {
                        MessageBox.Show("This booking was unsuccessful, because at the same time, " +
                                        "the provider cannot work in two different locations.\nPlease enter new booked.", "Notification",
                                        MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else if (flag == 4)
                    {
                        MessageBox.Show("This booking was unsuccessful, Because at the same time, " +
                                        "the provider cannot serve many different services.\nPlease enter new booked.", "Notification",
                                        MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
                else
                {
                    MessageBoxImage icon = MessageBoxImage.Question;
                    MessageBox.Show("Please complete and accurate information!\n" +
                                    "Tip: Check the red fields and see the tooltips of each input box " +
                                    "so that you can enter the information exactly.",
                                    "Notification", MessageBoxButton.OK, icon);
                }
            }
        }
Beispiel #57
0
 public MessageBoxResult ShowMessage(string message, string header, MessageBoxButton button, MessageBoxImage icon)
 {
     return(MessageBox.Show(message, header, button, icon));
 }
        /// <summary>
        /// 显示消息
        /// </summary>
        /// <param name="isShow">是否显示</param>
        /// <param name="button">显示按钮</param>
        /// <param name="image">显示图片</param>
        /// <param name="msgKey">消息文本密钥</param>
        /// <param name="args">参数</param>
        /// <returns>按钮结果</returns>
        public static MessageBoxResult ShowSystemMessage(bool isShow, MessageBoxButton button, MessageBoxImage image, string msgKey, params object[] args)
        {
            if (!isShow)
            {
                return(MessageBoxResult.Cancel);
            }
            string caption = Globals.GetStringFromCurrentLanguage(msgKey + "_Title");
            string msg     = Globals.GetStringFromCurrentLanguage(msgKey + "_Message");

            msg = string.IsNullOrEmpty(msg) ? "" : string.Format(msg, args);
            return(MessageBox.Show(msg, caption, button, image));
        }
Beispiel #59
0
        /// <summary>
        /// Получение/формирование параметров отчёта, DataSource (список сущностей для таблицы), пути файла и заголовка
        /// </summary>
        /// <inheritdoc />
        public void AdditionalInitializeComponent()
        {
            _reportFile = Common.GetReportFilePath(ReportFileName);             // Путь к файлу отчёта

            // Запрос параметров отчёта в отдельном окне

            const bool isPeriod        = false;
            const bool isMounthOrYeath = false;
            const bool isWarehouse     = false;
            const bool isWorkGuild     = false;
            const bool isDate          = true;
            const bool isDatePeriod    = false;
            const bool isMonthYear     = false;
            const bool isProduct       = false;
            const bool isCompany       = false;
            const bool isTypeProduct   = false;
            const bool isFormaPayment  = false;
            const bool isAbroad        = false;

            const string message          = "Выберите дату";
            var          parametersWindow = new ReportParametersWindow(isPeriod, isMounthOrYeath, isWarehouse,
                                                                       isWorkGuild, isDate, isDatePeriod, isMonthYear, isProduct, isCompany, isTypeProduct, isFormaPayment, isAbroad,
                                                                       message)
            {
                Owner = Common.GetOwnerWindow()
            };

            parametersWindow.ShowDialog();
            if (!parametersWindow.DialogResult.HasValue || parametersWindow.DialogResult != true)
            {
                return;
            }

            // Получение введённых пользователем параметров

            var nullableLoadDateTime = parametersWindow.SelectedDateTime();

            if (nullableLoadDateTime == null)
            {
                const string           errorMessage = "Дата не указана";
                const MessageBoxButton buttons      = MessageBoxButton.OK;
                const MessageBoxImage  messageType  = MessageBoxImage.Error;
                MessageBox.Show(errorMessage, PageLiterals.HeaderValidation, buttons, messageType);
                return;
            }

            var endDate   = (DateTime)nullableLoadDateTime;
            var startDate = Common.GetBeginOfMonthWithOffset(endDate);

            // Формирование одиночных строковых параметров отчёта
            _reportParameters = new[]
            {
                new ReportParameter("Date", endDate.ToShortDateString()),
                new ReportParameter("TypeOfCost", "(В учётных ценах)")
            };
            try
            {
                const string dataSourceName   = "ExpenditureOfProductsByTerritory";
                var          resultReportList =
                    ExpenditureOfProductsByTerritoryService.GetExpenditureOfProductsByTerritory(startDate, endDate);
                _reportDataSource = new ReportDataSource(dataSourceName, resultReportList);


                ReportViewer.Load += ReportViewer_Load;                 // Подписка на метод загрузки и отображения отчёта
            }
            catch (StorageException ex)
            {
                Common.ShowDetailExceptionMessage(ex);
            }
        }
Beispiel #60
0
    /// <summary>
    /// Setup the MessageBoxViewModel with the information it needs
    /// </summary>
    /// <param name="messageBoxText">A <see cref="System.String"/> that specifies the text to display.</param>
    /// <param name="caption">A <see cref="System.String"/> that specifies the title bar caption to display.</param>
    /// <param name="buttons">A <see cref="System.Windows.MessageBoxButton"/> value that specifies which button or buttons to display.</param>
    /// <param name="icon">A <see cref="System.Windows.MessageBoxImage"/> value that specifies the icon to display.</param>
    /// <param name="defaultResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the default result of the message box.</param>
    /// <param name="cancelResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the cancel result of the message box</param>
    /// <param name="buttonLabels">A dictionary specifying the button labels, if desirable</param>
    /// <param name="flowDirection">The <see cref="System.Windows.FlowDirection"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultFlowDirection"/></param>
    /// <param name="textAlignment">The <see cref="System.Windows.TextAlignment"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultTextAlignment"/></param>
    public void Setup(
        string messageBoxText,
        string caption                 = null,
        MessageBoxButton buttons       = MessageBoxButton.OK,
        MessageBoxImage icon           = MessageBoxImage.None,
        MessageBoxResult defaultResult = MessageBoxResult.None,
        MessageBoxResult cancelResult  = MessageBoxResult.None,
        IDictionary <MessageBoxResult, string> buttonLabels = null,
        FlowDirection?flowDirection = null,
        TextAlignment?textAlignment = null)
    {
        this.Text        = messageBoxText;
        this.DisplayName = caption;
        this.Icon        = icon;

        var buttonList = new BindableCollection <LabelledValue <MessageBoxResult> >();

        this.ButtonList = buttonList;
        foreach (var val in ButtonToResults[buttons])
        {
            string label;
            if (buttonLabels == null || !buttonLabels.TryGetValue(val, out label))
            {
                label = ButtonLabels[val];
            }

            var lbv = new LabelledValue <MessageBoxResult>(label, val);
            buttonList.Add(lbv);
            if (val == defaultResult)
            {
                this.DefaultButton = lbv;
            }
            else if (val == cancelResult)
            {
                this.CancelButton = lbv;
            }
        }
        // If they didn't specify a button which we showed, then pick a default, if we can
        if (this.DefaultButton == null)
        {
            if (defaultResult == MessageBoxResult.None && this.ButtonList.Any())
            {
                this.DefaultButton = buttonList[0];
            }
            else
            {
                throw new ArgumentException("DefaultButton set to a button which doesn't appear in Buttons");
            }
        }
        if (this.CancelButton == null)
        {
            if (cancelResult == MessageBoxResult.None && this.ButtonList.Any())
            {
                this.CancelButton = buttonList.Last();
            }
            else
            {
                throw new ArgumentException("CancelButton set to a button which doesn't appear in Buttons");
            }
        }

        this.FlowDirection = flowDirection ?? DefaultFlowDirection;
        this.TextAlignment = textAlignment ?? DefaultTextAlignment;
    }