Пример #1
0
 public CustomDialog(string strInstructionHeading, string strInstructionText, CustomDialogButtons enumButtons , CustomDialogResults enumDefaultButton , CustomDialogIcons enumInstructionIcon )
 {
     _strInstructionHeading = strInstructionHeading;
     _strInstructionText = strInstructionText;
     _enumButtons = enumButtons;
     _enumDefaultButton = enumDefaultButton;
     _enumInstructionIcon = enumInstructionIcon;
 }
 /// <summary>
 /// Displays a Yes/No dialog with a default button selected, and returns the user input.
 /// </summary>
 /// <param name="message">The message to be displayed.</param>
 /// <param name="caption">The caption of the message box window</param>
 /// <param name="icon">The icon to be displayed.</param>
 /// <param name="defaultResult">Default result for the message box</param>
 /// <returns>User selection.</returns>
 public CustomDialogResults ShowYesNo(string message, string caption, CustomDialogIcons icon, CustomDialogResults defaultResult)
 {
     return ShowQuestionWithButton(message, caption, icon, CustomDialogButtons.YesNo, defaultResult);
 }
 /// <summary>
 /// Shows a standard System.Windows.MessageBox using the parameters requested
 /// but will return a translated result to enable adhere to the IMessageBoxService
 /// implementation required. 
 /// 
 /// This abstraction allows for different frameworks to use the same ViewModels but supply
 /// alternative implementations of core service interfaces
 /// </summary>
 /// <param name="message">The message to be displayed.</param>
 /// <param name="caption">The caption of the message box window</param>
 /// <param name="icon">The icon to be displayed.</param>
 /// <param name="button"></param>
 /// <param name="defaultResult">Default result for the message box</param>
 /// <returns>CustomDialogResults results to use</returns>
 private CustomDialogResults ShowQuestionWithButton(string message, string caption,
     CustomDialogIcons icon, CustomDialogButtons button, CustomDialogResults defaultResult)
 {
     MessageBoxResult result = MessageBox.Show(message, caption,
         GetButton(button), GetImage(icon), GetResult(defaultResult));
     return GetResult(result);
 }
 /// <summary>
 /// Shows a standard System.Windows.MessageBox using the parameters requested
 /// </summary>
 /// <param name="message">The message to be displayed.</param>
 /// <param name="caption">The heading to be displayed</param>
 /// <param name="icon">The icon to be displayed.</param>
 private void ShowMessage(string message, string caption, CustomDialogIcons icon)
 {
     MessageBox.Show(message, caption, MessageBoxButton.OK, GetImage(icon));
 }
 /// <summary>
 /// Displays a OK/Cancel dialog with a default result selected, and returns the user input.
 /// </summary>
 /// <param name="message">The message to be displayed.</param>
 /// <param name="caption">The caption of the message box window</param>
 /// <param name="icon">The icon to be displayed.</param>
 /// <param name="defaultResult">Default result for the message box</param>
 /// <returns>User selection.</returns>
 public CustomDialogResults ShowOkCancel(string message, string caption, CustomDialogIcons icon, CustomDialogResults defaultResult)
 {
     return ShowQuestionWithButton(message, caption, icon, CustomDialogButtons.OKCancel, defaultResult);
 }
Пример #6
0
 /// <summary>
 /// Returns the next Dequeue ShowOkCancel response expected. See the tests for 
 /// the Func callback expected values
 /// </summary>
 /// <param name="message">The message to be displayed.</param>
 /// <param name="icon">The icon to be displayed.</param>
 /// <returns>User selection.</returns>
 public CustomDialogResults ShowOkCancel(string message, CustomDialogIcons icon)
 {
     if (ShowOkCancelResponders.Count == 0)
         throw new ApplicationException(
             "TestMessageBoxService ShowOkCancel method expects a Func<CustomDialogResults> callback \r\n" +
             "delegate to be enqueued for each Show call");
     else
     {
         Func<CustomDialogResults> responder = ShowOkCancelResponders.Dequeue();
         return responder();
     }
 }
Пример #7
0
 /// <summary>
 /// Shows a standard System.Windows.MessageBox using the parameters requested
 /// but will return a translated result to enable adhere to the IMessageBoxService
 /// implementation required. 
 /// 
 /// This abstraction allows for different frameworks to use the same ViewModels but supply
 /// alternative implementations of core service interfaces
 /// </summary>
 /// <param name="message">The message to be displayed.</param>
 /// <param name="icon">The icon to be displayed.</param>
 /// <param name="button"></param>
 /// <returns>CustomDialogResults results to use</returns>
 private CustomDialogResults ShowQuestionWithButton(string message,
     CustomDialogIcons icon, CustomDialogButtons button)
 {
     MessageBoxResult result = MessageBox.Show(message, "��ȷ��...",
         GetButton(button), GetImage(icon));
     return GetResult(result);
 }
Пример #8
0
        /// <summary>
        /// Translates a CustomDialogIcons into a standard WPF System.Windows.MessageBox MessageBoxImage.
        /// This abstraction allows for different frameworks to use the same ViewModels but supply
        /// alternative implementations of core service interfaces
        /// </summary>
        /// <param name="icon">The icon to be displayed.</param>
        /// <returns>A standard WPF System.Windows.MessageBox MessageBoxImage</returns>
        private MessageBoxImage GetImage(CustomDialogIcons icon)
        {
            MessageBoxImage image = MessageBoxImage.None;

            switch (icon)
            {
                case CustomDialogIcons.Information:
                    image = MessageBoxImage.Information;
                    break;
                case CustomDialogIcons.Question:
                    image = MessageBoxImage.Question;
                    break;
                case CustomDialogIcons.Exclamation:
                    image = MessageBoxImage.Exclamation;
                    break;
                case CustomDialogIcons.Stop:
                    image = MessageBoxImage.Stop;
                    break;
                case CustomDialogIcons.Warning:
                    image = MessageBoxImage.Warning;
                    break;
            }
            return image;
        }
 /// <summary>
 /// Shows a standard System.Windows.MessageBox using the parameters requested
 /// </summary>
 /// <param name="message">The message to be displayed.</param>
 /// <param name="caption">The heading to be displayed</param>
 /// <param name="icon">The icon to be displayed.</param>
 private void ShowMessage(string message, string caption, CustomDialogIcons icon)
 {
     MessageBox.Show(message, caption, MessageBoxButton.OK, GetImage(icon));
 }
 /// <summary>
 /// Displays a Yes/No dialog and returns the user input.
 /// </summary>
 /// <param name="message">The message to be displayed.</param>
 /// <param name="caption">The caption of the message box window</param>
 /// <param name="icon">The icon to be displayed.</param>
 /// <returns>User selection.</returns>
 public CustomDialogResults ShowYesNo(string message, string caption, CustomDialogIcons icon)
 {
     return(ShowQuestionWithButton(message, caption, icon, CustomDialogButtons.YesNo));
 }
 public CustomDialogWindow(string strCaption, string strInstructionHeading, string strInstructionText, string strAdditionalDetailsText, string strFooterText, CustomDialogButtons enumButtons, CustomDialogResults enumDefaultButton, CustomDialogIcons enumInstructionIcon, CustomDialogIcons enumFooterIcon, int intButtonsDisabledDelay = 0)
 {
     _strCaption               = strCaption;
     _strInstructionHeading    = strInstructionHeading;
     _strInstructionText       = strInstructionText;
     _strAdditionalDetailsText = strAdditionalDetailsText;
     _strFooterText            = strFooterText;
     _enumButtons              = enumButtons;
     _enumDefaultButton        = enumDefaultButton;
     _enumInstructionIcon      = enumInstructionIcon;
     _enumFooterIcon           = enumFooterIcon;
     _intButtonsDisabledDelay  = intButtonsDisabledDelay;
 }
Пример #12
0
 /// <summary>
 ///   Displays a Yes/No/Cancel dialog and returns the user input.
 /// </summary>
 /// <param name="message">The message to be displayed.</param>
 /// <param name="icon">The icon to be displayed.</param>
 /// <returns>User selection.</returns>
 public override CustomDialogResults ShowYesNoCancel(string message, CustomDialogIcons icon, string caption = null)
 {
     return(ShowQuestionWithButton(message, caption, icon, CustomDialogButtons.YesNoCancel));
 }
Пример #13
0
        /// <summary>
        ///   Shows a standard System.Windows.MessageBox using the parameters requested
        ///   but will return a translated result to enable adhere to the IMessageBoxService
        ///   implementation required.
        ///   This abstraction allows for different frameworks to use the same ViewModels but supply
        ///   alternative implementations of core service interfaces
        /// </summary>
        /// <param name="message">The message to be displayed.</param>
        /// <param name="heading">Heading for the message </param>
        /// <param name="icon">The icon to be displayed.</param>
        /// <param name="button"></param>
        /// <returns>CustomDialogResults results to use</returns>
        private CustomDialogResults ShowQuestionWithButton(string message, string heading, CustomDialogIcons icon, CustomDialogButtons button)
        {
            PreviewShowMessageBox(this, null);
            if (Owner != null)
            {
                var result = MessageBox.Show(Owner, message, heading, GetButton(button), GetImage(icon));
                MessageBoxClosed(this, null);

                return(GetResult(result));
            }
            else
            {
                var result = MessageBox.Show(message, heading, GetButton(button), GetImage(icon));
                MessageBoxClosed(this, null);

                return(GetResult(result));
            }
        }
Пример #14
0
 /// <summary>
 /// Shows a standard <see cref="MessageBox"/> using the parameters requested
 /// </summary>
 /// <param name="message">The message to be displayed.</param>
 /// <param name="heading">The heading to be displayed</param>
 /// <param name="icon">The icon to be displayed.</param>
 private static void ShowMessage(string message, string heading, CustomDialogIcons icon)
 {
     MessageBox.Show(message, heading, MessageBoxButton.OK, GetImage(icon));
 }
Пример #15
0
        private Uri GetIcon(CustomDialogIcons enumCustomDialogIcon)
        {
            switch (enumCustomDialogIcon)
            {

                case CustomDialogIcons.Information:
                    return new Uri("CustomDialogInformation.png", UriKind.Relative);

                case CustomDialogIcons.None:
                    return null;

                case CustomDialogIcons.Question:
                    return
                        new Uri
                            ("CustomDialogQuestion.png",
                             UriKind.Relative);

                case
                    CustomDialogIcons.Shield:
                    return
                        new Uri
                            ("CustomDialogShield.png",
                             UriKind.Relative);

                case
                    CustomDialogIcons.Stop:
                    return
                        new Uri
                            ("CustomDialogStop.png",
                             UriKind.Relative);

                case
                    CustomDialogIcons.Warning:
                    return
                        new Uri
                            ("CustomDialogWarning.png",
                             UriKind.Relative);

                default:
                    return null;
            }
        }
Пример #16
0
 /// <summary>
 /// Displays a Yes/No/Cancel dialog and returns the user input.
 /// </summary>
 /// <param name="message">The message to be displayed.</param>
 /// <param name="icon">The icon to be displayed.</param>
 /// <returns>User selection.</returns>
 public CustomDialogResults ShowYesNoCancel(string message, CustomDialogIcons icon)
 {
     return(ShowQuestionWithButton(message, icon, CustomDialogButtons.YesNoCancel));
 }
Пример #17
0
 /// <summary>
 /// Displays a Yes/No/Cancel dialog with a default button selected, and returns the user input.
 /// </summary>
 /// <param name="message">The message to be displayed.</param>
 /// <param name="caption">The caption of the message box window</param>
 /// <param name="icon">The icon to be displayed.</param>
 /// <param name="defaultResult">Default result for the message box</param>
 /// <returns>User selection.</returns>
 public CustomDialogResults ShowYesNoCancel(string message, string caption, CustomDialogIcons icon, CustomDialogResults defaultResult)
 {
     return(ShowQuestionWithButton(message, caption, icon, CustomDialogButtons.YesNoCancel, defaultResult));
 }
Пример #18
0
 /// <summary>
 /// Shows a standard System.Windows.MessageBox using the parameters requested
 /// </summary>
 /// <param name="message">The message to be displayed.</param>
 /// <param name="heading">The heading to be displayed</param>
 /// <param name="icon">The icon to be displayed.</param>
 private void ShowMessage(string message, string heading, CustomDialogIcons icon)
 {
     MessageBox.Show(message, heading, MessageBoxButton.OK, GetImage(icon));
 }
Пример #19
0
 /// <summary>
 /// Displays a OK/Cancel dialog and returns the user input.
 /// </summary>
 /// <param name="message">The message to be displayed.</param>
 /// <param name="caption">The caption of the message box window</param>
 /// <param name="icon">The icon to be displayed.</param>
 /// <returns>User selection.</returns>
 public CustomDialogResults ShowOkCancel(string message, string caption, CustomDialogIcons icon)
 {
     return(ShowQuestionWithButton(message, caption, icon, CustomDialogButtons.OKCancel));
 }
Пример #20
0
 /// <summary>
 /// Displays a Yes/No/Cancel dialog and returns the user input.
 /// </summary>
 /// <param name="message">The message to be displayed.</param>
 /// <param name="icon">The icon to be displayed.</param>
 /// <returns>User selection.</returns>
 public CustomDialogResults ShowYesNoCancel(string message, CustomDialogIcons icon)
 {
     return ShowQuestionWithButton(message, icon, CustomDialogButtons.YesNoCancel);
 }
Пример #21
0
        /// <summary>
        /// Shows a standard System.Windows.MessageBox using the parameters requested
        /// but will return a translated result to enable adhere to the IMessageBoxService
        /// implementation required.
        ///
        /// This abstraction allows for different frameworks to use the same ViewModels but supply
        /// alternative implementations of core service interfaces
        /// </summary>
        /// <param name="message">The message to be displayed.</param>
        /// <param name="icon">The icon to be displayed.</param>
        /// <param name="button"></param>
        /// <returns>CustomDialogResults results to use</returns>
        private static CustomDialogResults ShowQuestionWithButton(string message, CustomDialogIcons icon, CustomDialogButtons button)
        {
            MessageBoxResult result = MessageBox.Show(message, AxLanguage.Languages.REAplan_Confirmation, GetButton(button), GetImage(icon));

            return(GetResult(result));
        }