private void SetButtonsPosition()
{
// set the size and location for close and auto-hide buttons
Rectangle rectCaption = ClientRectangle;
int buttonWidth = this.ButtonClose.Image.Width;
int buttonHeight = this.ButtonClose.Image.Height;
int height = rectCaption.Height - ButtonGapTop - ButtonGapBottom;
if (buttonHeight < height)
{
buttonWidth = buttonWidth * (height / buttonHeight);
buttonHeight = height;
}
var buttonSize = new Size(buttonWidth, buttonHeight);
int x = rectCaption.X + rectCaption.Width - 1 - ButtonGapRight - this.m_buttonClose.Width;
int y = rectCaption.Y + ButtonGapTop;
var point = new Point(x, y);
this.ButtonClose.Bounds = DrawHelper.RtlTransform(this, new Rectangle(point, buttonSize));
// If the close button is not visible draw the auto hide button overtop.
// Otherwise it is drawn to the left of the close button.
if (this.CloseButtonVisible)
point.Offset(-(buttonWidth + ButtonGapBetween), 0);
this.ButtonAutoHide.Bounds = DrawHelper.RtlTransform(this, new Rectangle(point, buttonSize));
if (this.ShouldShowAutoHideButton)
point.Offset(-(buttonWidth + ButtonGapBetween), 0);
this.ButtonOptions.Bounds = DrawHelper.RtlTransform(this, new Rectangle(point, buttonSize));
}