It is now recommended to override DrawLocal and DrawShadowLocal methods (instead of Draw and DrawShadow) in custom node types. Overriding DrawLocal will provide you with built-in support for node rotation. The overrides should draw relatively to the bounding rectangle returned by GetLocalBounds. Overriding Draw still works, but any custom drawing code would have to apply a rotation transform corresponding to the node's RotationAngle value.
If your application implements custom drawing via the DrawNode event handler, note that the Bounds value provided as event argument is now relative to the node and not to the diagram.
The provided Graphics object will have translation and rotation transformations applied at the time when DrawLocal is called or DrawNode is raised. If you need your custom graphics elements to ignore the rotation angle, you should save the Graphics state, reset current transform, draw the elements and finally, restore the graphics state.
A significant change in the control's behavior is that it now allows different items to have the same ZIndex values. You must revise your code if it relies on ZIndex being unique or corresponding to the item's position within the Items collection.
Brush, Pen and Font properties of diagram items now have null values by default. This allows items to be skinned via styles and themes. If you need to set a specific object member of one of these properties, you must assign a new object instance to the respective property. For example, such code might throw an exception now:
C# Copy Code |
---|
node.Pen.Color = Color.Black; |
You must replace it with the following:
C# Copy Code |
---|
node.Pen = new Pen(Color.Black, 3); |
When drawing custom graphic elements for an item, use the EffectiveBrush, EffectivePen and EffectiveFont properties to access the objects that should be used for drawing - whether they come from local property values, from the item's Style or from a Theme applied to the diagram.