Most events are raised only in response to users actions. If you need to execute the same code after user actions and API calls, move the common code to a method and invoke the method both in the respective event handler and after the API method or property setter call. A notable exception is the *Deleted set of events, which are also raised when items are deleted programmatically, because in some circumstances deleting an item could delete other items related to it.
When a user starts drawing a new item with the mouse, the control raises an initialization event to let you set the appearance properties of the item. That is, for a node, the control raises InitializeNode.
While the user is holding down the mouse button and drawing, a validation event is raised to let you cancel the item creation (for example, NodeCreating). If the action is not cancelled, a creation event is raised to let your application know about the new item (for example, NodeCreated). There are events raised when users modify items, for example, NodeModifying and NodeModified. Call the CancelDrag method to cancel the item modification or creation from the *Modifying or *Creating events raised for nodes or links.
Note |
---|
In order to repaint the screen quickly while modifying items or drawing new ones, MindFusion.Diagramming caches the representation of all items not affected by the modification in an off-screen bitmap. When the mouse is moved, the cache bitmap is blitted to the screen and only the item being modified is redrawn. If an application changes the appearance properties of items in the cache while handling a mouse movement related event, the changes won't be visualized correctly on the screen until the mouse button is released and drawing completes. Use the RecreateCacheImage method to recreate the cache bitmap, so that the changes in item's appearance are immediately visualized. |
When a user presses the DEL key, there is a validation event raised to let you confirm that an item should be deleted (for example, NodeDeleting), and if not cancelled, there is an item-deleted event raised (for example, NodeDeleted).
There are many other events related to various activities a user could carry out on the diagram. The full set of events can be found here:
DiagramBase Events
DiagramView Events