Hello,
I am new to Syncfusion and have a couple of basic questions about Essential Diagram.
1) If I add a node from the palette, is it possible to later double click the node and change the text?
2) I am adding connections using ActivateTool but need to capture the event so I can add a label to the connection. Is this possible?
Thanks,
Steve
GM
Gowri Manohari D
Syncfusion Team
May 25, 2009 10:23 AM UTC
Hi Steve,
Thanks for choosing Syncfusion Products.
We can change the text of the node on Node Double Click.The below is the code snippet for changing the node text in Node Double Click event.
For your second requirement After draw the Line using Activate Tool,double click the line and add the label to the Line.The below code illstrate this.
we can add the label to the Connection via Node Double Click event.
In Node Double Click event we have to check what type of Node has double clicked now.If it is a Connector means add label to the Connector.If it is a symbol or shape means change the label for the particular node.
Please refer the below code for more details,
Private Sub Diagram1_NodeDoubleClick(ByVal e As NodeMouseEventArgs)
Dim s As String
'Getting input from the user
s = InputBox("Enter the node label text here", "Node Label")
If (TypeOf (e.Node) Is Syncfusion.Windows.Forms.Diagram.Line) Then
'Adding label to the connetcor
Dim l As Syncfusion.Windows.Forms.Diagram.Label = New Syncfusion.Windows.Forms.Diagram.Label()
l.Position = Position.Center
l.FontStyle.Family = "Arial"
l.FontStyle.Size = 9
l.FontColorStyle.Color = Color.MidnightBlue
l.FontStyle.Bold = True
l.Text = s
Dim con As Syncfusion.Windows.Forms.Diagram.Line = e.Node
con.Labels.Add(l)
Else
Dim node As FilledPath = e.Node
node.Labels(0).Text = s 'Changing node label here
End If
End Sub
Thanks & Regards,
Gowri
SM
Steven Mohnkern
May 25, 2009 02:52 PM UTC
Thank you - that was just what I was looking for. Your support is excellent.
SM
Steven Mohnkern
May 25, 2009 04:00 PM UTC
When I create a LineConnector from right to left, the text is inverted and upside down. Is there a way to flip just the label?
Also, if I use custom position, everytime I move a node it seems that I will have to recalculate the proper location for the labels of all connectors attached to that node. Is there an automated way to do this? If I use Position.Center, the label is right on the line and I need it above the line.
Thanks again
GM
Gowri Manohari D
Syncfusion Team
May 26, 2009 01:06 PM UTC
Hi SteveM,
We are working on this issue. We have to customize the label properties for positioning. It will take time for Customization. Already we have implemented UpdatePostion property for the label. We will provide the workaround for this in one business day.
Thanks & Regards,
Gowri
GM
Gowri Manohari D
Syncfusion Team
May 28, 2009 09:49 AM UTC
Hi SteveM,
The below is the code snippet for your requirement.
Label has the UpdatePosition and Position property for positioning on the node.If we set the UpdatePosition property to true,the label to be fixed in the specified position.Position property indicates the location of the label in the node.More number of positions available we can change the position according to our need.Please refer the code for more details
LineConnector connector = new LineConnector(PointF.Empty, new PointF(0, 1));
connector.HeadDecorator.DecoratorShape = DecoratorShape.Filled45Arrow;
connector.TailDecorator.DecoratorShape = DecoratorShape.Filled45Arrow;
connector.LineStyle.LineColor = Color.MidnightBlue;
connector.HeadDecorator.FillStyle.Color = Color.MidnightBlue;
connector.TailDecorator.FillStyle.Color = Color.MidnightBlue;
Syncfusion.Windows.Forms.Diagram.Label lbl = new Syncfusion.Windows.Forms.Diagram.Label();
lbl.Text = "Custom Label 1";
lbl.UpdatePosition = true;
lbl.Position = Position.BottomLeft;
lbl.FontStyle.Family = "Arial";
lbl.FontStyle.Size = 8;
lbl.FontColorStyle.Color = Color.MidnightBlue;
lbl.FontStyle.Bold = true;
connector.Labels.Add(lbl);
Syncfusion.Windows.Forms.Diagram.Label lbl1 = new Syncfusion.Windows.Forms.Diagram.Label();
lbl1.Text = "Custom Label 2";
lbl1.UpdatePosition = true;
lbl1.Position = Position.BottomRight;
lbl1.FontStyle.Family = "Arial";
lbl1.FontStyle.Size = 8;
lbl1.FontColorStyle.Color = Color.MidnightBlue;
lbl1.FontStyle.Bold = true;
connector.Labels.Add(lbl1);
this.diagram1.Model.AppendChild(connector);
Thanks & Regards,
Gowri