@@ -67,15 +67,27 @@ private string ExportGraphMLAsString()
6767 private string ExportGraphViz ( )
6868 {
6969 var graphviz = new GraphvizAlgorithm < PSVertex , PSEdge > ( Graph ) ;
70+ ApplyRenderProperties ( Graph . RenderProperties , graphviz . GraphFormat ) ;
7071 graphviz . FormatVertex += Graphviz_FormatVertex ;
72+ graphviz . FormatEdge += Graphviz_FormatEdge ;
7173 return graphviz . Generate ( ) ;
7274 }
7375
7476 private void Graphviz_FormatVertex ( object sender , FormatVertexEventArgs < PSVertex > args )
7577 {
76- foreach ( var entry in args . Vertex . RenderProperties )
78+ ApplyRenderProperties ( args . Vertex . RenderProperties , args . VertexFormat ) ;
79+ }
80+
81+ private void Graphviz_FormatEdge ( object sender , FormatEdgeEventArgs < PSVertex , PSEdge > args )
82+ {
83+ ApplyRenderProperties ( args . Edge . RenderProperties , args . EdgeFormat ) ;
84+ }
85+
86+ private static void ApplyRenderProperties ( IDictionary < string , object ? > properties , object formatTarget )
87+ {
88+ foreach ( var entry in properties )
7789 {
78- var destProperty = args . VertexFormat . GetType ( ) . GetProperty (
90+ var destProperty = formatTarget . GetType ( ) . GetProperty (
7991 entry . Key ,
8092 BindingFlags . Public | BindingFlags . Instance | BindingFlags . IgnoreCase ) ;
8193
@@ -86,7 +98,7 @@ private void Graphviz_FormatVertex(object sender, FormatVertexEventArgs<PSVertex
8698
8799 if ( TryConvertRenderPropertyValue ( entry . Value , destProperty . PropertyType , out var convertedValue ) )
88100 {
89- destProperty . SetValue ( args . VertexFormat , convertedValue ) ;
101+ destProperty . SetValue ( formatTarget , convertedValue ) ;
90102 }
91103 }
92104 }
0 commit comments