Ejemplo n.º 1
0
        //main public method for showing msgBox
        public static bool Show(MsgBoxExtOptions options)
        {
            //check whether there is a messagebox active
            if (_currentOptions != null)
            {
                //check whether current active Msgbox is model
                if (_currentOptions.model)
                {
                    return(false); //do nothing
                }
                //else close the current msgBox
                closeMessageBox(_currentOptions.caption);
            }

            //save options in current options
            _currentOptions = options;

            //if timeout > 0  start timeout timer
            if (options.timeout > 0)
            {
                timeoutTimer          = new System.Windows.Forms.Timer();
                timeoutTimer.Tick    += new EventHandler(timeoutTimer_Tick);
                timeoutTimer.Interval = options.timeout;
                timeoutTimer.Enabled  = true;
            }

            //start messagebox thread
            msgBoxThread = new Thread(new ThreadStart(startMsgBoxThread));
            msgBoxThread.IsBackground = true;
            msgBoxThread.Start();

            return(true); //messagebox started
        }
Ejemplo n.º 2
0
        private static void timeoutTimer_Tick(object sender, EventArgs e)
        {
            // close current messagebox
            closeMessageBox(_currentOptions.caption);

            //fire result event
            onMsgBoxResultEvent(_currentOptions.resultReference, DialogResult.None);

            //dispose current options

            _currentOptions = null;
        }
Ejemplo n.º 3
0
        private static void startMsgBoxThread()
        {
            //standard Messagebox with results
            DialogResult result = MessageBox.Show(_currentOptions.text, _currentOptions.caption, _currentOptions.buttons, _currentOptions.icon, _currentOptions.defaultButton);

            //dispose the tiemout timer
            disposeTimeoutTimer();

            //fire result event
            onMsgBoxResultEvent(_currentOptions.resultReference, result);

            //dispose current options
            _currentOptions = null;
        }