void OnConnectionAdding(object sender, AcceptNodeConnectionEventArgs e) { //e.Cancel = true; }
void OnConnectionRemoved(object sender, AcceptNodeConnectionEventArgs e) { //e.Cancel = true; }
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; }
void OnConnectionAdded(object sender, AcceptNodeConnectionEventArgs e) { //e.Cancel = true; e.Connection.Name = "Connection " + counter ++; e.Connection.DoubleClick += new EventHandler<NodeConnectionEventArgs>(OnConnectionDoubleClick); }
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; if (toNode.AcceptsConnection(fromNode, fromIndex, toIndex)) { MyConnection newConnection = new MyConnection(fromNode, toNode, fromIndex, toIndex); newConnection.Connect(); e.Connection.Tag = newConnection; m_mainForm.RefreshConnections(this); } else { // Make the graph library drop the connection. e.Cancel = true; } }
private void Desktop_ConnectionRemoving(object sender, AcceptNodeConnectionEventArgs e) { e.Cancel = TestIfInsideSimulation(); }
public bool Disconnect(NodeConnection connection) { if (connection == null) return false; if (ConnectionRemoving != null) { var eventArgs = new AcceptNodeConnectionEventArgs(connection); ConnectionRemoving(this, eventArgs); if (eventArgs.Cancel) return false; } if (HasFocus(connection)) FocusElement = null; var from = connection.From; var to = connection.To; if (from != null && from.Node != null) from.Node.connections.Remove(connection); if (to != null && to.Node != null) to.Node.connections.Remove(connection); // Just in case somebody stored it somewhere .. connection.From = null; connection.To = null; if (ConnectionRemoved != null) ConnectionRemoved(this, new NodeConnectionEventArgs(from, to, connection)); this.Invalidate(); return true; }
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); }
public NodeConnection Connect(NodeConnector from, NodeConnector to) { if (from == null || to == null || from.Node == null || to.Node == null || !from.Enabled || !to.Enabled) return null; foreach (var other in from.Node.connections) { if (other.From == from && other.To == to) return null; } foreach (var other in to.Node.connections) { if (other.From == from && other.To == to) return null; } var connection = new NodeConnection(); connection.From = from; connection.To = to; from.Node.connections.Add(connection); to.Node.connections.Add(connection); if (ConnectionAdded != null) { var eventArgs = new AcceptNodeConnectionEventArgs(connection); ConnectionAdded(this, eventArgs); if (eventArgs.Cancel) { Disconnect(connection); return null; } } return connection; }
/// <summary> /// Checks whether the connection between two connectors is allowed. /// This is achieved through event propagation. /// </summary> /// <returns></returns> private bool ConnectionIsAllowed(NodeConnector from, NodeConnector to) { if (HighlightCompatible && null != CompatibilityStrategy) { if (!CompatibilityStrategy.CanConnect(from, to)) return false; } // If someone has subscribed to the ConnectionAdding event, // give them a chance to interrupt this connection attempt. if (null != ConnectionAdding) { // Populate a temporary NodeConnection instance. var connection = new NodeConnection(); connection.From = from; connection.To = to; // Fire the event and see if someone cancels it. var eventArgs = new AcceptNodeConnectionEventArgs(connection); ConnectionAdding(this, eventArgs); if (eventArgs.Cancel) return false; } return true; }
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; } }
private void Desktop_ConnectionRemoving(object sender, AcceptNodeConnectionEventArgs e) { e.Cancel = CanChangeGraph(); }
private void GraphControl1OnConnectionAdded(object sender, AcceptNodeConnectionEventArgs e) { e.Connection.Name = " None "; }