示例#1
0
        private static MessageBoxResult ShowCore(
            Window owner,
            string messageBoxText,
            string caption                 = "",
            MessageBoxButton button        = MessageBoxButton.OK,
            MessageBoxImage icon           = MessageBoxImage.None,
            MessageBoxResult defaultResult = MessageBoxResult.None,
            MessageBoxOptions options      = MessageBoxOptions.None)
        {
            if (owner == null)
            {
                owner = Application.Current.MainWindow;
            }

            return(WPFMessageBoxWindow.Show(
                       delegate(Window messageBoxWindow)
            {
                /*owner.Dispatcher.BeginInvoke((System.Action)(() =>
                 * {*/
                messageBoxWindow.Owner = owner;
                messageBoxWindow.FontSize = owner.FontSize;
                //}));
            },
                       messageBoxText, caption, button, icon, defaultResult, options));
        }
示例#2
0
        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);
        }
示例#3
0
        public MessageBoxViewModel(
            WPFMessageBoxWindow view,
            string title,
            string message,
            MessageBoxButton 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;
        }