Hi,
Consider using TableNodes, they let you assign different font to each cell:
var node = diagram.Factory.CreateTableNode(
rect, 2 /* columns */, 2 /* rows */);
node.Caption = nodeName;
node[0, 0].Text = "Start time:";
node[0, 0].TextFormat.Alignment = StringAlignment.Far;
node[0, 1].Text = "Avg.Run time:";
node[0, 1].TextFormat.Alignment = StringAlignment.Far;
node[1, 0].Text = avgStartTime;
node[1, 0].Font = new Font("Arial", 4, GraphicsUnit.World);
node[1, 0].TextBrush = new MindFusion.Drawing.SolidBrush(Color.Red);
node[1, 1].Text = ts;
node.ResizeToFitText(false);
node.Scrollable = false;
node.CellFrameStyle = CellFrameStyle.None;
node.Font = new Font("Times New Roman", 3, GraphicsUnit.World);
node.TextBrush = new MindFusion.Drawing.SolidBrush(Color.Blue);
node.Brush = new MindFusion.Drawing.SolidBrush(Color.LightBlue);
If you prefer using ShapeNodes, you could change color and some font attributes for the avgStartTime by setting EnableStyledText and enclosing within <b>,<i>,<color> tags. This won't let you change the font family.
var node = diagram.Factory.CreateShapeNode(rect);
node.Font = new Font("Times New Roman", 3, GraphicsUnit.World);
node.TextBrush = new MindFusion.Drawing.SolidBrush(Color.Blue);
node.Brush = new MindFusion.Drawing.SolidBrush(Color.LightBlue);
node.PolygonalTextLayout = true;
node.EnableStyledText = true;
node.Text =
nodeName + "\n" +
" \n" +
"Start time:<b><color=#FF0000>" + avgStartTime + "</color></b>\n" +
"Avg.Run time:" + ts;
Or otherwise you could set ShapeNode's CustomDraw property and draw the text yourself using any fonts you like by calling GDI+ DrawString method from DrawNode event handler.
Brush cannot change dynamically based on node's text, you will have to set it yourself each time you assign to the Text property. You could possibly implement that via extension method:
static class ShapeNodeExtensions
{
static public void SetText(this ShapeNode node, string text)
{
node.Text = text;
node.Brush = text.StartsWith("XXXX") ?
new MindFusion.Drawing.SolidBrush(Color.LightGreen) :
new MindFusion.Drawing.SolidBrush(Color.LightBlue);
}
}
shapeNode.SetText(...);
I hope that helps,
Stoyan