public Rectangle GetTabCloserRect(int index)
{
Rectangle closerRect = new Rectangle();
using (GraphicsPath path = this._StyleProvider.GetTabBorder(index)){
RectangleF rect = path.GetBounds();
// Make it shorter or thinner to fit the height or width because of the padding added to the tab for painting
switch (this.Alignment) {
case TabAlignment.Top:
rect.Y += 4;
rect.Height -= 6;
break;
case TabAlignment.Bottom:
rect.Y += 2;
rect.Height -= 6;
break;
case TabAlignment.Left:
rect.X += 4;
rect.Width -= 6;
break;
case TabAlignment.Right:
rect.X += 2;
rect.Width -= 6;
break;
}
if (this.Alignment <= TabAlignment.Bottom) {
if (this.RightToLeftLayout){
closerRect = new Rectangle((int)rect.Left, (int)rect.Y + (int)Math.Floor((double)((int)rect.Height - 6)/2), 6, 6);
while (!path.IsVisible(closerRect.Left, closerRect.Y) && closerRect.Right < this.Width) {
closerRect.X += 1;
}
closerRect.X += 4;
} else {
closerRect = new Rectangle((int)rect.Right, (int)rect.Y + (int)Math.Floor((double)((int)rect.Height - 6)/2), 6, 6);
while (!path.IsVisible(closerRect.Right, closerRect.Y) && closerRect.Right > -6) {
closerRect.X -= 1;
}
closerRect.X -= 4;
}
} else {
if (this.RightToLeftLayout){
closerRect = new Rectangle((int)rect.X + (int)Math.Floor((double)((int)rect.Width - 6)/2), (int)rect.Top, 6, 6);
while (!path.IsVisible(closerRect.X, closerRect.Top) && closerRect.Bottom < this.Height) {
closerRect.Y += 1;
}
closerRect.Y += 4;
} else {
closerRect = new Rectangle((int)rect.X + (int)Math.Floor((double)((int)rect.Width - 6)/2), (int)rect.Bottom, 6, 6);
while (!path.IsVisible(closerRect.X, closerRect.Bottom) && closerRect.Top > -6) {
closerRect.Y -= 1;
}
closerRect.Y -= 4;
}
}
}
return closerRect;
}