public void Connect(LocationNode n) { if (!ConnectedNodes.Contains(n)) { ConnectedNodes.Add(n); } }
protected override void OnDragFinish() { ExecuteNode hoveredNode = (SelectionManager.Instance.HoverNode as ExecuteNode); if (!hoveredNode) { Destroy(currentGameObject); currentDraggingLine = null; return; } if (hoveredNode != this) { if (hoveredNode.IsInputNode != IsInputNode) { NodeConnection <ExecuteNode> nodeConnection = new NodeConnectionBuilder <ExecuteNode>() .SetNodes(this, hoveredNode) .SetConnectionLine(currentDraggingLine) .Build(); ConnectedNodes.Add(nodeConnection.Cast <ConnectedNode>()); hoveredNode.ConnectedNodes.Add(nodeConnection.Cast <ConnectedNode>()); RegisterExecNodes(nodeConnection); nodeConnection.UpdateLine(); currentGameObject = null; return; } } Destroy(currentGameObject); currentDraggingLine = null; }
/// <summary> /// /// </summary> /// <param name="dst_"></param> public bool ConnectTo(NodeSlot dst_) { if (dst_.Node == Node) { throw new InvalidOperationException("Try to connect itself"); } foreach (NodeSlot s in ConnectedNodes) { if (s.Node == dst_.Node) // already connected { return(true); //throw new InvalidOperationException(""); } } switch (ConnectionType) { case SlotType.NodeIn: case SlotType.NodeOut: if ((dst_.Node is VariableNode) == true) { return(false); } break; case SlotType.VarIn: case SlotType.VarOut: case SlotType.VarInOut: if ((dst_.Node is VariableNode) == false && (dst_ is NodeSlotVar) == false) { return(false); } break; } ConnectedNodes.Add(dst_); return(true); }
/// <summary> /// Connect all anchors to the nearest nodes /// </summary> private void ConnectToNodes() { ClearNodes(); // Clear previous connections foreach (Vector anchor in Anchors) { Node node = BoardGrid.Magnetize(ImagePosition + anchor); // The nearest node Vector nodeRelativePosition = node.Position - ImagePosition; // Node position relative to the image Directions direction = new Directions(); // Direction of the component relative to the node try { if (Math.Abs(ImageSize.X - nodeRelativePosition.X) < Properties.Settings.Default.GridThickness) // The grid thickness is used as an error threshold { direction = Directions.Left; } else if (Math.Abs(ImageSize.Y - nodeRelativePosition.Y) < Properties.Settings.Default.GridThickness) { direction = Directions.Up; } else if (Math.Abs(nodeRelativePosition.Y) < Properties.Settings.Default.GridThickness) { direction = Directions.Down; } else if (Math.Abs(nodeRelativePosition.X) < Properties.Settings.Default.GridThickness) { direction = Directions.Right; } else { throw new System.ApplicationException("Can't determine anchor position relatively to the node."); } } catch (System.ApplicationException e) { ((MainWindow)Application.Current.MainWindow).LogError(e); // Write error to log and close the processus } ConnectedNodes.Add(node); node.ConnectedElements.Add(this, direction); } }
private void ProcessMessageCore(IncomingMessage message) { if (message.Message.Payload is VersionPayload) { var version = message.AssertPayload <VersionPayload>(); var connectedToSelf = version.Nonce == Nonce; if (message.Node != null && connectedToSelf) { NodeServerTrace.ConnectionToSelfDetected(); message.Node.DisconnectAsync(); return; } if (message.Node == null) { var remoteEndpoint = version.AddressFrom; if (!remoteEndpoint.Address.IsRoutable(AllowLocalPeers)) { //Send his own endpoint remoteEndpoint = new IPEndPoint(((IPEndPoint)message.Socket.RemoteEndPoint).Address, Network.DefaultPort); } var peer = new NetworkAddress() { Endpoint = remoteEndpoint, Time = DateTimeOffset.UtcNow }; var node = new Node(peer, Network, CreateNodeConnectionParameters(), message.Socket, version); if (connectedToSelf) { node.SendMessage(CreateNodeConnectionParameters().CreateVersion(node.Peer.Endpoint, Network)); NodeServerTrace.ConnectionToSelfDetected(); node.Disconnect(); return; } CancellationTokenSource cancel = new CancellationTokenSource(); cancel.CancelAfter(TimeSpan.FromSeconds(10.0)); try { ConnectedNodes.Add(node); node.StateChanged += node_StateChanged; node.RespondToHandShake(cancel.Token); } catch (OperationCanceledException ex) { NodeServerTrace.Error("The remote node did not respond fast enough (10 seconds) to the handshake completion, dropping connection", ex); node.DisconnectAsync(); throw; } catch (Exception) { node.DisconnectAsync(); throw; } } } var messageReceived = MessageReceived; if (messageReceived != null) { messageReceived(this, message); } }
// どこからも参照されていない /* * private void AddRange(IEnumerable<Point3Di> cluster) * { * voxels.AddRange(cluster); * } */ public void AddConnectedNode(DendriteNode node) { ConnectedNodes.Add(node); }
/// <summary> /// Adds node to list of connected nodes. /// </summary> /// <param name="node">The node that will be added to the list of connected nodes.</param> public void AddConnectedNode(NodeGene node) { ConnectedNodes.Add(node); }