public void RemoveNode(Node node) { lock (nodesLock) if (!nodes.Contains(node)) { LogEngineError($"Can`t remove node [{node.GetType().Name}]. Node [{node.Id}] does not exist."); return; } List <Node> nodesToRemove = new List <Node>(); nodesToRemove.Add(node); List <Link> linksToRemove = new List <Link>(); List <Link> links = GetLinksForNode(node); linksToRemove.AddRange(links); foreach (var link in links) { RemoveLink(link, false); } node.OnRemove(); if (node is PanelNode) { var nodesOnPanel = GetNodesForPanel(node.Id, true); nodesToRemove.AddRange(nodesOnPanel); foreach (var n in nodesOnPanel) { List <Link> li = GetLinksForNode(n); linksToRemove.AddRange(li); foreach (var link in li) { RemoveLink(link, false); } LogEngineInfo($"Remove node [{n.GetType().Name}]"); OnRemoveNode?.Invoke(n); lock (nodesLock) nodes.Remove(n); } } lock (nodesLock) nodes.Remove(node); nodesDb?.RemoveNodes(nodesToRemove); nodesDb?.RemoveLinks(linksToRemove); LogEngineInfo($"Remove node [{node.GetType().Name}]"); OnRemoveNode?.Invoke(node); }
public void RemoveNode(int nodeId) { Node oldNode = GetNode(nodeId); if (oldNode == null) { LogError($"Can`t remove Node[{nodeId}]. Does not exist."); return; } nodes.Remove(oldNode); db?.RemoveNode(oldNode.Id); LogInfo($"Remove Node[{nodeId}]"); OnRemoveNode?.Invoke(oldNode); }
private void OnClickRemoveNode() { OnRemoveNode?.Invoke(this); }