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
|
I have a custom FlowDiagramConnection that has a couple of properties in it that I want to use to set the connection color and line style. I have not been able to successful do this and wanted to see if anyone had any advice. Here is the basis of what I have tried: Public class MyConnection : FlowDiagramConnection { public bool IsDashed { get; set; } public Color LineColor { get; set; } }
In my FlowDiagramFormatter I referenced a custom TypeTemplateSelector I created.
<ms:FlowDiagramFormatter x:Key="Formatter" ConnectionStyleSelector="{StaticResource ConnectionTemplateSelector}" CalculatorSelector="{StaticResource CalculatorSelector}" />
<ms:TypeTemplateSelector x:Key="ConnectionTemplateSelector" BasedOn="{StaticResource {x:Static ms:Whalesong.ConnectionTemplateSelectorKey}}"> <ms:TypeTemplate DataType="nodes:MyConnection" Template="{StaticResource MyConnectionTemplate}" />
</ms:TypeTemplateSelector> I think that if in my resource MyConnectionTemplate if I took the whalesong xaml I could update it accordingly, but I can not find the xaml. Any advice on how to complete this task is appreciated. Thanks, Mike
|
|
|
Hello Mike I have attached a very simple sample that demonstrates what you have described. Though I have done it in a slightly different way than what you have tried so far. To run the sample, you will first need to add references to your copy of WpfDiagrammingFoundation and WpfFlowDiagrams. When you run the sample you will see a start node, action node and end node. creating a connection from the StartNode to any other node will create a plain blue connection. Creating a connection from the ActionNode to any other node will create a dashed green connection. The main thing you may have been missing is the connection builder. In the sample you will see a class called CustomConnectionBuilder which is an implementation of IDiagramConnectionBuilder. This tells the diagram to use instances of CustomConnection as connections in the diagram. This is similar to the MyConnection class you described. The style for the CustomConnection is also very simple. It is just a few lines long and works using a binding and a trigger to change the appearance based on the CustomConnection properties. Ignore the fact that the arrow heads in the sample are still purple, this can still be changed. I'm sure the logic I've used in this sample for selecting a connection style is not what you need, but this sample should help you get something working. Let me know if you have any questions about the sample or need advice for providing different logic. Regards |
|