예제 #1
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);
        }
예제 #2
0
        /// <summary>
        /// 布局所有控件
        /// Layout all the controls
        /// </summary>
        private void LayoutControls()
        {
            panelIcon.Location  = new Point(LEFT_PADDING, TOP_PADDING);
            rtbMessage.Location = new Point(LEFT_PADDING + panelIcon.Width + ICON_MESSAGE_PADDING * (panelIcon.Width == 0 ? 0 : 1), TOP_PADDING);

            chbSaveResponse.Location = new Point(LEFT_PADDING + (int)(panelIcon.Width / 2),
                                                 TOP_PADDING + Math.Max(panelIcon.Height, rtbMessage.Height) + ITEM_PADDING);

            Size buttonSize       = GetButtonSize();
            int  allButtonsHeight = GetHeightOfAllButtons();

            //int firstButtonX = ((int)(this.ClientSize.Width - allButtonsWidth) / 2);
            int firstButtonX = ((int)(this.ClientSize.Width - buttonSize.Width) / 2);
            //int firstButtonY = this.ClientSize.Height - BOTTOM_PADDING - buttonSize.Height;
            int   firstButtonY       = this.ClientSize.Height - BOTTOM_PADDING - allButtonsHeight;
            Point nextButtonLocation = new Point(firstButtonX, firstButtonY);

            bool foundDefaultButton = false;

            foreach (SEMessageBoxButton button in _buttons)
            {
                SECommandLink buttonCtrl = GetButton(button, buttonSize, nextButtonLocation);

                if (foundDefaultButton == false)
                {
                    _defaultButtonControl = button;
                    foundDefaultButton    = true;
                }

                nextButtonLocation.Y += buttonSize.Height + BUTTON_PADDING;
            }
        }
예제 #3
0
        protected void OnButtonClicked(object sender, EventArgs e)
        {
            SECommandLink btn = sender as SECommandLink;

            //if (btn == null || btn.Tag == null)
            //    return;

            //string result = btn.Tag as string;
            SetResultAndClose(btn.Tag as SEMessageBoxButton);
        }
예제 #4
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 SECommandLink GetButton(SEMessageBoxButton button, Size size, Point location)
        {
            SECommandLink buttonCtrl = null;

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

            return(buttonCtrl);
        }