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

                //See if standard cancel button is present
                foreach (SEMessageBoxButton button in _buttons)
                {
                    //if (button.Text == SEMessageBoxButtons.Cancel.ToString() && button.Value == SEMessageBoxButtons.Cancel.ToString())
                    if (button.Text == SEMessageBoxButtons.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 SEMessageBoxButton;
            }
            else
            {
                //This condition should never get called
                _allowCancel = false;
            }
        }
Exemple #2
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 SECommandLink CreateButton(SEMessageBoxButton button, Size size, Point location)
        {
            SECommandLink buttonCtrl = new SECommandLink();

            button.Control        = buttonCtrl;
            buttonCtrl.Size       = size;
            buttonCtrl.HeaderText = button.Text;
            //buttonCtrl.TextAlign = ContentAlignment.MiddleCenter;
            //buttonCtrl.FlatStyle = FlatStyle.System;
            if (button.Description != null && button.Description.Trim().Length != 0)
            {
                //buttonToolTip.SetToolTip(buttonCtrl, button.Description);
                buttonCtrl.DescriptionText = button.Description;
            }
            else
            {
                buttonCtrl.DescriptionText = null;
            }
            buttonCtrl.Image    = IconResource.Arrow_right_green;
            buttonCtrl.Location = location;
            buttonCtrl.Click   += new EventHandler(OnButtonClicked);
            buttonCtrl.Tag      = button;

            return(buttonCtrl);
        }
 public SEMessageBoxButton Show(IWin32Window owner)
 {
     if (_useSavedResponse && this.Name != null)
     {
         SEMessageBoxButton savedResponse = SEMessageBoxManager.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)
         {
             SEMessageBoxManager.SetSavedResponse(this, _msgBox.Result);
         }
         else
         {
             SEMessageBoxManager.ResetSavedResponse(this.Name);
         }
     }
     else
     {
         Dispose();
     }
     return(_msgBox.Result);
 }
Exemple #4
0
 internal static void SetSavedResponse(SEMessageBox msgBox, SEMessageBoxButton response)
 {
     if (msgBox.Name == null)
     {
         return;
     }
     _savedResponses[msgBox.Name] = response;
 }
Exemple #5
0
        protected void AddOkButtonIfNoButtonsPresent()
        {
            if (_buttons.Count == 0)
            {
                SEMessageBoxButton okButton = new SEMessageBoxButton();
                okButton.Text = SEMessageBoxButtons.Ok.ToString();
                //okButton.Value = SEMessageBoxButtons.Ok.ToString();

                _buttons.Add(okButton);
            }
        }
        public void AddButton(string text)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text", "Text of a button cannot be null");
            }
            SEMessageBoxButton button = new SEMessageBoxButton();

            button.Text = text;
            AddButton(button);
        }
        public void AddButton(SEMessageBoxButtons button)
        {
            string buttonText = SEMessageBoxManager.GetLocalizedString(button.ToString());

            if (buttonText == null)
            {
                buttonText = button.ToString();
            }
            string             buttonVal = button.ToString();
            SEMessageBoxButton btn       = new SEMessageBoxButton();

            btn.Text = buttonText;
            if (button == SEMessageBoxButtons.Cancel)
            {
                btn.IsCancelButton = true;
            }
            AddButton(btn);
        }
Exemple #8
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(SEMessageBoxButton button, Size size, Point location)
        {
            Button buttonCtrl = new Button();

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

            return(buttonCtrl);
        }
Exemple #9
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(SEMessageBoxButton 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);
        }
Exemple #10
0
        protected override void OnClosing(CancelEventArgs e)
        {
            if (_result == null)
            {
                if (_allowCancel)
                {
                    _result = _cancelButton;
                }
                else
                {
                    e.Cancel = true;
                    return;
                }
            }

            if (timerTimeout != null)
            {
                timerTimeout.Stop();
            }

            base.OnClosing(e);
        }
Exemple #11
0
 protected void SetResultAndClose(SEMessageBoxButton result)
 {
     _result           = result;
     this.DialogResult = DialogResult.OK;
 }