我正在创建一个工具,该工具会遍历示意图网络并检测圆环是否存在,我已经完成了检测部分,现在在示意图重画部分,我的问题是: 如何使节点中的所有节点都成为一条水平直线?如果存在一个环,则在该线上绘制该环(基本上更改两个环节点的Y坐标) 现在这就是我所拥有的;遗憾的是,它并非在所有情况下都有效。
//Change the schematic diagram graphics
if (ringList.Count > 0)
{
//create a line
foreach (var node1 in nodeList)
{
var movingNode = node1.Shape as ITransform2D;
if (movingNode != null) movingNode.Move(x, 0);
node1.Shape = movingNode as IGeometry;
x = x + 500;
}
//create a ring on that line
if (ringList[0].Count>0)
{
foreach (var nodeName in nodeList)
{
if (ringList[0].Contains(nodeList[z].Name))
{
if(!ringNodes.Contains(nodeList[z]))
ringNodes.Add(nodeList[z]);
}
z++;
}
foreach (var node1 in ringNodes)
{
if ((ringNodes.IndexOf(node1) + 2) % 2 == 0)
{
y = -500;
var movingNode1 = node1.Shape as ITransform2D;
if (movingNode1 != null) movingNode1.Move(0, y);
node1.Shape = movingNode1 as IGeometry;
}
else
{
y = 500;
var movingNode1 = node1.Shape as ITransform2D;
if (movingNode1 != null) movingNode1.Move(0, y);
node1.Shape = movingNode1 as IGeometry;
}
}
}
我知道其中存在很多错误,但我仍在修复它。我只是对示意图中节点的移动感到好奇,我了解到我可以使用Itransform2D接口或通过IGeometry,请帮忙。