protected virtual void DrawStatusBarPanel (Graphics dc, Rectangle area, int index,
Brush br_forecolor, StatusBarPanel panel) {
int border_size = 3; // this is actually const, even if the border style is none
int icon_width = 16;
area.Height -= border_size;
DrawStatusBarPanelBackground (dc, area, panel);
if (panel.Style == StatusBarPanelStyle.OwnerDraw) {
StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs (
dc, panel.Parent.Font, area, index, DrawItemState.Default,
panel, panel.Parent.ForeColor, panel.Parent.BackColor);
panel.Parent.OnDrawItemInternal (e);
return;
}
string text = panel.Text;
StringFormat string_format = new StringFormat ();
string_format.Trimming = StringTrimming.Character;
string_format.FormatFlags = StringFormatFlags.NoWrap;
if (text != null && text.Length > 0 && text [0] == '\t') {
string_format.Alignment = StringAlignment.Center;
text = text.Substring (1);
if (text [0] == '\t') {
string_format.Alignment = StringAlignment.Far;
text = text.Substring (1);
}
}
Rectangle string_rect = Rectangle.Empty;
int x;
int len;
int icon_x = 0;
int y = (area.Height / 2 - (int) panel.Parent.Font.Size / 2) - 1;
switch (panel.Alignment) {
case HorizontalAlignment.Right:
len = (int) dc.MeasureString (text, panel.Parent.Font).Width;
x = area.Right - len - 4;
string_rect = new Rectangle (x, y,
area.Right - x - border_size,
area.Bottom - y - border_size);
if (panel.Icon != null) {
icon_x = x - icon_width - 2;
}
break;
case HorizontalAlignment.Center:
len = (int) dc.MeasureString (text, panel.Parent.Font).Width;
x = area.Left + ((panel.Width - len) / 2);
string_rect = new Rectangle (x, y,
area.Right - x - border_size,
area.Bottom - y - border_size);
if (panel.Icon != null) {
icon_x = x - icon_width - 2;
}
break;
default:
int left = area.Left + border_size;;
if (panel.Icon != null) {
icon_x = area.Left + 2;
left = icon_x + icon_width + 2;
}
x = left;
string_rect = new Rectangle (x, y,
area.Right - x - border_size,
area.Bottom - y - border_size);
break;
}
RectangleF clip_bounds = dc.ClipBounds;
dc.SetClip (area);
dc.DrawString (text, panel.Parent.Font, br_forecolor, string_rect, string_format);
dc.SetClip (clip_bounds);
if (panel.Icon != null) {
dc.DrawIcon (panel.Icon, new Rectangle (icon_x, y, icon_width, icon_width));
}
}