Exemple #1
0
            /// <summary>
            ///   Returns candidates for all ports at orange nodes in the graph, except
            ///   for the current source node to avoid the creation of self-loops.
            /// </summary>
            public IEnumerable <IPortCandidate> GetTargetPortCandidates(IInputModeContext context)
            {
                List <IPortCandidate> result = new List <IPortCandidate>();

                // add the current one as the default
                result.Add(new DefaultPortCandidate(edge.TargetPort));
                var graph = context.GetGraph();

                if (graph == null)
                {
                    return(result);
                }
                foreach (INode node in graph.Nodes)
                {
                    if (node != edge.SourcePort.Owner && Colors.Orange.Equals(node.Tag))
                    {
                        // If available, use the candidates from the provider. Otherwise, add a default candidate.
                        IPortCandidateProvider provider = node.Lookup <IPortCandidateProvider>();
                        if (provider != null)
                        {
                            result.AddRange(provider.GetTargetPortCandidates(context));
                        }
                        else
                        {
                            result.Add(new DefaultPortCandidate(node, FreeNodePortLocationModel.NodeCenterAnchored));
                        }
                    }
                }
                return(result);
            }
Exemple #2
0
 internal CustomPortCandidateProvider(INode node)
 {
     this.node = node;
     geometryPortCandidateProvider =
         PortCandidateProviders.Combine(
             PortCandidateProviders.FromNodeCenter(node),
             PortCandidateProviders.FromShapeGeometry(node));
 }