Ejemplo n.º 1
0
        public string Show(IWin32Window owner, string text, string caption, MessageBoxButtonsBA buttons, MessageBoxIconBA icon)
        {
            MessageBoxManager.GetMessageButton();
            _msgBox = new MessageBoxForm();
            try
            {
                if (_useSavedResponse && this.Name != null)
                {
                    string savedResponse = MessageBoxManager.GetSavedResponse(this);
                    if (savedResponse != null)
                    {
                        return(savedResponse);
                    }
                }
                _msgBox.ClearButtons();
                this.AddButtons(buttons);
                this.Caption = caption;
                this.Text    = text;
                this.Icon    = icon;
                if (owner == null)
                {
                    _msgBox.ShowDialog();
                }
                else
                {
                    _msgBox.ShowDialog(owner);
                }

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

            return(_msgBox.Result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Shows the messsage box with the specified owner
        /// </summary>
        public string Show(IWin32Window owner)
        {
            MessageBoxManager.GetMessageButton();
            _msgBox = new MessageBoxForm();
            if (_useSavedResponse && this.Name != null)
            {
                string savedResponse = MessageBoxManager.GetSavedResponse(this);
                if (savedResponse != null)
                {
                    return(savedResponse);
                }
            }
            _msgBox.ClearButtons();
            this.AddButton(MessageBoxButtonsBA.OK);
            this.Caption = string.Empty;
            this.Text    = string.Empty;
            this.Icon    = MessageBoxIconBA.Information;
            if (owner == null)
            {
                _msgBox.ShowDialog();
            }
            else
            {
                _msgBox.ShowDialog(owner);
            }

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

            return(_msgBox.Result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Add a standard button to the message box
        /// </summary>
        public void AddButton(MessageBoxButtonsBA button)
        {
            string buttonText = MessageBoxManager.GetLocalizedString(button.ToString());

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

            string buttonVal = button.ToString();

            MessageBoxButton btn = new MessageBoxButton();

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

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

            AddButton(btn);
        }