This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi,
Is there any built in support to add a label at a connection point including the destination point? I can see that labels can be added easily to connections at their source. For our application, we need to be able to easily label the source and destination of a connection.
Best regards.
|
|
|
Hello I have attached a sample project that demonstrates how to display labels at both ends of a connection. To run the sample, make sure to include a reference to your copy of Mindscape.WpfDiagramming.Foundation.dll. After running the sample, drag a couple of nodes onto the diagram surface and create a connection between them. You will see that there is a label displayed at both ends of the connection displaying some default text. You can copy the various parts of this sample into your application to get this dual label effect. Here is a description of how it works to help you along: To achieve this, I created a model object called ConnectionData which contains 2 object properties. One represents the label displayed at the source of the connection, and the other for the destination label. An instance of this object can be used to set the Data property of a connection. I also created a custom IDiagramConnectionBuilder called ConnectionBuilder which overrides the behaviour of when a user creates a connection. On line 20 of the ConnectionBuilder class, I create an instance of the ConnectionData with default values to set the Data property of the connection that is created. In MainWindow.xaml.cs the DefaultConnectionBuilder of the diagram is set to be this custom connection builder so that it can take effect. The final part of this project is the custom connection style found in MainWindow.xaml. The main difference between this custom style and the generic style is that it has 2 content presenters. One at line 201, the other at line 213. The multi bindings used to set the RenderTransforms take care of positioning the labels in the right place. A different ContentTemplate has been applied to each content presenter which have their own bindings to the appropriate propety in the ConnectionData class. The custom connection style is incorporated in the diagram by setting the Formatter property of the DiagramSurface on line 310. The formatter itself is located at line 274. Let me know how it goes |
|