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

Polygon Tool

Thread ID:

Created:

Updated:

Platform:

Replies:

67863 Sep 1,2007 09:24 AM UTC Sep 6,2007 08:52 PM UTC WinForms 3
loading
Tags: Diagram
Elie
Asked On September 1, 2007 09:24 AM UTC

hello,
I am using the polygon tools and i have a few questions:

1 -How can i change the color of the drawed polygon, by default it is yellow, i want it to be transparent.

2- How can i control the insert node event and delete node event.. for example when a polygon is inserted i want to change it's default name and when a polygone is deleted i want some code to be executed.

3- On doubleclicking a node, i want this node to be the selected node and also execute some code.

Thank you for you quick reply

Regards
Elie

J.Nagarajan [Syncfusion]
Replied On September 3, 2007 08:44 PM UTC

Hi Elie,

Thanks for your continued interest in Syncfusion product.

1. To change the color of polygon, you have to derive PolygonTool class and override the CreateNode() method. Please refer to the following code snippet

public class MyPolygonTool: PolyLineBase
{
protected override Node CreateNode( PointF[] pts )
{
Polygon m_polygon = new Polygon(pts);
m_polygon.FillStyle.Color = Color.Transparent;
return (m_polygon);
}
}

// In Tool->Polygon menuitem's click event
private void menuItem2_Click(object sender, EventArgs e)
{
MyPolygonTool m_polygon = new MyPolygonTool(this.diagram1.Controller);
this.diagram1.Controller.RegisterTool(m_polygon);
this.diagram1.Controller.ActivateTool(m_polygon);
}

I have attached the sample that demonstrates this completely. You can download the sample from the following page.
http://websamples.syncfusion.com/samples/Diagram.Windows/F67863/main.htm

2. To change the node's name when it inserts into the diagram model then you have to handle EventSink.NodeCollectionChanged event. In this event you can add your code when you delete the selected node. Please refer to the following code snippet

this.diagram1.Model.EventSink.NodeCollectionChanged+=new CollectionExEventHandler(EventSink_NodeCollectionChanged);

[EventHandlerPriority(true)]
private void EventSink_NodeCollectionChanged(CollectionExEventArgs evtArgs)
{
// Control InsertNodeevent
if (evtArgs.ChangeType == CollectionExChangeType.Insert)
{
Node objnode = evtArgs.Element as Node;
objnode.Name = "PolygonNode";
Console.WriteLine(objnode.Name);
}

if (evtArgs.ChangeType == CollectionExChangeType.Remove)
{
Console.WriteLine("Removed the node from the Diagram");
}

}
Sample: http://websamples.syncfusion.com/samples/Diagram.Windows/F67863/main.htm

3. To achieve this you have to customize a node and you can perform the MouseDoubleClick event. Please refer to the following code snippet.

public class MySymbol : Group
{
protected override void OnMouseDoubleClick()
{
if (this.m_curEllipseColor == m_ellipseColors.Length - 1)
{
this.m_curEllipseColor = 0;
}
else
{
this.m_curEllipseColor++;
}
this.m_innerEllipse.FillStyle.Color = m_ellipseColors[this.m_curEllipseColor];

MessageBox.Show("NodeDoubleClick event gets fired");
}
}

I have attached the sample that demonstrates this completely. You can download the sample from the following page

http://websamples.syncfusion.com/samples/Diagram.Windows/F67863_Sep3/main.htm

Please refer to the sample and let me know if you have any questions.

Regards,
Nagaraj

Elie
Replied On September 4, 2007 06:55 AM UTC

Thank you for your reply,
this was just the event that i needed.

J.Nagarajan [Syncfusion]
Replied On September 6, 2007 08:52 PM UTC

Hi Elie,

Thanks for the update.

Please feel free to contact us if you have any other questions.

Thansk for your continued interest in Syncfusion product.

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

;