The first issue, i supose i should use event NodeCreated.
I just made a simple check:
private void form_NodeCreated(object sender, NodeEventArgs e)
{
MessageBox.Show("Created!");
}
When create a node, no event fired, or at least i not see the message box.
I think the code should be something like this for count specific nodes:
int counter = 0;
private void form_NodeCreated(object sender, NodeEventArgs e)
{
foreach (var node in form.Nodes)
{
var adapter = node as DiagramNodeAdapter;
if (adapter != null && adapter.Control is MyCustomNode)
{
counter++;
// MessageBox.Show(Convert.ToString(counter));
MyCustomNode Prop = (MyCustomNode)adapter.Control;
if (Prop.Number == 0)
{
Prop.Number = counter;
}
}
}
}
There is no event fired when i create node, so the code wont run.
Anyway this basic code is wrong, duet there is some other rules handle all this behaviour.
The form only can contain up to 8 nodes of type MyCustomNode.
All MyCustomNode need be automatic numbered as 1, 2, 3, 4, 5, 6, 7, 8
Now imagine have 8 nodes created, so that nodes are asigned as 1 to 8 and now i delete MyCustomNod number 5, when create again a new one MyCustomNode need number that as 5 again duet all others already exist.
Well i find the way to doit, i think i need check first numbers already asigned, anyway the first thing is NodeCreated fire event when node is created, and that not happen.
Why?