public override void DrawTabBorder(RenderContext context,
Rectangle rect,
IPaletteBorder palette,
VisualOrientation orientation,
PaletteState state,
TabBorderStyle tabBorderStyle)
{
Debug.Assert(context != null);
Debug.Assert(palette != null);
// Validate parameter references
if (context == null) throw new ArgumentNullException("context");
if (palette == null) throw new ArgumentNullException("palette");
Debug.Assert(context.Control != null);
Debug.Assert(!context.Control.IsDisposed);
// Is there anything to actually draw?
if ((rect.Width > 0) && (rect.Height > 0))
{
// Decide if we need to use anti aliasing for a smoother looking visual
using (GraphicsHint hint = new GraphicsHint(context.Graphics, palette.GetBorderGraphicsHint(state)))
{
// Cache commonly used values
int borderWidth = palette.GetBorderWidth(state);
// Is there any border to actually draw?
if (borderWidth > 0)
{
// Create the path that represents the entire tab border
using (GraphicsPath borderPath = CreateTabBorderBackPath(context.Control.RightToLeft, state, true, rect,
borderWidth, tabBorderStyle, orientation,
(palette.GetBorderGraphicsHint(state) == PaletteGraphicsHint.AntiAlias)))
{
// Get the rectangle to use when dealing with gradients
Rectangle gradientRect = context.GetAlignedRectangle(palette.GetBorderColorAlign(state), rect);
// Use standard helper routine to create appropriate color brush
using(Brush borderBrush = CreateColorBrush(gradientRect,
palette.GetBorderColor1(state),
palette.GetBorderColor2(state),
palette.GetBorderColorStyle(state),
palette.GetBorderColorAngle(state),
orientation))
{
using (Pen borderPen = new Pen(borderBrush, borderWidth))
context.Graphics.DrawPath(borderPen, borderPath);
}
Image borderImage = palette.GetBorderImage(state);
// Do we need to draw the image?
if (ShouldDrawImage(borderImage))
{
// Get the rectangle to use when dealing with gradients
Rectangle imageRect = context.GetAlignedRectangle(palette.GetBorderImageAlign(state), rect);
// Get the image style to use for the image brush
PaletteImageStyle borderImageStyle = palette.GetBorderImageStyle(state);
// Use standard helper routine to create appropriate image brush
using (Pen borderPen = new Pen(CreateImageBrush(imageRect, borderImage, borderImageStyle), borderWidth))
{
context.Graphics.DrawPath(borderPen, borderPath);
}
}
}
}
}
}
}