Beispiel #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;
            }
        }
Beispiel #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);
            }
        }
Beispiel #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;
            }
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #8
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;
        }
        private MessageBoxExButton[] GetButtons()
        {
            ArrayList buttons = new ArrayList();
            foreach(ListViewItem item in listViewButtons.Items)
            {
                if(item.Checked)
                {
                    if(item.Tag == null)
                    {
                        //Standard buttons
                        MessageBoxExButton button = new MessageBoxExButton();
                        button.Text = item.Text;
                        button.Value = item.Text;
                        buttons.Add(button);
                    }
                    else
                    {
                        //Custom buttons
                        MessageBoxExButton button = item.Tag as MessageBoxExButton;
                        if(button != null)
                            buttons.Add(button);
                    }
                }
            }

            return (MessageBoxExButton[])buttons.ToArray(typeof(MessageBoxExButton));
        }
Beispiel #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;
        }
Beispiel #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);
            }
        }
Beispiel #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);
		}
Beispiel #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);
		}
Beispiel #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;
			}
		}
        /// <summary>
        /// Test case which exposed the AutoScale bug, this was submitted by Harry Stein
        /// </summary>
        private void Test3()
        {
            // as an experiment, I moved these from class members to local members

            // to see if it helps -- it didn't -- but it helps show you nothing else

            // is going on!

            MessageBoxEx       m_msgBoxSummary1 = null;

            MessageBoxExButton m_btnYes = null;

            // Tahoma 8.25 in Ex originally

            m_msgBoxSummary1 = MessageBoxExManager.CreateMessageBox("Summary1");

            m_btnYes = new MessageBoxExButton();

            string m_sPROGRAM_NAME = "Possrv.Debug Merchant Parser";
            string m_sVersion = "1.00A";;
            m_msgBoxSummary1.Caption = m_sPROGRAM_NAME + " " + m_sVersion;

            // fyi: m_sPROGRAM_NAME = "Possrv.Debug Merchant Parser";

            // and m_sVersion = "1.00A";

            m_msgBoxSummary1.Icon = MessageBoxExIcon.Information;

            m_btnYes.Text = "Okay";

            m_btnYes.Value = "OK";

            m_msgBoxSummary1.AddButton(m_btnYes);

            String sResultM =

                "Hello this is a reasonably long message with 1234 56789";

            m_msgBoxSummary1.Font = new Font("Lucida Console", 8);

            m_msgBoxSummary1.Text = sResultM;

            String sResult3 = m_msgBoxSummary1.Show();  // first call

            sResult3 = m_msgBoxSummary1.Show();         // second call

            if(sResult3=="" || (1 + 1 == 2))return; // quiet the compiler
        }
        private void Test2()
        {
            MessageBoxEx msgBox = MessageBoxExManager.CreateMessageBox("Test2");
            msgBox.Caption = "Question";
            msgBox.Text = "Do you want to save the data?";

            MessageBoxExButton btnYes = new MessageBoxExButton();
            btnYes.Text = "Yes";
            btnYes.Value = "Yes";
            btnYes.HelpText = "Save the data";

            MessageBoxExButton btnNo = new MessageBoxExButton();
            btnNo.Text = "No";
            btnNo.Value = "No";
            btnNo.HelpText = "Do not save the data";

            msgBox.AddButton(btnYes);
            msgBox.AddButton(btnNo);

            msgBox.Icon = MessageBoxExIcon.Question;

            msgBox.SaveResponseText = "Don't ask me again";
            msgBox.AllowSaveResponse = true;

            msgBox.Font = new Font("Tahoma",8);

            string result = msgBox.Show();
        }
Beispiel #17
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;
            }
        }
        private void btnAddButton_Click(object sender, System.EventArgs e)
        {
            MessageBoxExButton button = new MessageBoxExButton();
            button.Text = txtButtonText.Text;
            button.Value = txtButtonVal.Text;
            button.HelpText = txtButtonHelp.Text;
            button.IsCancelButton = chbIsCancel.Checked;

            ListViewItem item = new ListViewItem();
            item.Text = button.Text;
            item.Tag = button;

            listViewButtons.Items.Add(item);
        }