任何人都可以向我指出如何在winforms应用程序(c#)中通过ElementHost 使用Graph#的示例.
特别是加载*.gml文件并显示Graph-control.
任何帮助赞赏.
小智 6
基本思想是创建一个封装Graph#canvas的WPF用户控件.然后,您将在ElementHost中显示此用户控件.
我已经把一个小的示例应用程序放在一起,通过基本上将GraphSharp.Sample.TestCompoundLayout窗口作为用户控件公开来演示这一点.
http://cl.ly/0w350230200g0w0o2R2N
我还添加了GML文件的加载,基本归结为这个函数:
var graph = new CompoundGraph<object, IEdge<object>>();
try
{
//open the file of the graph
var reader = XmlReader.Create(fileName);
//create the serializer
var serializer = new GraphMLDeserializer<object, IEdge<object>, CompoundGraph<object, IEdge<object>>>();
//deserialize the graph
serializer.Deserialize(reader, graph,
id => id, (source, target, id) => new Edge<object>(source, target)
);
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
layout.Graph = graph;
layout.UpdateLayout();
Run Code Online (Sandbox Code Playgroud)