public void Remove() { _node1.Edges.Remove(this); _node2.Edges.Remove(this); EdgeRemoved.Invoke(); }
public RemoveVertexResult <TVertex, TEdge> RemoveVertex(TVertex vertex) { bool vertexWasRemoved; TEdge[] edgesOfRemovedVertex; lock (SyncRoot) { edgesOfRemovedVertex = Graph.GetAllEdges(vertex).ToArray(); vertexWasRemoved = Graph.RemoveVertex(vertex); } if (!vertexWasRemoved) { return(RemoveVertexResult <TVertex, TEdge> .Empty); } foreach (var edge in edgesOfRemovedVertex) { EdgeRemoved?.Invoke(edge); } VertexRemoved?.Invoke(vertex); return(new RemoveVertexResult <TVertex, TEdge>(vertex, edgesOfRemovedVertex)); }
/// <summary> /// Called on each removed edge. /// </summary> /// <param name="edge">Removed edge.</param> protected virtual void OnEdgeRemoved([NotNull] TEdge edge) { if (edge == null) { throw new ArgumentNullException(nameof(edge)); } EdgeRemoved?.Invoke(edge); }
public bool RemoveEdge(TEdge edge) { bool edgeWasRemoved; lock (SyncRoot) edgeWasRemoved = Graph.RemoveEdge(edge); if (edgeWasRemoved) { EdgeRemoved?.Invoke(edge); } return(edgeWasRemoved); }
private void CloseNodesAndEdges() { CacheMovableData(); if (Edges != null) { for (var i = 0; i < Edges.Length; i++) { if (Edges[i] != null) { Edges[i].CurveUpdated -= OnCurveUpdated; EdgeRemoved?.Invoke(this, Edges[i]); Edges[i].Close(); } Edges[i] = null; } } // ReSharper disable once InvertIf if (Nodes != null) { for (var i = 0; i < Nodes.Length; i++) { if (Nodes[i] != null) { NodeRemoved?.Invoke(this, Nodes[i]); if (!Definition.Nodes[i].Movable) { Nodes[i].UnpinTangent(); } } Nodes[i] = null; } } EdgeSetupChanged?.Invoke(this); }
/// <summary> /// Called on each removed edge. /// </summary> /// <param name="edge">Removed edge.</param> protected virtual void OnEdgeRemoved(TEdge edge) { Debug.Assert(edge != null); EdgeRemoved?.Invoke(edge); }
void GViewer_EdgeRemoved(object sender, EventArgs e) { EdgeRemoved?.Invoke(this, new EdgeEventArgs(sender as Edge)); }