The components in MindFusion.Diagramming are used through an instance of the CompositeNode class or a class deriving from CompositeNode. Simply create concrete component instances and add them to the Components collection of the CompositeNode.
By default the composite node arranges its child components on top of each other, in the order they were added to the Components collection. To apply custom arrangement, the children should be organized in a component hierarchy using the appropriate panel components. For example, to arrange children horizontally, in a row, you can use the StackPanel with Orientation set to Horizontal. Here is an example on how to do this in code:
C# Copy Code |
---|
CompositeNode node = new CompositeNode(); |
Visual Basic Copy Code |
---|
Dim node As New CompositeNode() |
It is possible to create custom panel classes by deriving from ContentComponent and overriding the ArrangeComponents method. For an example on how to implement custom panel classes, check the Creating Custom Components topic.
Another way to arrange child components is by deriving from CompositeNode and overriding the ArrangeComponents method. Then, you can manually assign the position of individual nodes through their Bounds property.
The FindComponent method of the CompositeNode class can be used to search for components by their Name. This method performs a recursive search of all components in the Components collection and returns a reference to the first component with the specified name. This is particularly useful when the component hierarchy is defined through XML and you need to obtain a reference to a specific component in the hierarchy for additional processing. For more information on how to define components in XML check Components and XML.
To retrieve the topmost component at a specific location, use the GetComponentAt method of the CompositeNode class. This method ignores components with any of the following properties set to false: IsEnabled, IsHitTestVisible.