Represents a flow diagram.
Namespace: MindFusion.Diagramming.Wpf
Assembly: MindFusion.Diagramming.Wpf
C# Copy Code |
---|
public class Diagram : DiagramBase, |
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 inside WPF window, add a DiagramView instance to the Xaml 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 WpfDiagram 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. 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.
Items are aligned to a grid when AlignToGrid is enabled. To display the grid, set ShowGrid to true. The grid size and appearance can be customized via the GridSizeX, GridSizeY, GridPen and GridStyle properties.
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.
Users actions can be validated by handling various events, fired while items are being created, modified or deleted. For example, you can cancel node creation or modification by handling NodeCreating and NodeModifying events.
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.
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.
Use TextFormat and TextBrush to specify alignment and color of the text for all diagram items. EnableStyledText allows using HTML-like tags to format item's text. PolygonalTextLayout allows laying text out inside non-rectangular node shapes.
System.Object
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Media.Visual
System.Windows.UIElement
System.Windows.FrameworkElement
System.Windows.Controls.Control
MindFusion.Diagramming.Wpf.DiagramBase
MindFusion.Diagramming.Wpf.Diagram
MindFusion.Diagramming.Wpf.DiagramPage
MindFusion.Diagramming.Wpf.FishboneDiagram
MindFusion.Diagramming.Wpf.VirtualizingDiagram