private void DrawNode(TreeNodeEx node, Drawing.Graphics graphics, Drawing2D.Matrix matrix, ref int totalHeight) { if (node.Visible) { totalHeight += this.HeightIndent + this.Font.Height; // transform coordinates Drawing.PointF[] p = new Drawing.PointF[1]; p[0] = new Drawing.PointF(0.0f, 0.0f); matrix.TransformPoints(p); // calculate location and size node.Location = new Drawing.Point((int)p[0].X, (int)p[0].Y); node.Size = new Drawing.Size(this.Width, this.Font.Height); if (dragOverNode == node) { // draw drag over line graphics.DrawLine(Drawing.Pens.Black, node.Location.X, node.Location.Y, this.Width, node.Location.Y); } // draw plus/minus if (this.ShowPlusMinus) { if (node.Nodes.Count > 0) { graphics.DrawRectangle(Drawing.Pens.Black, (int)p[0].X + 2, (int)p[0].Y + 2, 8, 8); if (!node.Expanded) { // line across graphics.DrawLine(Drawing.Pens.Black, (int)p[0].X + 4, (int)p[0].Y + 6, (int)p[0].X + 8, (int)p[0].Y + 6); // down graphics.DrawLine(Drawing.Pens.Black, (int)p[0].X + 6, (int)p[0].Y + 4, (int)p[0].X + 6, (int)p[0].Y + 8); } else { graphics.DrawLine(Drawing.Pens.Black, (int)p[0].X + 4, (int)p[0].Y + 6, (int)p[0].X + 8, (int)p[0].Y + 6); } } p[0].X += 12; } // draw node image if (!this.imageList.Images.Empty) { this.imageList.Draw(graphics, new Drawing.Point((int)p[0].X, (int)p[0].Y), (node.Expanded) ? node.ExpandedImageIndex : node.CollapsedImageIndex); p[0].X += this.imageList.ImageSize.Width; } // draw node text Drawing.Brush textBrush; if (node == this.selectedNode && this.ChangeColorOnSelected) textBrush = this.TextSelectedBrush; else if (node == this.mouseOverNode && this.ChangeColorOnMouseOver) textBrush = this.TextMouseOverBrush; else textBrush = node.TextBrush; Drawing.Font font = new Drawing.Font(this.Font.FontFamily.Name, this.Font.Size, node.FontStyle); graphics.DrawString(node.Text, font, textBrush, p[0]); // go through children if (node.Expanded && node.Nodes.Count > 0) { matrix.Translate((float)this.WidthIndent, 0.0f); foreach (TreeNodeEx treeNode in node.Nodes) { matrix.Translate(0.0f, this.HeightIndent + this.Font.Height); DrawNode(treeNode, graphics, matrix, ref totalHeight); } matrix.Translate(-(float)this.WidthIndent, 0.0f); } } else matrix.Translate(0.0f, -((float)this.HeightIndent + this.Font.Height)); }