private void SetButtonVisibility(WPFMessageBoxButton buttonOption)
        {
            switch (buttonOption)
            {
            case WPFMessageBoxButton.YesNo:
                OkVisibility = ContinueVisibility = CancelVisibility = Visibility.Collapsed;
                break;

            case WPFMessageBoxButton.YesNoCancel:
                OkVisibility = ContinueVisibility = Visibility.Collapsed;
                break;

            case WPFMessageBoxButton.OK:
                YesNoVisibility = ContinueVisibility = CancelVisibility = Visibility.Collapsed;
                break;

            case WPFMessageBoxButton.OKCancel:
                YesNoVisibility = ContinueVisibility = Visibility.Collapsed;
                break;

            case WPFMessageBoxButton.ContinueCancel:
                YesNoVisibility = Visibility.Collapsed;
                OkVisibility    = Visibility.Collapsed;
                break;

            default:
                OkVisibility = CancelVisibility = YesNoVisibility = Visibility.Collapsed;
                break;
            }
        }
        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);
        }
        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;
        }
        public static WPFMessageBoxResult Show(string 息, string 詳細資訊, WPFMessageBoxButton 鍵樣式)
        {
            _MessageBox        = new WPFMessageBox();
            _MessageBox.Result = WPFMessageBoxResult.Close;
            if (詳細資訊 != "")
            {
                _MessageBox.Border.Height = 680;
                _MessageBox.Border.Width  = 540;
            }
            if (Local.MainForm != null)
            {
                Local.MainForm.Border_遮幕.Visibility = Visibility.Visible; //把主視窗變暗
            }
            MessageBoxViewModel ViewModel = new MessageBoxViewModel(_MessageBox, 息, 詳細資訊, 鍵樣式);

            _MessageBox.DataContext = ViewModel;
            try
            {
                _MessageBox.Owner = Local.MainForm;   //視窗綁在主視窗前
                _MessageBox.Border_背景.Background = new SolidColorBrush(Local.GetThemeColor("ImmersiveStartSelectionBackground"));
            }
            catch { }
            _MessageBox.ShowDialog();
            return(_MessageBox.Result);
        }
예제 #5
0
 private static MessageBoxResult ShowCore(
     Window owner,
     CultureInfo culture,
     string messageBoxText,
     string caption                 = "",
     WPFMessageBoxButton button     = WPFMessageBoxButton.OK,
     MessageBoxImage icon           = MessageBoxImage.None,
     MessageBoxResult defaultResult = MessageBoxResult.None,
     MessageBoxOptions options      = MessageBoxOptions.None)
 {
     return(WPFMessageBoxWindow.Show(
                delegate(Window messageBoxWindow)
     {
         messageBoxWindow.Owner = owner;
     },
                culture, messageBoxText, caption, button, icon, defaultResult, options));
 }
 public MessageBoxViewModel(
     WPFMessageBoxWindow view,
     CultureInfo culture,
     string title,
     string message,
     WPFMessageBoxButton buttonOption,
     MessageBoxImage image,
     MessageBoxResult defaultResult,
     MessageBoxOptions options)
 {
     //TextAlignment
     Title = title;
     Message = message;
     ButtonOption = buttonOption;
     Options = options;
     SetDirections(options);
     SetButtonVisibility(buttonOption);
     SetImageSource(image);
     SetButtonDefault(defaultResult);
     _view = view;
 }
 public MessageBoxViewModel(
     WPFMessageBoxWindow view,
     CultureInfo culture,
     string title,
     string message,
     WPFMessageBoxButton buttonOption,
     MessageBoxImage image,
     MessageBoxResult defaultResult,
     MessageBoxOptions options)
 {
     //TextAlignment
     Title        = title;
     Message      = message;
     ButtonOption = buttonOption;
     Options      = options;
     SetDirections(options);
     SetButtonVisibility(buttonOption);
     SetImageSource(image);
     SetButtonDefault(defaultResult);
     _view = view;
 }
 public static WPFMessageBoxResult Show(string 息, WPFMessageBoxButton 鍵樣式)
 {
     return(Show(息, string.Empty, 鍵樣式));
 }
예제 #9
0
 //
 // Summary:
 //     Displays a message box that has a message, title bar caption, and button;
 //     and that returns a result.
 //
 // Parameters:
 //   messageBoxText:
 //     A System.String that specifies the text to display.
 //
 //   caption:
 //     A System.String that specifies the title bar caption to display.
 //
 //   button:
 //     A System.Windows.MessageBoxButton value that specifies which button or buttons
 //     to display.
 //
 // Returns:
 //     A System.Windows.MessageBoxResult value that specifies which message box
 //     button is clicked by the user.
 public static MessageBoxResult Show(string messageBoxText, string caption, WPFMessageBoxButton button)
 {
     return ShowCore(null, new CultureInfo("en-US"), messageBoxText, caption, button);
 }
예제 #10
0
 private static MessageBoxResult ShowCore(
     Window owner,
     CultureInfo culture,
     string messageBoxText,
     string caption = "",
     WPFMessageBoxButton button = WPFMessageBoxButton.OK,
     MessageBoxImage icon = MessageBoxImage.None,
     MessageBoxResult defaultResult = MessageBoxResult.None,
     MessageBoxOptions options = MessageBoxOptions.None)
 {
     return WPFMessageBoxWindow.Show(
         delegate(Window messageBoxWindow)
         {
             messageBoxWindow.Owner = owner;
         },
         culture, messageBoxText, caption, button, icon, defaultResult, options);
 }
예제 #11
0
 //
 // Summary:
 //     Displays a message box in front of the specified window. The message box
 //     displays a message, title bar caption, button, and icon; and accepts a default
 //     message box result, complies with the specified options, and returns a result.
 //
 // Parameters:
 //   owner:
 //     A System.Windows.Window that represents the owner window of the message box.
 //
 //   messageBoxText:
 //     A System.String that specifies the text to display.
 //
 //   caption:
 //     A System.String that specifies the title bar caption to display.
 //
 //   button:
 //     A System.Windows.MessageBoxButton value that specifies which button or buttons
 //     to display.
 //
 //   icon:
 //     A System.Windows.MessageBoxImage value that specifies the icon to display.
 //
 //   defaultResult:
 //     A System.Windows.MessageBoxResult value that specifies the default result
 //     of the message box.
 //
 //   options:
 //     A System.Windows.MessageBoxOptions value object that specifies the options.
 //
 // Returns:
 //     A System.Windows.MessageBoxResult value that specifies which message box
 //     button is clicked by the user.
 public static MessageBoxResult Show(Window owner, CultureInfo culture, string messageBoxText, string caption, WPFMessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult, MessageBoxOptions options)
 {
     return ShowCore(owner, culture, messageBoxText, caption, button, icon, defaultResult, options);
 }
예제 #12
0
 //
 // Summary:
 //     Displays a message box that has a message, title bar caption, button, and
 //     icon; and that accepts a default message box result, complies with the specified
 //     options, and returns a result.
 //
 // Parameters:
 //   messageBoxText:
 //     A System.String that specifies the text to display.
 //
 //   caption:
 //     A System.String that specifies the title bar caption to display.
 //
 //   button:
 //     A System.Windows.MessageBoxButton value that specifies which button or buttons
 //     to display.
 //
 //   icon:
 //     A System.Windows.MessageBoxImage value that specifies the icon to display.
 //
 //   defaultResult:
 //     A System.Windows.MessageBoxResult value that specifies the default result
 //     of the message box.
 //
 //   options:
 //     A System.Windows.MessageBoxOptions value object that specifies the options.
 //
 // Returns:
 //     A System.Windows.MessageBoxResult value that specifies which message box
 //     button is clicked by the user.
 public static MessageBoxResult Show(string messageBoxText, string caption, WPFMessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult, MessageBoxOptions options)
 {
     return ShowCore(null, new CultureInfo("en-US"), messageBoxText, caption, button, icon, defaultResult, options);
 }
예제 #13
0
 //
 // Summary:
 //     Displays a message box in front of the specified window. The message box
 //     displays a message, title bar caption, and button; and it also returns a
 //     result.
 //
 // Parameters:
 //   owner:
 //     A System.Windows.Window that represents the owner window of the message box.
 //
 //   messageBoxText:
 //     A System.String that specifies the text to display.
 //
 //   caption:
 //     A System.String that specifies the title bar caption to display.
 //
 //   button:
 //     A System.Windows.MessageBoxButton value that specifies which button or buttons
 //     to display.
 //
 // Returns:
 //     A System.Windows.MessageBoxResult value that specifies which message box
 //     button is clicked by the user.
 public static MessageBoxResult Show(Window owner, CultureInfo culture, string messageBoxText, string caption, WPFMessageBoxButton button)
 {
     return ShowCore(owner, culture, messageBoxText, caption, button);
 }
예제 #14
0
 //
 // Summary:
 //     Displays a message box that has a message, title bar caption, and button;
 //     and that returns a result.
 //
 // Parameters:
 //   messageBoxText:
 //     A System.String that specifies the text to display.
 //
 //   caption:
 //     A System.String that specifies the title bar caption to display.
 //
 //   button:
 //     A System.Windows.MessageBoxButton value that specifies which button or buttons
 //     to display.
 //
 // Returns:
 //     A System.Windows.MessageBoxResult value that specifies which message box
 //     button is clicked by the user.
 public static MessageBoxResult Show(string messageBoxText, string caption, WPFMessageBoxButton button)
 {
     return(ShowCore(null, new CultureInfo("en-US"), messageBoxText, caption, button));
 }
        private void SetButtonVisibility(WPFMessageBoxButton buttonOption)
        {
            switch (buttonOption)
            {
                case WPFMessageBoxButton.YesNo:
                    OkVisibility = CancelVisibility = Visibility.Collapsed;
                    break;

                case WPFMessageBoxButton.YesNoCancel:
                    OkVisibility = Visibility.Collapsed;
                    break;

                case WPFMessageBoxButton.OK:
                    YesNoVisibility = CancelVisibility = Visibility.Collapsed;
                    break;

                case WPFMessageBoxButton.OKCancel:
                    YesNoVisibility = Visibility.Collapsed;
                    break;

                case WPFMessageBoxButton.ContinueCancel:
                    YesNoVisibility = Visibility.Collapsed;
                    OkVisibility = Visibility.Collapsed;
                    break;

                default:
                    OkVisibility = CancelVisibility = YesNoVisibility = Visibility.Collapsed;
                    break;
            }
        }
예제 #16
0
 //
 // Summary:
 //     Displays a message box in front of the specified window. The message box
 //     displays a message, title bar caption, button, and icon; and accepts a default
 //     message box result, complies with the specified options, and returns a result.
 //
 // Parameters:
 //   owner:
 //     A System.Windows.Window that represents the owner window of the message box.
 //
 //   messageBoxText:
 //     A System.String that specifies the text to display.
 //
 //   caption:
 //     A System.String that specifies the title bar caption to display.
 //
 //   button:
 //     A System.Windows.MessageBoxButton value that specifies which button or buttons
 //     to display.
 //
 //   icon:
 //     A System.Windows.MessageBoxImage value that specifies the icon to display.
 //
 //   defaultResult:
 //     A System.Windows.MessageBoxResult value that specifies the default result
 //     of the message box.
 //
 //   options:
 //     A System.Windows.MessageBoxOptions value object that specifies the options.
 //
 // Returns:
 //     A System.Windows.MessageBoxResult value that specifies which message box
 //     button is clicked by the user.
 public static MessageBoxResult Show(Window owner, CultureInfo culture, string messageBoxText, string caption, WPFMessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult, MessageBoxOptions options)
 {
     return(ShowCore(owner, culture, messageBoxText, caption, button, icon, defaultResult, options));
 }
예제 #17
0
 //
 // Summary:
 //     Displays a message box that has a message, title bar caption, button, and
 //     icon; and that accepts a default message box result, complies with the specified
 //     options, and returns a result.
 //
 // Parameters:
 //   messageBoxText:
 //     A System.String that specifies the text to display.
 //
 //   caption:
 //     A System.String that specifies the title bar caption to display.
 //
 //   button:
 //     A System.Windows.MessageBoxButton value that specifies which button or buttons
 //     to display.
 //
 //   icon:
 //     A System.Windows.MessageBoxImage value that specifies the icon to display.
 //
 //   defaultResult:
 //     A System.Windows.MessageBoxResult value that specifies the default result
 //     of the message box.
 //
 //   options:
 //     A System.Windows.MessageBoxOptions value object that specifies the options.
 //
 // Returns:
 //     A System.Windows.MessageBoxResult value that specifies which message box
 //     button is clicked by the user.
 public static MessageBoxResult Show(string messageBoxText, string caption, WPFMessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult, MessageBoxOptions options)
 {
     return(ShowCore(null, new CultureInfo("en-US"), messageBoxText, caption, button, icon, defaultResult, options));
 }
예제 #18
0
 //
 // Summary:
 //     Displays a message box in front of the specified window. The message box
 //     displays a message, title bar caption, and button; and it also returns a
 //     result.
 //
 // Parameters:
 //   owner:
 //     A System.Windows.Window that represents the owner window of the message box.
 //
 //   messageBoxText:
 //     A System.String that specifies the text to display.
 //
 //   caption:
 //     A System.String that specifies the title bar caption to display.
 //
 //   button:
 //     A System.Windows.MessageBoxButton value that specifies which button or buttons
 //     to display.
 //
 // Returns:
 //     A System.Windows.MessageBoxResult value that specifies which message box
 //     button is clicked by the user.
 public static MessageBoxResult Show(Window owner, CultureInfo culture, string messageBoxText, string caption, WPFMessageBoxButton button)
 {
     return(ShowCore(owner, culture, messageBoxText, caption, button));
 }