Esempio n. 1
0
    public void AddConnection(ItemClass element, bool newConnection)
    {
        var conn = element.GetClosestConnection();

        if (conn != null)
        {
            if (nodes.Count > 0)
            {
                if (LastNode().connections.Contains(conn) || newConnection)
                {
                    nodes.Add(new Node(conn));
                    LastNode().id = nodes.Count - 1;
                }
                else
                {
                    LastNode().connections.Add(conn);
                    conn.connected = true;
                    DrawNode(LastNode());
                    TrySolve();
                }
            }
            else
            {
                nodes.Add(new Node(conn));
                LastNode().id = nodes.Count - 1;
            }
        }
    }