コード例 #1
0
ファイル: Edge.cs プロジェクト: ekostenkodev/CityGraphTest
    public void Remove()
    {
        _node1.Edges.Remove(this);
        _node2.Edges.Remove(this);

        EdgeRemoved.Invoke();
    }
コード例 #2
0
        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));
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
        public bool RemoveEdge(TEdge edge)
        {
            bool edgeWasRemoved;

            lock (SyncRoot)
                edgeWasRemoved = Graph.RemoveEdge(edge);

            if (edgeWasRemoved)
            {
                EdgeRemoved?.Invoke(edge);
            }

            return(edgeWasRemoved);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
ファイル: GraphEditor.cs プロジェクト: j-prox/blueprint41
 void GViewer_EdgeRemoved(object sender, EventArgs e)
 {
     EdgeRemoved?.Invoke(this, new EdgeEventArgs(sender as Edge));
 }