private void DrawColumnHeaders(Graphics gr)
{
PerformanceAnalyzer.Start("DrawColumnHeaders");
ReorderColumnState reorder = Input as ReorderColumnState;
int x = 0;
TreeColumn.DrawBackground(gr, new Rectangle(0, 0, ClientRectangle.Width + 2, ColumnHeaderHeight - 1), false, false);
gr.TranslateTransform(-OffsetX, 0);
foreach (TreeColumn c in Columns)
{
if (c.IsVisible)
{
if (x >= OffsetX && x - OffsetX < this.Bounds.Width) // skip invisible columns
{
Rectangle rect = new Rectangle(x, 0, c.Width, ColumnHeaderHeight - 1);
gr.SetClip(rect);
bool pressed = ((Input is ClickColumnState || reorder != null) && ((Input as ColumnState).Column == c));
c.Draw(gr, rect, Font, pressed, _hotColumn == c);
gr.ResetClip();
if (reorder != null && reorder.DropColumn == c)
{
TreeColumn.DrawDropMark(gr, rect);
}
}
x += c.Width;
}
}
if (reorder != null)
{
if (reorder.DropColumn == null)
{
TreeColumn.DrawDropMark(gr, new Rectangle(x, 0, 0, ColumnHeaderHeight));
}
gr.DrawImage(reorder.GhostImage, new Point(reorder.Location.X + +reorder.DragOffset, reorder.Location.Y));
}
PerformanceAnalyzer.Finish("DrawColumnHeaders");
}