MindFusion.Diagramming defines proxy classes to wrap the functionality of standard .NET brushes and pens and expose them as properties of diagram elements. Those classes, located in the MindFusion.Drawing namespace, have the same names as their System.Drawing counterparts. There are five brush classes that inherit the abstract class Brush, namely HatchBrush, LinearGradientBrush, PathGradientBrush, SolidBrush and TextureBrush. There's also a Pen class - proxy for the .NET Pen.
There are two reasons to use proxy classes instead the original GDI classes. First, the GDI resources are limited and would be exhausted by keeping a GDI pen and brush attached all the time to each diagram element; by using proxies the GDI pen and brush are created only at the time of drawing, and immediately disposed after that. Second, the GDI Pen and Brush classes don't support serialization; the proxy-classes implement the required interfaces instead.
Otherwise the proxy classes expose the same properties as their GDI counterparts. You might set default pen and brush properties like this:
C# Copy Code |
---|
diagram.ShapeBrush = new MindFusion.Drawing.LinearGradientBrush( |
Visual Basic Copy Code |
---|
Diagram.ShapeBrush = New MindFusion.Drawing.LinearGradientBrush( _ |
After that piece of code is executed, every new shape node created will have gradient brush and pen.
Instances of those classes can be assigned to the Pen and Brush properties of each diagram element.