I use this piece of code the program runs but now i cant see the link lables at all.
even zoomtorezt dont show any lables,
i debug the code it seems string are drawn.
I guess i am missing something
private void diagramView1_Paint(object sender, PaintEventArgs e)
{
System.Drawing.Brush textBrush = new System.Drawing.SolidBrush(Color.Black);
System.Drawing.Brush backBrush = diagram1.BackBrush.CreateGdiBrush(diagram1.Bounds);
foreach (DiagramLink l in diagram1.Links)
{
int s = l.SegmentCount / 2;
PointF p1 = l.ControlPoints[s];
PointF p2 = l.ControlPoints[s + 1];
float iX;
if (p2.X < p1.X)
iX = p2.X + 10F;
else if (p2.X > p1.X)
iX = p2.X - 10F;
else
iX = (p1.X + p2.X) / 2;
PointF c = new PointF(iX, (p1.Y + p2.Y) / 2);//(p1.X + p2.X) / 2
SizeF textSize = diagram1.MeasureString(l.Text, l.Font, int.MaxValue, StringFormat.GenericDefault);
float w = textSize.Width;
float h = textSize.Height;
RectangleF textRect = new RectangleF(c.X - w / 2, c.Y - h / 2, w, h);
StringFormat stringFormat = new StringFormat();
stringFormat.Alignment = StringAlignment.Center;
stringFormat.LineAlignment = StringAlignment.Center;
e.Graphics.FillRectangle(backBrush, textRect);
e.Graphics.DrawString(l.Text, l.Font, textBrush, textRect, stringFormat);
}
backBrush.Dispose();
textBrush.Dispose();
}