protected virtual Rectangle ManagedWindowDrawTitleBarAndBorders (Graphics dc, Rectangle clip, InternalWindowManager wm)
{
Form form = wm.Form;
int tbheight = ManagedWindowTitleBarHeight (wm);
int bdwidth = ManagedWindowBorderWidth (wm);
Color titlebar_color = Color.FromArgb (255, 10, 36, 106);
Color titlebar_color2 = Color.FromArgb (255, 166, 202, 240);
Color color = ThemeEngine.Current.ColorControlDark;
Color color2 = Color.FromArgb (255, 192, 192, 192);
Pen pen = ResPool.GetPen (ColorControl);
Rectangle borders = new Rectangle (0, 0, form.Width, form.Height);
ControlPaint.DrawBorder3D (dc, borders, Border3DStyle.Raised);
// The 3d border is only 2 pixels wide, so we draw the innermost pixels ourselves
borders = new Rectangle (2, 2, form.Width - 5, form.Height - 5);
for (int i = 2; i < bdwidth; i++) {
dc.DrawRectangle (pen, borders);
borders.Inflate (-1, -1);
}
bool draw_titlebar_enabled = false;
if (wm.Form.Parent != null && wm.Form.Parent is Form) {
draw_titlebar_enabled = false;
} else if (wm.IsActive && !wm.IsMaximized) {
draw_titlebar_enabled = true;
}
if (draw_titlebar_enabled) {
color = titlebar_color;
color2 = titlebar_color2;
}
Rectangle tb = new Rectangle (bdwidth, bdwidth, form.Width - (bdwidth * 2), tbheight - 1);
// HACK: For now always draw the titlebar until we get updates better
if (tb.Width > 0 && tb.Height > 0) {
using (System.Drawing.Drawing2D.LinearGradientBrush gradient = new LinearGradientBrush (tb, color, color2, LinearGradientMode.Horizontal))
{
dc.FillRectangle (gradient, tb);
}
}
if (!wm.IsMinimized)
// Draw the line just beneath the title bar
dc.DrawLine (ResPool.GetPen (SystemColors.Control), bdwidth,
tbheight + bdwidth - 1, form.Width - bdwidth - 1,
tbheight + bdwidth - 1);
return tb;
}