Example #1
0
        /// <summary>
        /// Create a persistent message box. This is used when the application needs to update information on the dialog over time.
        /// will replace any existing persistent message box.
        /// </summary>
        /// <param name="configuration">The configuration of the message box.</param>
        public static void MessageBoxPersistentCreate(DialogConfiguration configuration)
        {
            if (_parentForm == null)
            {
                return;
            }

            if (_parentForm.InvokeRequired)
            {
                _parentForm.Invoke(new MessageBoxPersistentCreateCallback(MessageBoxPersistentCreate), configuration);
            }
            else
            {
                MessageBoxPersistentClose();
                _persistentDialog = new CustomDialogBox(_parentForm, configuration);
                _persistentDialog.Show();
            }
        }
Example #2
0
        /// <summary>
        /// Create a blocking message box. Will wait for user input to continue execution.
        /// </summary>
        /// <param name="configuration">The configuration for the message box.</param>
        /// <returns>User results.</returns>
        public static DialogResult MessageBoxBlocking(DialogConfiguration configuration)
        {
            if (_parentForm == null)
            {
                return(DialogResult.Cancel);
            }

            if (_parentForm.InvokeRequired)
            {
                return((DialogResult)_parentForm.Invoke(new MessageBoxBlockingCallback(MessageBoxBlocking), configuration));
            }

            var dialog = new CustomDialogBox(_parentForm, configuration);

            configuration.Result          = dialog.ShowDialog();
            configuration.ResultUserInput = dialog.ResultText;
            return(configuration.Result);
        }
Example #3
0
        /// <summary>
        /// Close any open persistent message boxes.
        /// </summary>
        public static void MessageBoxPersistentClose()
        {
            if (_parentForm == null || _persistentDialog == null)
            {
                return;
            }

            if (_parentForm.InvokeRequired)
            {
                _parentForm.Invoke(new MessageBoxPersistentCloseCallback(MessageBoxPersistentClose));
            }
            else
            {
                if (_persistentDialog == null)
                {
                    return;
                }

                _persistentDialog.Close();
                _persistentDialog = null;
            }
        }