public virtual void DrawFlatStyleFocusRectangle (Graphics graphics, Rectangle rectangle, ButtonBase button, Color foreColor, Color backColor) {
// make a rectange to trace around border of the button
Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
Color outerColor = foreColor;
// adjust focus color according to the flatstyle
if (button.FlatStyle == FlatStyle.Popup && !button.is_pressed) {
outerColor = (backColor.ToArgb () == ColorControl.ToArgb ()) ? ControlPaint.Dark(ColorControl) : ColorControlText;
}
// draw the outer rectangle
graphics.DrawRectangle (ResPool.GetPen (outerColor), trace_rectangle);
// draw the inner rectangle
if (button.FlatStyle == FlatStyle.Popup) {
DrawInnerFocusRectangle (graphics, Rectangle.Inflate (rectangle, -4, -4), backColor);
} else {
// draw a flat inner rectangle
Pen pen = ResPool.GetPen (ControlPaint.LightLight (backColor));
graphics.DrawRectangle(pen, Rectangle.Inflate (trace_rectangle, -4, -4));
}
}