We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Polyline Tool right click event and Node Selection in a diagram

Thread ID:

Created:

Updated:

Platform:

Replies:

67074 Aug 8,2007 09:36 AM UTC Aug 10,2007 12:25 AM UTC WinForms 1
loading
Tags: Diagram
Elia Chkayra
Asked On August 8, 2007 09:36 AM UTC

Hello again,

I tried this time to use the polyline tool, i noticed that when a right click occurs, the tool automatically groups the drawed line, i want to add a feature on the righr click event wich allows me to connect the polyline begining point and the polyline ending point it they are spaced and then group the object created.

And Also when i use the select tool to select a node, i want to be able to access this selected node, wich function do i have to use. for example i select a node, when i right click on the selected node a menu appears, i choose a number in this menu and the programs will draw copies of the selected node according to the number chosen.

I appreciate your help, Thank you

J.Nagarajan [Syncfusion]
Replied On August 10, 2007 12:25 AM UTC

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.htm

Please 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.htm

Please let me know if you have any questions.

Regards,
Nagaraj

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;