本文整理汇总了C#中System.Drawing.DrawString方法的典型用法代码示例。如果您正苦于以下问题:C# Drawing.DrawString方法的具体用法?C# Drawing.DrawString怎么用?C# Drawing.DrawString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing
的用法示例。
在下文中一共展示了Drawing.DrawString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawNode
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));
}