コード例 #1
0
        /// <summary>
        /// Converts <paramref name="graph"/> to an <see cref="Microsoft.Msagl.Drawing.Graph"/>.
        /// </summary>
        /// <typeparam name="TVertex">Vertex type.</typeparam>
        /// <typeparam name="TEdge">Edge type.</typeparam>
        /// <param name="graph">Graph to convert to MSAGL graph.</param>
        /// <param name="nodeAdded">Node added delegate.</param>
        /// <param name="edgeAdded">Edge added delegate.</param>
        /// <returns>MSAGL Graph.</returns>
        public static Graph ToMsaglGraph <TVertex, TEdge>(
            [NotNull] this IEdgeListGraph <TVertex, TEdge> graph,
            [CanBeNull] MsaglVertexNodeEventHandler <TVertex> nodeAdded  = null,
            [CanBeNull] MsaglEdgeEventHandler <TVertex, TEdge> edgeAdded = null)
            where TEdge : IEdge <TVertex>
        {
            MsaglGraphPopulator <TVertex, TEdge> populator = CreateMsaglPopulator(graph);

            try
            {
                if (nodeAdded != null)
                {
                    populator.NodeAdded += nodeAdded;
                }
                if (edgeAdded != null)
                {
                    populator.EdgeAdded += edgeAdded;
                }

                populator.Compute();
                return(populator.MsaglGraph);
            }
            finally
            {
                if (nodeAdded != null)
                {
                    populator.NodeAdded -= nodeAdded;
                }
                if (edgeAdded != null)
                {
                    populator.EdgeAdded -= edgeAdded;
                }
            }
        }
コード例 #2
0
        protected virtual void OnNodeAdded(MsaglVertexEventArgs <TVertex> e)
        {
            MsaglVertexNodeEventHandler <TVertex> eh = this.NodeAdded;

            if (eh != null)
            {
                eh(this, e);
            }
        }
コード例 #3
0
 public static void ShowMsaglGraph <TVertex, TEdge>(
     this IEdgeListGraph <TVertex, TEdge> visitedGraph,
     MsaglVertexNodeEventHandler <TVertex> nodeAdded,
     MsaglEdgeAction <TVertex, TEdge> edgeAdded
     )
     where TEdge : IEdge <TVertex>
 {
     ShowDialog(ToMsaglGraph(visitedGraph, nodeAdded, edgeAdded));
 }
コード例 #4
0
        public static Microsoft.Msagl.Drawing.Graph ToIdentifiableMsaglGraph <TVertex, TEdge>(
#if !NET20
            this
#endif
            IEdgeListGraph <TVertex, TEdge> visitedGraph,
            VertexIdentity <TVertex> vertexIdentities,
            MsaglVertexNodeEventHandler <TVertex> nodeAdded,
            MsaglEdgeAction <TVertex, TEdge> edgeAdded
            )
            where TEdge : IEdge <TVertex>
        {
            Contract.Requires(visitedGraph != null);
            Contract.Requires(vertexIdentities != null);

            var populator = CreateIdentifiableMsaglPopulator(visitedGraph, vertexIdentities);

            try
            {
                if (nodeAdded != null)
                {
                    populator.NodeAdded += nodeAdded;
                }
                if (edgeAdded != null)
                {
                    populator.EdgeAdded += edgeAdded;
                }

                populator.Compute();
                return(populator.MsaglGraph);
            }
            finally
            {
                if (nodeAdded != null)
                {
                    populator.NodeAdded -= nodeAdded;
                }
                if (edgeAdded != null)
                {
                    populator.EdgeAdded -= edgeAdded;
                }
            }
        }
コード例 #5
0
        public static Microsoft.Msagl.Drawing.Graph ToMsaglGraph <TVertex, TEdge>(
            this IEdgeListGraph <TVertex, TEdge> visitedGraph,
            MsaglVertexNodeEventHandler <TVertex> nodeAdded,
            MsaglEdgeAction <TVertex, TEdge> edgeAdded
            )
            where TEdge : IEdge <TVertex>
        {
            Contract.Requires(visitedGraph != null);

            var populator = CreateMsaglPopulator(visitedGraph);

            try
            {
                if (nodeAdded != null)
                {
                    populator.NodeAdded += nodeAdded;
                }
                if (edgeAdded != null)
                {
                    populator.EdgeAdded += edgeAdded;
                }

                populator.Compute();
                return(populator.MsaglGraph);
            }
            finally
            {
                if (nodeAdded != null)
                {
                    populator.NodeAdded -= nodeAdded;
                }
                if (edgeAdded != null)
                {
                    populator.EdgeAdded -= edgeAdded;
                }
            }
        }