コード例 #1
0
 public MainWindow()
 {
     InitializeComponent();
     _messageBoxManager = JhMessageBox.GetNewInstance("Invensys", "JhMessageBoxTestApp");
     rbUserMistake.IsChecked = true;
     _viewModel = MsgBoxViewModel.The;
     DataContext = _viewModel;
     Loaded += new RoutedEventHandler(MainWindow_Loaded);
 }
コード例 #2
0
 public static JhMessageBox GetNewInstance(System.Windows.Application ownerApplication)
 {
     var newMessageBoxManager = new JhMessageBox();
     newMessageBoxManager._ownerApplication = ownerApplication;
     newMessageBoxManager._captionPrefix = newMessageBoxManager.GetAReasonableTitlebarPrefix();
     return newMessageBoxManager;
 }
コード例 #3
0
 /// <summary>
 /// Get a new instance of a JhMessageBox (which is an IInterlocution),
 /// given the text to use as a prefix for all captions.
 /// </summary>
 /// <param name="vendorName">the name of the business-entity that owns this application, which is included within the caption for all message-boxes</param>
 /// <param name="productName">the name of this application, which is included within the caption for all message-boxes</param>
 /// <returns>a new instance of JhMessageBox for use in your application</returns>
 public static JhMessageBox GetNewInstance(string vendorName, string productName)
 {
     if (String.IsNullOrWhiteSpace(vendorName))
     {
         throw new ArgumentException("You must supply a value for vendorName - this is part of the mandatory title-bar prefix.");
     }
     if (String.IsNullOrWhiteSpace(productName))
     {
         throw new ArgumentException("productName.");
     }
     var newMessageBoxManager = new JhMessageBox();
     string titlebarPrefix = vendorName + " " + productName;
     newMessageBoxManager._captionPrefix = titlebarPrefix;
     return newMessageBoxManager;
 }
コード例 #4
0
 public static JhMessageBoxViewModel GetInstance(JhMessageBox manager, JhMessageBoxOptions options)
 {
     _theInstance = new JhMessageBoxViewModel(manager, options);
     return _theInstance;
 }
コード例 #5
0
 public JhMessageBoxViewModel(JhMessageBox manager, JhMessageBoxOptions options)
 {
     _options = options;
     DetailText = options.DetailText;
     SummaryText = options.SummaryText;
     // If there is no caption, then just put the caption-prefix without the spacer.
     if (String.IsNullOrWhiteSpace(options.CaptionAfterPrefix))
     {
         if (String.IsNullOrWhiteSpace(options.CaptionPrefix))
         {
             Title = manager.CaptionPrefix;
         }
         else
         {
             Title = options.CaptionPrefix;
         }
     }
     else
     {
         if (String.IsNullOrWhiteSpace(options.CaptionPrefix))
         {
             Title = manager.CaptionPrefix + ": " + options.CaptionAfterPrefix;
         }
         else
         {
             Title = options.CaptionPrefix + ": " + options.CaptionAfterPrefix;
         }
     }
 }
コード例 #6
0
        /// <summary>
        /// Create a new JhMessageBoxWindow, with the given options if non-null - otherwise use the DefaultOptions.
        /// </summary>
        /// <param name="options">The options to use for this particular message-box invocation. Leave this null to use the DefaultOptions.</param>
        public JhMessageBoxWindow(JhMessageBox mgr, JhMessageBoxOptions options = null)
        {
            //Console.WriteLine("JhMessageBoxWindow ctor, with options.BackgroundTexture = " + options.BackgroundTexture.ToString());
            _manager = mgr;
            // _options has to be set before InitializeComponent, since that causes properties to be bound, and hence the DataContext creates it's view-model.
            if (options == null)
            {
                _options = mgr.DefaultOptions;
            }
            else
            {
                _options = options;
            }
            _viewModel = JhMessageBoxViewModel.GetInstance(mgr, _options);

            InitializeComponent();

            // Ensure the timeout value isn't ridiculously high (as when the caller mistakenly thinks it's in milliseconds).
            // Use the constant upper-limit value to test it against.
            if (_options.TimeoutPeriodInSeconds > JhMessageBoxOptions.MaximumTimeoutPeriodInSeconds)
            {
                _options.TimeoutPeriodInSeconds = JhMessageBoxOptions.GetDefaultTimeoutValueFor(_options.MessageType);
            }

            if (_options.IsToCenterOverParent)
            {
                this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            }

            // If the option to use custom styles for the buttons is turned off, then set these button styles to null
            // so that they do not inherit the styles of the parent application.
            if (!_options.IsCustomButtonStyles)
            {
                btnCancel.Style = btnClose.Style = btnNo.Style = btnOk.Style = btnRetry.Style = btnYes.Style = btnIgnore.Style = null;
            }

            #if SILVERLIGHT
            _viewModel.CopyCommand = new RelayCommand(
                () => OnCopyCommandExecuted()
            );
            _viewModel.StayCommand = new RelayCommand(
                () => OnStayCommandExecuted(),
                () => StayCommand_CanExecute()
            );
            #else
            _viewModel.CopyCommand = new RelayCommand(
                (x) => OnCopyCommandExecuted()
            );
            _viewModel.StayCommand = new RelayCommand(
                (x) => OnStayCommandExecuted(),
                (x) => StayCommand_CanExecute()
            );
            #endif

            Loaded += OnLoaded;
            #if SILVERLIGHT
            Closing += new EventHandler<System.ComponentModel.CancelEventArgs>(OnClosing);
            #else
            ContentRendered += OnContentRendered;
            Closing += new System.ComponentModel.CancelEventHandler(OnClosing);
            #endif
        }
コード例 #7
0
 /// <summary>
 /// Make a new JhMessageBoxTestFacility object with the default values.
 /// </summary>
 public JhMessageBoxTestFacility(JhMessageBox manager)
 {
     _messageBoxManager = manager;
     _isTesting = true;
     _isTimeoutsFast = true;
 }