示例#1
0
        private void DisableCloseIfMultipleButtonsAndNoCancelButton()
        {
            if (_buttons.Count > 1)
            {
                if (_cancelButton != null)
                {
                    return;
                }

                //See if standard cancel button is present
                foreach (MessageBoxExButton button in _buttons)
                {
                    if (button.Text == MessageBoxExButtons.Cancel.ToString() && button.Value == MessageBoxExButtons.Cancel.ToString())
                    {
                        _cancelButton = button;
                        return;
                    }
                }

                //Standard cancel button is not present, Disable
                //close button
                DisableCloseButton(this);
                _allowCancel = false;
            }
            else if (_buttons.Count == 1)
            {
                _cancelButton = _buttons[0] as MessageBoxExButton;
            }
            else
            {
                //This condition should never get called
                _allowCancel = false;
            }
        }
示例#2
0
        private void AddOkButtonIfNoButtonsPresent()
        {
            if (_buttons.Count == 0)
            {
                MessageBoxExButton okButton = new MessageBoxExButton();
                okButton.Text  = MessageBoxExButtons.OK.ToString();
                okButton.Value = MessageBoxExButtons.OK.ToString();

                _buttons.Add(okButton);
            }
        }
示例#3
0
        /// <summary>
        /// Add a custom button to the message box
        /// </summary>
        /// <param name="button">The button to add</param>
        public void AddButton(MessageBoxExButton button)
        {
            if (button == null)
            {
                throw new ArgumentNullException("button", "A null button cannot be added");
            }

            _msgBox.Buttons.Add(button);

            if (button.IsCancelButton)
            {
                _msgBox.CustomCancelButton = button;
            }
        }
示例#4
0
        /// <summary>
        /// Creates a button control based on info from MessageBoxExButton
        /// </summary>
        /// <param name="button"></param>
        /// <param name="size"></param>
        /// <param name="location"></param>
        /// <returns></returns>
        private Button CreateButton(MessageBoxExButton button, Size size, Point location)
        {
            Button buttonCtrl = new Button();

            buttonCtrl.Size      = size;
            buttonCtrl.Text      = button.Text;
            buttonCtrl.TextAlign = ContentAlignment.MiddleCenter;
            buttonCtrl.FlatStyle = FlatStyle.System;
            if (button.HelpText != null && button.HelpText.Trim().Length != 0)
            {
                buttonToolTip.SetToolTip(buttonCtrl, button.HelpText);
            }
            buttonCtrl.Location = location;
            buttonCtrl.Click   += new EventHandler(OnButtonClicked);
            buttonCtrl.Tag      = button.Value;

            return(buttonCtrl);
        }
示例#5
0
        /// <summary>
        /// Gets the button control for the specified MessageBoxExButton, if the
        /// control has not been created this method creates the control
        /// </summary>
        /// <param name="button"></param>
        /// <param name="size"></param>
        /// <param name="location"></param>
        /// <returns></returns>
        private Button GetButton(MessageBoxExButton button, Size size, Point location)
        {
            Button buttonCtrl = null;

            if (_buttonControlsTable.ContainsKey(button))
            {
                buttonCtrl          = _buttonControlsTable[button] as Button;
                buttonCtrl.Size     = size;
                buttonCtrl.Location = location;
            }
            else
            {
                buttonCtrl = CreateButton(button, size, location);
                _buttonControlsTable[button] = buttonCtrl;
                this.Controls.Add(buttonCtrl);
            }

            return(buttonCtrl);
        }
示例#6
0
        /// <summary>
        /// Add a custom button to the message box
        /// </summary>
        /// <param name="text">The text of the button</param>
        /// <param name="val">The return value in case this button is clicked</param>
        public void AddButton(string text, string val)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text", "Text of a button cannot be null");
            }

            if (val == null)
            {
                throw new ArgumentNullException("val", "Value of a button cannot be null");
            }

            MessageBoxExButton button = new MessageBoxExButton();

            button.Text  = text;
            button.Value = val;

            AddButton(button);
        }
示例#7
0
        /// <summary>
        /// Add a standard button to the message box
        /// </summary>
        /// <param name="buttons">The standard button to add</param>
        public void AddButton(MessageBoxExButtons button)
        {
            string buttonText = MessageBoxExManager.GetLocalizedString(button.ToString());

            if (buttonText == null)
            {
                buttonText = button.ToString();
            }

            string buttonVal = button.ToString();

            MessageBoxExButton btn = new MessageBoxExButton();

            btn.Text  = buttonText;
            btn.Value = buttonVal;

            if (button == MessageBoxExButtons.Cancel)
            {
                btn.IsCancelButton = true;
            }

            AddButton(btn);
        }
        /// <summary>
        /// Gets the button control for the specified MessageBoxExButton, if the
        /// control has not been created this method creates the control
        /// </summary>
        /// <param name="button"></param>
        /// <param name="size"></param>
        /// <param name="location"></param>
        /// <returns></returns>
        private Button GetButton(MessageBoxExButton button, Size size, Point location)
        {
            Button buttonCtrl = null;
            if(_buttonControlsTable.ContainsKey(button))
            {
                buttonCtrl  = _buttonControlsTable[button] as Button;
                buttonCtrl.Size = size;
                buttonCtrl.Location = location;
            }
            else
            {
                buttonCtrl = CreateButton(button, size, location);
                _buttonControlsTable[button] = buttonCtrl;
                this.Controls.Add(buttonCtrl);
            }

            return buttonCtrl;
        }
        private void DisableCloseIfMultipleButtonsAndNoCancelButton()
        {
            if(_buttons.Count > 1)
            {
                if(_cancelButton != null)
                    return;

                //See if standard cancel button is present
                foreach(MessageBoxExButton button in _buttons)
                {
                    if(button.Text == MessageBoxExButtons.Cancel.ToString() && button.Value == MessageBoxExButtons.Cancel.ToString())
                    {
                        _cancelButton = button;
                        return;
                    }
                }

                //Standard cancel button is not present, Disable
                //close button
                DisableCloseButton(this);
                _allowCancel = false;

            }
            else if(_buttons.Count == 1)
            {
                _cancelButton = _buttons[0] as MessageBoxExButton;
            }
            else
            {
                //This condition should never get called
                _allowCancel = false;
            }
        }
示例#10
0
        /// <summary>
        /// Creates a button control based on info from MessageBoxExButton
        /// </summary>
        /// <param name="button"></param>
        /// <param name="size"></param>
        /// <param name="location"></param>
        /// <returns></returns>
        private Button CreateButton(MessageBoxExButton button, Size size, Point location)
        {
            Button buttonCtrl = new Button();
            buttonCtrl.Size = size;
            buttonCtrl.Text = button.Text;
            buttonCtrl.TextAlign = ContentAlignment.MiddleCenter;
            buttonCtrl.FlatStyle = FlatStyle.System;
            if(button.HelpText != null && button.HelpText.Trim().Length != 0)
            {
                buttonToolTip.SetToolTip(buttonCtrl, button.HelpText);
            }
            buttonCtrl.Location = location;
            buttonCtrl.Click += new EventHandler(OnButtonClicked);
            buttonCtrl.Tag = button.Value;

            return buttonCtrl;
        }
示例#11
0
        private void AddOkButtonIfNoButtonsPresent()
        {
            if(_buttons.Count == 0)
            {
                MessageBoxExButton okButton = new MessageBoxExButton();
                okButton.Text = MessageBoxExButtons.OK.ToString();
                okButton.Value = MessageBoxExButtons.OK.ToString();

                _buttons.Add(okButton);
            }
        }
示例#12
0
        /// <summary>
        /// Add a standard button to the message box
        /// </summary>
        /// <param name="buttons">The standard button to add</param>
        public void AddButton(MessageBoxExButtons button)
        {
            string buttonText = MessageBoxExManager.GetLocalizedString(button.ToString());

            if(buttonText == null)
            {
                buttonText = button.ToString();
            }

            string buttonVal = button.ToString();

            MessageBoxExButton btn = new MessageBoxExButton();

            btn.Text = buttonText;
            btn.Value = buttonVal;

            if(button == MessageBoxExButtons.Cancel)
            {
                btn.IsCancelButton = true;
            }

            AddButton(btn);
        }
示例#13
0
        /// <summary>
        /// Add a custom button to the message box
        /// </summary>
        /// <param name="text">The text of the button</param>
        /// <param name="val">The return value in case this button is clicked</param>
        public void AddButton(string text, string val)
        {
            if(text == null)
                throw new ArgumentNullException("text","Text of a button cannot be null");

            if(val == null)
                throw new ArgumentNullException("val","Value of a button cannot be null");

            MessageBoxExButton button = new MessageBoxExButton();
            button.Text = text;
            button.Value = val;

            AddButton(button);
        }
示例#14
0
        /// <summary>
        /// Add a custom button to the message box
        /// </summary>
        /// <param name="button">The button to add</param>
        public void AddButton(MessageBoxExButton button)
        {
            if(button == null)
                throw new ArgumentNullException("button","A null button cannot be added");

            _msgBox.Buttons.Add(button);

            if(button.IsCancelButton)
            {
                _msgBox.CustomCancelButton = button;
            }
        }