Beispiel #1
0
        public string GetWiringCode(IPortConnection wire)
        {
            if (wire.Render.Visibility != Visibility.Visible)
            {
                return("");
            }
            if ((Graph.GetNode(wire.SourceId) as VisualPortGraphNode)?.Type.StartsWith("@") ?? false)
            {
                return("");
            }

            var sb = new StringBuilder();

            var A     = Graph.GetNode(wire.SourceId) as VisualPortGraphNode;
            var AName = !string.IsNullOrWhiteSpace(A.Name) ? A.Name : $"id_{A.Id}";

            AName = AName.Replace("@", "");

            var B     = Graph.GetNode(wire.DestinationId) as VisualPortGraphNode;
            var BName = !string.IsNullOrWhiteSpace(B.Name) ? B.Name : $"id_{B.Id}";

            BName = BName.Replace("@", "");

            sb.Append($"{AName}.WireTo({BName}, \"{wire.SourcePort.Name}\");");

            return(sb.ToString());
        }
 public void RemoveConnection(IPortConnection connection)
 {
     if (connection is PortConnection portConnection)
     {
         var index = connections.IndexOf(portConnection);
         connections.RemoveAt(index);
     }
 }
Beispiel #3
0
 public static bool IsTarget(this IPortConnection connection, INodePort target)
 {
     return(connection.NodeId == target.NodeId && connection.PortName == target.ItemName);
 }