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.htm2. 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.htm3. 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.htmPlease refer to the sample and let me know if you have any questions.
Regards,
Nagaraj