示例#1
0
        /// <summary>
        /// Shows the messsage box with the specified owner
        /// </summary>
        /// <param name="owner"></param>
        /// <returns></returns>
        public string Show(IWin32Window owner)
        {
            if (_useSavedResponse && this.Name != null)
            {
                string savedResponse = MessageBoxExManager.GetSavedResponse(this);
                if (savedResponse != null)
                {
                    return(savedResponse);
                }
            }

            if (owner == null)
            {
                _msgBox.ShowDialog();
            }
            else
            {
                _msgBox.ShowDialog(owner);
            }

            if (this.Name != null)
            {
                if (_msgBox.AllowSaveResponse && _msgBox.SaveResponse)
                {
                    MessageBoxExManager.SetSavedResponse(this, _msgBox.Result);
                }
                else
                {
                    MessageBoxExManager.ResetSavedResponse(this.Name);
                }
            }
            else
            {
                Dispose();
            }

            return(_msgBox.Result);
        }
示例#2
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;
            btn.SystemButton = button;

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

            AddButton(btn);
        }