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
|
Normal 0 false false false RU X-NONE X-NONE I make custom node with custom OutboundConnectionPoint. public class CustomNode : FlowDiagramNode { private List<InboundConnectionPoint> _inboundConnectionPoints = new List<InboundConnectionPoint>(); private List<OutboundConnectionPoint> _outboundConnectionPoints = new List<OutboundConnectionPoint>();
public CustomNode() { _inboundConnectionPoints.Add(new InboundConnectionPoint(this));
_outboundConnectionPoints.Add(new CustomOutboundConnectionPoint(this, 0, 1, "", ""));
}
protected override IList<InboundConnectionPoint> InboundConnectionPointsCore { get { return _inboundConnectionPoints; } }
protected override IList<OutboundConnectionPoint> OutboundConnectionPointsCore { get { return _outboundConnectionPoints; } }
public void AddEmptyOutboundConnectionPoint() { _outboundConnectionPoints.Add(new CustomOutboundConnectionPoint(this, _outboundConnectionPoints.Count, _outboundConnectionPoints.Count + 1, "", ""));
OnPropertyChanged("ConnectionPoints"); }
}
public class CustomOutboundConnectionPoint : OutboundConnectionPoint { public CustomOutboundConnectionPoint(FlowDiagramNode node, int i, int maxI, string text, string tooltip) : base(node, Edge.Right) { I = i; MaxI = maxI;
Text = text;
Tooltip = tooltip; }
public int MaxI { get; set; }
public int I { get; private set; } public double YPos { get { return (double)(I + 1) / (MaxI + 1); } }
public string Text { get; protected set; } public string Tooltip { get; protected set; } }
Also I using CustomOutboundConnectionCalculatorSelector
public class CustomOutboundConnectionCalculatorSelector : IPositionCalculatorSelector { public IPositionCalculatorSelector BasedOn { get; set; }
public IPositionCalculator SelectCalculator(object item) { CustomOutboundConnectionPoint point = item as CustomOutboundConnectionPoint;
if (point == null) return BasedOn.SelectCalculator(item);
return new OffsetPositionCalculator(1, point.YPos); ; } }
In the diagram it’s look like this
<ms:MatchingTemplateSelector x:Key="NodeTemplateSelector" > <local:CustomNodeDataTemplateMatcher DataType="local:CustomNode" Template="{StaticResource CustomNodeTemplate}" /> </ms:MatchingTemplateSelector>
<localCommon:CustomOutboundConnectionCalculatorSelector x:Key="CalculatorSelector" BasedOn="{StaticResource {x:Static styles:GradientStyle.ConnectionPointPositionCalculatorSelectorKey}}"/>
<flow:FlowDiagramFormatter x:Key="Formatter" CalculatorSelector="{StaticResource CalculatorSelector}" NodeTemplateSelector="{StaticResource NodeTemplateSelector … />
When I create CustomNode and place it to the diagram, all right. CustomOutboundConnectionPoint’s are placed on the right side of nodes. Method CustomOutboundConnectionCalculatorSelector.SelectCalculator are called.
But if I call AddEmptyOutboundConnectionPoint for existing node, new CustomOutboundConnectionPoint placed on the center of existing node and CustomOutboundConnectionCalculatorSelector.SelectCalculator are not called.
Question: how can I dynamically add CustomOutboundConnectionPoint on the right side of existing node?
|
|
|
Hello For working with dynamically adding connection points, you can do this: Remove the _inboundConnectionPoints and _outboundConnectionPoints collections. Replace them with a single observable collection like this: In the constructor, add all the new connection points to this collection. Override the ConnectionPoints property to return this new collection like this:
public override IEnumerable<IDiagramConnectionPoint> ConnectionPoints Change the InboundConnectionPointsCore and OutboundConnectionPointsCore implementations to iterate through the collection and return the appropriate connection points like this:
protected override IList<InboundConnectionPoint> InboundConnectionPointsCore Now in your AddEmptyOutboundConnectionPoint method, add your new connection point to the _connectionPoints collection. and then use: _connectionPoints.Move(0, 0); Let me know how it goes. |
|
|
Thank you, Jason. It's work.
P.S. Last advice is not necessary: _connectionPoints.Move(0, 0); Connection points already dynamically updated. |
|