Exemple #1
0
        private void SetButtonsPosition()
        {
            // set the size and location for close and auto-hide buttons
            Rectangle rectCaption  = ClientRectangle;
            int       buttonWidth  = ImageCloseEnabled.Width;
            int       buttonHeight = ImageCloseEnabled.Height;
            int       height       = rectCaption.Height - ButtonGapTop - ButtonGapBottom;

            if (buttonHeight < height)
            {
                buttonWidth  = buttonWidth * (height / buttonHeight);
                buttonHeight = height;
            }
            m_buttonClose.SuspendLayout();
            m_buttonAutoHide.SuspendLayout();
            Size buttonSize = new Size(buttonWidth, buttonHeight);

            m_buttonClose.Size = m_buttonAutoHide.Size = buttonSize;
            int   x     = rectCaption.X + rectCaption.Width - 1 - ButtonGapRight - m_buttonClose.Width;
            int   y     = rectCaption.Y + ButtonGapTop;
            Point point = m_buttonClose.Location = new Point(x, y);

            if (ShouldShowCloseButton)
            {
                point.Offset(-(m_buttonAutoHide.Width + ButtonGapBetween), 0);
            }
            m_buttonAutoHide.Location = point;
            m_buttonClose.ResumeLayout();
            m_buttonAutoHide.ResumeLayout();
        }