示例#1
0
        private void DeleteEdges()
        {
            List <Edge> removeEdges = new List <Edge>();

            edges.ForEach(e =>
            {
                LogicPort li = e.input as LogicPort;
                LogicPort lo = e.output as LogicPort;
                //BasePort input = (e.input is LogicPort li) ? li.basePort : null;
                //BasePort output = (e.output is LogicPort lo) ? lo.basePort : null;

                if (li == null || lo == null || !BasePort.Connected(li.basePort, lo.basePort) || (li.node as LogicNode).WasRemoved || (lo.node as LogicNode).WasRemoved)
                {
                    if (li != null && li.IsEdgeDragging(e))
                    {
                        return;
                    }
                    if (lo != null && lo.IsEdgeDragging(e))
                    {
                        return;
                    }
                    if (!removeEdges.Contains(e))
                    {
                        removeEdges.Add(e);
                    }
                    return;
                }
            });

            RemoveEdges(removeEdges);
        }
示例#2
0
        private void DisconnectEdge(Edge e)
        {
            LogicPort li = e.input as LogicPort;
            LogicPort lo = e.output as LogicPort;

            if (li == null || lo == null)
            {
                return;
            }
            BasePort.Disconnect(li.basePort, lo.basePort);
        }
示例#3
0
        private void GeneratePort(BasePort basePort)
        {
            LogicPort port = new LogicPort(basePort);

            if (basePort.Direction == PortDirection.Input)
            {
                inputContainer.Add(port);
            }
            else
            {
                outputContainer.Add(port);
            }
        }
示例#4
0
        private void AddEdges()
        {
            List <KeyValuePair <BasePort, LogicPort> > connectables = new List <KeyValuePair <BasePort, LogicPort> >();

            ports.ForEach(p =>
            {
                LogicPort output = p as LogicPort;

                if (output.direction == Direction.Output)
                {
                    foreach (BasePort basePort in output.basePort.GetReferences())
                    {
                        if (!output.connections.Any(e => Equals(basePort, (e.input as LogicPort).basePort)))
                        {
                            connectables.Add(new KeyValuePair <BasePort, LogicPort>(basePort, output));
                        }
                    }
                }
            });

            //foreach (var pair in connectables)
            //{
            //    Debug.Log("Connect In: " + pair.Key.Name + " Out: " + pair.Value.basePort.Name);
            //}

            ports.ForEach(p =>
            {
                LogicPort inputPort = p as LogicPort;
                if (inputPort.direction == Direction.Input)
                {
                    for (int i = 0; i < connectables.Count; i++)
                    {
                        var pair = connectables[i];
                        if (pair.Key.Equals(inputPort.basePort))
                        {
                            Edge e = new Edge()
                            {
                                input  = inputPort,
                                output = pair.Value
                            };

                            inputPort.Connect(e);
                            pair.Value.Connect(e);
                            Add(e);
                            connectables.RemoveAt(i);
                            i--;
                        }
                    }
                }
            });
        }