Represents a flow diagram.
Namespace: MindFusion.Diagramming
Package: MindFusion.Diagramming
C# Copy Code |
---|
public class Diagram : DiagramBase, IItemFactory, IPersists |
Visual Basic Copy Code |
---|
Public Class Diagram |
An instance of the Diagram class represents a diagram document. A Diagram instance does not provide its own user interface. To display a diagram on a form, add a DiagramView instance to the form and set the view's Diagram property. A diagram can be displayed in more than one view.
A diagram can contain connected nodes and links. Nodes are instances of DiagramNode-derived classes. Nodes are stored in the Nodes collection. Links in NetDiagram are instances of the DiagramLink class and are stored in the Links collection. Diagram items can be grouped in hierarchical structures and the so formed groups can be accessed by means of the Groups collection.
Items can be created by using the new operator and added to the diagram by means of the Add method of the Nodes or Links collection. Items are deleted by using the Remove method of the respective collection. There are shortcut methods provided by the diagram's Factory object that can be used to create an item and add it to the diagram with just one method call. Use the CreateTableNode, CreateShapeNode and CreateDiagramLink factory methods to create new items of the respective type.
Hierarchical groups of items are created by adding a Group instance to the diagram's Groups collection. The Factory object provides a shortcut CreateGroup method to do that with a single method call. Use the Remove method of the Groups collection to destroy a group.
Searching for a particular kind of items is done with the FindLink, FindNode and FindGroup methods, which look for an item that has a particular Tag, or FindLinkById and FindNodeById to find items by their Id. To get the item placed at a certain location, use the GetItemAt method.
Binary serialization of diagrams is provided by the SaveToStream and LoadFromStream methods which serialize diagrams to / from .NET streams. SaveToFile and LoadFromFile wrap their stream counterparts to implement easy serialization to disk files. SaveToString and LoadFromString store or load diagrams to/from ASCII strings, allowing easy storage of whole diagrams in a database or their transfer between a web-server and a browser through a hidden html element.
Use the SaveToXml and LoadFromXml methods to serialize a diagram into/from XML documents.
Most aspects of user interaction are controlled by the DiagramView class.
Users actions can be validated by handling various events, fired while items are being created, modified or deleted.
The following properties control what kind of links users can create: AllowLinksRepeat, AllowSelfLoops, AllowUnanchoredLinks, AllowUnconnectedLinks.
The order in which items are hit-tested when clicking on them depends on the value of HitTestPriority. The LinkHitDistance property specifies the furthest distance from a link that a click would be still considered a hit.
If AutoAlignNodes is enabled, nodes are aligned to other nodes so that a pair of their vertical or horizontal sides become collinear. To specify the maximal distance at which nodes are aligned, set the AutoAlignDistance property. The pair of aligned nodes is indicated visually by drawing an alignment guide using the pen assigned to AlignmentGuidePen.
Links can also automatically snap to nodes when AutoSnapLinks is set. The maximal distance at which links will connect to a nearby node is set via AutoSnapDistance.
The Diagram background area can be painted using a solid, gradient, texture or color brush, by setting the BackBrush property, and/or using an image specified by BackgroundImage and BackgroundImageAlign. Some more elaborate visual effects can be applied by means of the EffectsProvider, EnableEmbossEffects and EnableShadowEffects properties.
To further customize the diagram appearance, handle the DrawBackground event to render custom background graphics, or the DrawForeground event to render custom foreground graphics.
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
MindFusion.Diagramming.DiagramBase
MindFusion.Diagramming.Diagram
MindFusion.Diagramming.DiagramPage