예제 #1
0
        void OnConnectionAdded(object sender, AcceptNodeConnectionEventArgs e)
        {
            bool isHidden = (Control.ModifierKeys & Keys.Shift) != 0;

            MyNode fromNode = (e.Connection.From.Node as MyNodeView).Node;
            MyNode toNode   = (e.Connection.To.Node as MyNodeView).Node;

            int fromIndex = (int)e.Connection.From.Item.Tag;
            int toIndex   = (int)e.Connection.To.Item.Tag;

            if (toNode.AcceptsConnection(fromNode, fromIndex, toIndex))
            {
                MyConnection newConnection = new MyConnection(fromNode, toNode, fromIndex, toIndex);
                newConnection.Connect();

                newConnection.IsHidden = isHidden;
                e.Connection.Tag       = newConnection;
                (e.Connection as MyNodeViewConnection).Hidden = isHidden;


                m_mainForm.RefreshConnections(this);
                m_mainForm.ProjectStateChanged("Connection added");
            }
            else
            {
                // Make the graph library drop the connection.
                e.Cancel = true;
            }
        }
예제 #2
0
        void OnConnectionAdded(object sender, AcceptNodeConnectionEventArgs e)
        {
            MyNode fromNode = (e.Connection.From.Node as MyNodeView).Node;
            MyNode toNode   = (e.Connection.To.Node as MyNodeView).Node;

            int fromIndex = (int)e.Connection.From.Item.Tag;
            int toIndex   = (int)e.Connection.To.Item.Tag;

            MyConnection newConnection = new MyConnection(fromNode, toNode, fromIndex, toIndex);

            newConnection.Connect();

            e.Connection.Tag = newConnection;
        }
예제 #3
0
        private void OnConnectionAdded(object sender, AcceptNodeConnectionEventArgs e)
        {
            NodeConnection graphConnection = e.Connection;

            Project.Node nodeFrom = (graphConnection.From.Node as NodeView)?.Node;
            Project.Node nodeTo   = (graphConnection.To.Node as NodeView)?.Node;

            var indexFrom = (int)graphConnection.From.Item.Tag;
            var indexTo   = (int)graphConnection.To.Item.Tag;

            if (nodeTo.InputPorts[indexTo] != null)
            {
                e.Cancel = true;
                return;
            }

            var connection = new Connection(nodeFrom, indexFrom, nodeTo, indexTo);

            connection.Connect();

            graphConnection.Tag = connection;
        }
예제 #4
0
 private void Desktop_ConnectionAdding(object sender, AcceptNodeConnectionEventArgs e)
 {
     e.Cancel = CanChangeGraph();
 }
예제 #5
0
파일: ExampleForm.cs 프로젝트: ywscr/Graph
 void OnConnectionAdded(object sender, AcceptNodeConnectionEventArgs e)
 {
     //e.Cancel = true;
     e.Connection.Name         = "Connection " + counter++;
     e.Connection.DoubleClick += new EventHandler <NodeConnectionEventArgs>(OnConnectionDoubleClick);
 }
예제 #6
0
파일: ExampleForm.cs 프로젝트: ywscr/Graph
 void OnConnectionAdding(object sender, AcceptNodeConnectionEventArgs e)
 {
     //e.Cancel = true;
 }
예제 #7
0
파일: ExampleForm.cs 프로젝트: ywscr/Graph
 void OnConnectionRemoved(object sender, AcceptNodeConnectionEventArgs e)
 {
     //e.Cancel = true;
 }
예제 #8
0
파일: ExampleForm.cs 프로젝트: taknim/XLE
 void OnConnectionRemoved(object sender, AcceptNodeConnectionEventArgs e)
 {
     ShaderFragmentNodeUtil.InvalidateShaderStructure(graphControl);
 }
예제 #9
0
파일: ExampleForm.cs 프로젝트: taknim/XLE
 void OnConnectionAdded(object sender, AcceptNodeConnectionEventArgs e)
 {
     e.Connection.Name = "Connection " + counter++;
     ShaderFragmentNodeUtil.InvalidateShaderStructure(graphControl);
 }
예제 #10
0
파일: ExampleForm.cs 프로젝트: taknim/XLE
 void OnConnectionAdding(object sender, AcceptNodeConnectionEventArgs e)
 {
 }
예제 #11
0
 private void OnConnectionRemoving(object sender, AcceptNodeConnectionEventArgs e)
 {
 }
예제 #12
0
        private void GraphControl1_ConnectionAdded(object sender, AcceptNodeConnectionEventArgs e)
        {
            if (GeneratingGraph)
            {
                return;
            }

            var to   = GetInputItem(e.Connection.From.Item, e.Connection.To.Item);
            var from = GetOutputItem(e.Connection.From.Item, e.Connection.To.Item);

            //Clear all other connections.  This is to prevent multiple connections from attaching to the same pin.
            //Only the latest connection will provide data.
            List <NodeConnection> connections = new List <NodeConnection>(to.Connector.Connectors);

            foreach (var con in connections)
            {
                if (con == e.Connection)
                {
                    continue;                      // Skip our connection, we want to keep it
                }
                graphControl1.Disconnect(con);
            }


            Console.WriteLine("Connected " + from.Node.Title + " to " + to.Node.Title + "'s " + to.Tag);

            if (!(to is ExecuteNodeItem) && to.Node is ActionNode) //If the to node is an action node, notify it that a pin was connected
            {
                var an = to.Node as ActionNode;

                an.PinConnected(from, (string)to.Tag);
            }

            //If we are connecting execute nodes, lets walk back
            if (from is ExecuteNodeItem)
            {
                var executeItem = from as ExecuteNodeItem;


                if (executeItem.ActionCollection != null) //We are directly connected to the root
                {
                    OnExecuteNodeChanged(from as ExecuteNodeItem);
                }
                else   //Walk back the connection chain to find the execute node with the action collection
                {
                    executeItem = (executeItem.Node as AbilityGraphNode).InputExecute;

                    while (executeItem != null && executeItem.ActionCollection == null) //Keep moving backwards until we either are null or we have a action collection
                    {
                        var connection = executeItem.Connector.Connectors.FirstOrDefault();
                        if (connection == null)
                        {
                            executeItem = null;
                            break;
                        }

                        executeItem = connection.From.Item as ExecuteNodeItem;

                        if (executeItem.ActionCollection == null)
                        {
                            executeItem = (executeItem.Node as AbilityGraphNode).InputExecute;
                        }
                    }

                    if (executeItem != null && executeItem.ActionCollection != null) //We've walked back to an action node and we aren't null, so it's an Event node.
                    {
                        OnExecuteNodeChanged(executeItem);
                    }
                }
            }


            ActiveDocument.DocumentEdited(this);
        }
예제 #13
0
 private void Desktop_ConnectionAdding(object sender, AcceptNodeConnectionEventArgs e)
 {
     e.Cancel = TestIfInsideSimulation();
 }