Profile Picture

Cancel Node Inserting

Posted By Volvick Derose 14 Years Ago
Author
Message
Volvick Derose
Posted 14 Years Ago
View Quick Profile
Forum Guru

Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 71, Visits: 1
Refer to the following knowledge base below. I couldn't find a way to cancel the node inserting. For instance, user drag a shape from the library to the drawing area, then a messagebox comes up. If users click yes, the shape is added to the area then if user clicks cancel the shape is not inserted to the drawing area. So how can I do that? The node removing works fine, but not the inserting.


Question:

I have created a diagram that uses a library browser. I can drag and drop several object from the library to the document. The task that I need is for an event to fire on the creation of a new shape, and also an event when an already created shape is altered/deleted. I am having trouble finding a way to hook into these events. These are object that will be created during the run-time of the program. I saw examples for adding changed value events for programmatically created object, but I need for these event handlers to apply to all object created from the library browser. Any information on this would be greatly appreciated.

Answer:

The NodeInserted and NoderRemoved events of the document event sink service will be fired whenever a node has been inserted or removed from the document regardless of the way in which this was done. You can subscribe for this events with the following code:

document.EventSinkService.NodeInserted += new ChildNodeEventHandler(OnNodeInserted);
document.EventSinkService.NodeRemoved += new ChildNodeEventHandler(OnNodeRemoved);

private void OnNodeInserted(NChildNodeEventArgs args)
{
if (args.Child is NShape)
{
// do something when a shape is added
}
}

Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi,

to cancel node removal you can use the cancellable NodeRemoving event. Currently there isn't NodeInserting event (we are going to implement it soon), so for the node inserting you can use the NodeInserted event and eventually remove the inserted node if the user clicks on the Cancel button of your message box.



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic