Пример #1
0
        private static void ButtonShow(MsgButton button, JXMessageBox msgBox)
        {
            msgBox.button = button;
            switch (button)
            {
            case MsgButton.OK:
                msgBox.btnConfirm.Content = "确定";
                break;

            case MsgButton.Yes:
                msgBox.btnConfirm.Content = "是";
                break;

            case MsgButton.Yes_No:
                msgBox.btnConfirm.Content = "是";
                //msgBox.btnNo.Visibility = Visibility.Visible;
                break;

            case MsgButton.OK_Cancel:
                msgBox.btnConfirm.Content   = "确定";
                msgBox.btnCancel.Visibility = Visibility.Visible;
                break;

            case MsgButton.Yes_No_Cancel:
                msgBox.btnConfirm.Content   = "是";
                msgBox.btnCancel.Visibility = Visibility.Visible;
                // msgBox.btnNo.Visibility = Visibility.Visible;
                break;
            }
        }
Пример #2
0
 public MsgPack(string message, string caption, MsgButton button, MsgIcon icon, MsgResult defaultResult)
 {
     Message       = message;
     Caption       = caption;
     Button        = button;
     Icon          = icon;
     DefaultResult = defaultResult;
 }
Пример #3
0
        public static MsgResult Show(string message, string caption = null, MsgButton button = MsgButton.OK,
                                     MsgIcon icon = MsgIcon.None, MsgResult defaultResult    = MsgResult.None, Window owner = null)
        {
            msgBox = new WPFMessageBoxControl(owner);
            MsgPack messagePack = new MsgPack(message, caption, button, icon, defaultResult);
            WPFMessageBoxViewModel viewmodel = new WPFMessageBoxViewModel(messagePack);

            msgBox.DataContext = viewmodel;
            PlayMessageBeep(icon);
            msgBox.ShowDialog();
            return(Result);
        }
Пример #4
0
        /// <summary>
        /// Permet d'afficher un message dans une boite de dialogue
        /// </summary>
        /// <param name="msg">Message à afficher</param>
        /// <param name="title">Titre du message</param>
        /// <param name="msgButton">Boutons à afficher</param>
        /// <param name="msgDefaultButton">Bouton par défaut</param>
        /// <returns>Bouton cliqué par l'utilisateur ou Cancel si le message est annulé</returns>
        public async static Task <MsgResult> MsgChoix(this string msg, string title, MsgButton msgButton, MsgDefaultButton msgDefaultButton)
        {
            MessageDialog msgDialog = null;
            MsgResult     reponse   = MsgResult.OK;

            // Création du message avec ou sans titre
            if (String.IsNullOrEmpty(title))
            {
                msgDialog = new MessageDialog(msg);
            }
            else
            {
                msgDialog = new MessageDialog(msg, title);
            }

            // Création des boutons qui seront affichés dans le message
            switch (msgButton)
            {
            case MsgButton.OK:
                msgDialog.Commands.Add(new UICommand("BT_OK".ReadResMsg())
                {
                    Id = BT_OK
                });
                break;

            case MsgButton.OKCancel:
                msgDialog.Commands.Add(new UICommand("BT_OK".ReadResMsg())
                {
                    Id = BT_OK
                });
                msgDialog.Commands.Add(new UICommand("BT_CANCEL".ReadResMsg())
                {
                    Id = BT_CANCEL
                });
                break;

            case MsgButton.RetryCancel:
                msgDialog.Commands.Add(new UICommand("BT_RETRY".ReadResMsg())
                {
                    Id = BT_RETRY
                });
                msgDialog.Commands.Add(new UICommand("BT_CANCEL".ReadResMsg())
                {
                    Id = BT_CANCEL
                });
                break;

            case MsgButton.YesNo:
                msgDialog.Commands.Add(new UICommand("BT_YES".ReadResMsg())
                {
                    Id = BT_YES
                });
                msgDialog.Commands.Add(new UICommand("BT_NO".ReadResMsg())
                {
                    Id = BT_NO
                });
                break;

            case MsgButton.YesNoCancel:
                msgDialog.Commands.Add(new UICommand("BT_YES".ReadResMsg())
                {
                    Id = BT_YES
                });
                msgDialog.Commands.Add(new UICommand("BT_NO".ReadResMsg())
                {
                    Id = BT_NO
                });
                msgDialog.Commands.Add(new UICommand("BT_CANCEL".ReadResMsg())
                {
                    Id = BT_CANCEL
                });
                break;

            default:
                msgDialog.Commands.Add(new UICommand("BT_OK".ReadResMsg())
                {
                    Id = BT_OK
                });
                break;
            }

            // Définition du bouton par défaut
            switch (msgDefaultButton)
            {
            case MsgDefaultButton.Button1:
                msgDialog.DefaultCommandIndex = 0;
                break;

            case MsgDefaultButton.Button2:
                msgDialog.DefaultCommandIndex = 1;
                break;

            case MsgDefaultButton.Button3:
                msgDialog.DefaultCommandIndex = 2;
                break;

            default:
                msgDialog.DefaultCommandIndex = 0;
                break;
            }

            // Affichage du message
            IUICommand result = await msgDialog.ShowAsync();

            if (result != null)
            {
                // Récupération du bouton 'cliqué' par l'utilisateur
                switch ((int)result.Id)
                {
                case BT_OK:
                    reponse = MsgResult.OK;
                    break;

                case BT_CANCEL:
                    reponse = MsgResult.Cancel;
                    break;

                case BT_RETRY:
                    reponse = MsgResult.Retry;
                    break;

                case BT_YES:
                    reponse = MsgResult.Yes;
                    break;

                case BT_NO:
                    reponse = MsgResult.No;
                    break;

                default:
                    reponse = MsgResult.OK;
                    break;
                }
            }
            else // Le message a été annulé (ex : Fermeture de la fenêtre, BackPressed, ...)
            {
                reponse = MsgResult.Cancel;
            }

            // Retour du bouton 'cliqué par l'utilisateur
            return(reponse);
        }
Пример #5
0
 /// <summary>
 /// Permet d'afficher un message dans une boite de dialogue sans titre
 /// </summary>
 /// <param name="msg">Message à afficher</param>
 /// <param name="msgButton">Boutons à afficher</param>
 /// <param name="msgDefaultButton">Bouton par défaut</param>
 /// <returns>Bouton cliqué par l'utilisateur ou Cancel si le message est annulé</returns>
 public async static Task <MsgResult> MsgChoix(this string msg, MsgButton msgButton, MsgDefaultButton msgDefaultButton)
 {
     return(await MsgChoix(msg, null, msgButton, msgDefaultButton));
 }
Пример #6
0
        public static MsgResult Show(Window win, string displayMessage, string caption, MsgButton button, MsgImage img)
        {
            JXMessageBox msgBox = new JXMessageBox();

            msgBox.txtDisplayMessage.Text  = displayMessage;
            msgBox.lblMessageTitle.Content = caption;
            ButtonShow(button, msgBox);

            string imageUrl = "";

            switch (img)
            {
            case MsgImage.Error:
                imageUrl = @"../Images/error.png";
                break;

            case MsgImage.Success:
                imageUrl = @"../Images/success.png";
                break;

            case MsgImage.Question:
                imageUrl = @"../Images/question.png";
                break;

            case MsgImage.Exclamation:
                imageUrl = @"../Images/wonder.png";
                break;
            }
            if (img != MsgImage.None)
            {
                msgBox.imgInfo.Visibility = Visibility.Visible;
                msgBox.imgInfo.Source     = msgBox.imgSource(imageUrl);
            }
            else
            {
                msgBox.imgInfo.Visibility = Visibility.Collapsed;
            }
            if (win != null)
            {
                msgBox.Owner = win;
            }
            msgBox.ShowDialog();
            return(msgBox.msgResult);
        }
Пример #7
0
        public static MsgResult Show(Window win, string displayMessage, string caption, MsgButton button)
        {
            JXMessageBox msgBox = new JXMessageBox();

            msgBox.txtDisplayMessage.Text  = displayMessage;
            msgBox.lblMessageTitle.Content = caption;
            ButtonShow(button, msgBox);
            if (win != null)
            {
                msgBox.Owner = win;
            }
            msgBox.ShowDialog();
            return(msgBox.msgResult);
        }
Пример #8
0
 public static MsgResult Show(Window win, string displayMessage, string caption, MsgButton button)
 {
     JXMessageBox msgBox = new JXMessageBox();
     msgBox.txtDisplayMessage.Text = displayMessage;
     msgBox.lblMessageTitle.Content = caption;
     ButtonShow(button, msgBox);
     if (win != null)
         msgBox.Owner = win;
     msgBox.ShowDialog();
     return msgBox.msgResult;
 }
Пример #9
0
 private static void ButtonShow(MsgButton button, JXMessageBox msgBox)
 {
     msgBox.button = button;
     switch (button)
     {
         case MsgButton.OK:
             msgBox.btnConfirm.Content = "确定";
             break;
         case MsgButton.Yes:
             msgBox.btnConfirm.Content = "是";
             break;
         case MsgButton.Yes_No:
             msgBox.btnConfirm.Content = "是";
             //msgBox.btnNo.Visibility = Visibility.Visible;
             break;
         case MsgButton.OK_Cancel:
             msgBox.btnConfirm.Content = "确定";
             msgBox.btnCancel.Visibility = Visibility.Visible;
             break;
         case MsgButton.Yes_No_Cancel:
             msgBox.btnConfirm.Content = "是";
             msgBox.btnCancel.Visibility = Visibility.Visible;
            // msgBox.btnNo.Visibility = Visibility.Visible;
             break;
     }
 }
Пример #10
0
        public static MsgResult Show(Window win, string displayMessage, string caption, MsgButton button, MsgImage img)
        {
            JXMessageBox msgBox = new JXMessageBox();
            msgBox.txtDisplayMessage.Text = displayMessage;
            msgBox.lblMessageTitle.Content = caption;
            ButtonShow(button, msgBox);

            string imageUrl = "";
            switch (img)
            {
                case MsgImage.Error:
                    imageUrl = @"../Images/error.png";
                    break;
                case MsgImage.Success:
                    imageUrl = @"../Images/success.png";
                    break;

                case MsgImage.Question:
                    imageUrl = @"../Images/question.png";
                    break;
                case MsgImage.Exclamation:
                    imageUrl = @"../Images/wonder.png";
                    break;
            }
            if (img != MsgImage.None)
            {
                msgBox.imgInfo.Visibility = Visibility.Visible;
                msgBox.imgInfo.Source = msgBox.imgSource(imageUrl);
            }
            else
                msgBox.imgInfo.Visibility = Visibility.Collapsed;
            if (win != null)
                msgBox.Owner = win;
            msgBox.ShowDialog();
            return msgBox.msgResult;
        }
Пример #11
0
 public MsgResult ShowMessageBox(string message, string caption = null, MsgButton button = MsgButton.OK,
                                 MsgIcon icon = MsgIcon.None, MsgResult defaultResult    = MsgResult.None, Window owner = null)
 {
     return(WPFMessageBox.Show(message, caption, button, icon, defaultResult, owner));
 }