我无法使用WPF,所以我在Winform中使用了elementHost。
在我的项目中(使用Graph#绘制图形)我可以绘制顶点和边缘,但我无法在边缘上放置标签。
代码:
string[] vertices = new string[] { "A", "B", "C" };
var g = new BidirectionalGraph<object, IEdge<object>>();
g.AddVertexRange(vertices);
g.AddEdge(new Edge<object>(vertices[0], vertices[1]));
g.AddEdge(new Edge<object>(vertices[1], vertices[2]));
g.AddEdge(new Edge<object>(vertices[0], vertices[2]));
graphLayout.Graph = g;
答案 0 :(得分:0)
您可以创建颜色图例而不是标签,然后为边缘着色。
if (FirstCase
{
g.AddVertex("A");
Color edgeColor = Colors.Green;
g.AddVerticesAndEdge(new MyEdge("A", "B")
{
EdgeColor = edgeColor
});
}
if (SecondCase
{
g.AddVertex("B");
Color edgeColor = Colors.Red;
g.AddVerticesAndEdge(new MyEdge("B", "C")
{
EdgeColor = edgeColor
});
}