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; } }