Hi Elica,
Thanks for your continued interest in SYncfusion product.
If you want to connect the first and last point of the polyline, When you right click on the the diagram model then you have to derive PolyLineBase and PolyLineTool classes. In the Mouse up event of PolyLineTool class you can assign the first and last point of the polyline. Please refer to the following code snippet
public override Tool ProcessMouseUp( MouseEventArgs evtArgs )
{
if( evtArgs.Button == MouseButtons.Right )
{
if( this.Points.Length > c_nMIN_NODE_POINTS )
{
// set InAction property before adding node to document
this.InAction = false;
// complete action
PointF[] pt = this.Points;
pt[pt.Length - 1] = pt[0];
CompleteAction( pt );
toolToReturn = base.ProcessMouseUp( evtArgs );
}
}
}
I have attached the sample that demonstrates this completely. In this sample when you click on Tools->LinkSymbol menuitem, you can activate the polyline tool. You can download the sample from the following page
http://websamples.syncfusion.com//samples/Diagram.Windows/F67074/main.htmPlease refer to it and let me nmow if you have any questions.
2. If you want to access the selected node then please refer to the following code snippet
public delegate void NodeSelection(object sender, CollectionExEventArgs evtargs);
public event NodeSelection nodeselection;
public MainForm()
{
InitializeComponent();
this.nodeselection += new NodeSelection(MainForm_nodeselection);
void MainForm_nodeselection(object sender, CollectionExEventArgs evtargs)
{
if (this.diagram1.Controller.SelectionList.Count > 0)
{
Node node = this.diagram1.Controller.SelectionList.Last as Node;
this.richTextBox1.Text = node.Name;
}
}
//NodeCollectionChanged event
void EventSink_NodeCollectionChanged(CollectionExEventArgs evtArgs)
{
DiagramController controller = this.diagram1.Controller;
Node node = evtArgs.Element as Node;
if (node != null)
{
if (node == controller.SelectionList.First)
{
//Fire the NodeSelection event
this.nodeselection(this,evtArgs);
}
}
}
I have attached the sample that demonstrates this completely. In this sample when you select a node, the name of selected will appear in the textbox. You can download the sample from the following page
http://websamples.syncfusion.com//samples/Diagram.Windows/F67074_2/main.htmPlease let me know if you have any questions.
Regards,
Nagaraj