Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何以编程方式在visio中重新路由连接器?_C#_Vba_Visio - Fatal编程技术网

C# 如何以编程方式在visio中重新路由连接器?

C# 如何以编程方式在visio中重新路由连接器?,c#,vba,visio,C#,Vba,Visio,我正在为visio 2013开发VSTO插件。我需要重新路由连接器,因为图表很复杂,包含很多步骤。自动布线的连接器没有清晰的路径。是否有任何方法可以通过编程方式重新路由连接器?就像在visio应用程序中手动拖动连接器点一样 我读了一些vba文档 但是没有人能给我洞察力。你启发我尝试一下,因为我需要做类似的事情。 这是我找到的一种方法,可以让它发挥作用。此子例程引用接头形状,隐藏自动布线的线,添加新的几何图形截面,并手动调整该截面内的几个点(基于原始可见线的高度/宽度百分比)。显然,您可以通过编程

我正在为visio 2013开发VSTO插件。我需要重新路由连接器,因为图表很复杂,包含很多步骤。自动布线的连接器没有清晰的路径。是否有任何方法可以通过编程方式重新路由连接器?就像在visio应用程序中手动拖动连接器点一样

我读了一些vba文档
但是没有人能给我洞察力。

你启发我尝试一下,因为我需要做类似的事情。 这是我找到的一种方法,可以让它发挥作用。此子例程引用接头形状,隐藏自动布线的线,添加新的几何图形截面,并手动调整该截面内的几个点(基于原始可见线的高度/宽度百分比)。显然,您可以通过编程方式调整数量/位置

Sub CustomRoutedConnector(shpConnectorShape As Shape)

    With shpConnectorShape
        'Hide the automatically routed connector line (still there, just hidden)
        .CellsSRC(visSectionFirstComponent, 0, 2).FormulaU = "TRUE"

        'Make a custom geometry section
        .AddSection visSectionFirstComponent + 1
        .AddRow visSectionFirstComponent + 1, visRowComponent, visTagComponent
        .AddRow visSectionFirstComponent + 1, visRowVertex, visTagLineTo
        .AddRow visSectionFirstComponent + 1, visRowVertex, visTagMoveTo

        'Set up the new geometry section rows (11,1 and 11,2 are the start and end rows)
        .CellsSRC(11, 0, 0).FormulaForceU = "TRUE"
        .CellsSRC(11, 0, 1).FormulaForceU = "FALSE"
        .CellsSRC(11, 0, 2).FormulaForceU = "FALSE"
        .CellsSRC(11, 0, 3).FormulaForceU = "FALSE"
        .CellsSRC(11, 0, 5).FormulaForceU = "FALSE"
        .CellsSRC(11, 1, 0).FormulaU = "0"
        .CellsSRC(11, 1, 1).FormulaU = "0"
        .CellsSRC(11, 2, 0).FormulaU = "0"
        .CellsSRC(11, 2, 1).FormulaU = "0"

        'Add two additional rows for demonstration (could be programatically 
        'adjusted to however many points you need)

        .AddRow visSectionFirstComponent + 1, 2, visTagLineTo
        .CellsSRC(11, 2, 0).FormulaU = "0"
        .CellsSRC(11, 2, 1).FormulaU = "0"

        .AddRow visSectionFirstComponent + 1, 3, visTagLineTo
        .CellsSRC(11, 3, 0).FormulaU = "0"
        .CellsSRC(11, 3, 1).FormulaU = "0"

        'Adjust the geometry of the rows (the doubles given are percentages of the height/width of the original connector)
        'I recommend stepping through this to see how it moves the points:
        .CellsSRC(visSectionFirstComponent + 1, 2, 0).FormulaU = ".5"
        .CellsSRC(visSectionFirstComponent + 1, 3, 0).FormulaU = ".5"
        .CellsSRC(visSectionFirstComponent + 1, 3, 1).FormulaU = ".5"
        .CellsSRC(visSectionFirstComponent + 1, 4, 0).FormulaU = "1"
        .CellsSRC(visSectionFirstComponent + 1, 4, 1).FormulaU = "1"

    End With

End Sub

此自定义管线的端点仍然绑定到起点和终点形状。要完全终止所有自动路由,请使用
.layoutroutpassive
。(这可能会给你你想要的,但需要一些修补)。

你启发我尝试一下,因为我需要做类似的事情。 这是我找到的一种方法,可以让它发挥作用。此子例程引用接头形状,隐藏自动布线的线,添加新的几何图形截面,并手动调整该截面内的几个点(基于原始可见线的高度/宽度百分比)。显然,您可以通过编程方式调整数量/位置

Sub CustomRoutedConnector(shpConnectorShape As Shape)

    With shpConnectorShape
        'Hide the automatically routed connector line (still there, just hidden)
        .CellsSRC(visSectionFirstComponent, 0, 2).FormulaU = "TRUE"

        'Make a custom geometry section
        .AddSection visSectionFirstComponent + 1
        .AddRow visSectionFirstComponent + 1, visRowComponent, visTagComponent
        .AddRow visSectionFirstComponent + 1, visRowVertex, visTagLineTo
        .AddRow visSectionFirstComponent + 1, visRowVertex, visTagMoveTo

        'Set up the new geometry section rows (11,1 and 11,2 are the start and end rows)
        .CellsSRC(11, 0, 0).FormulaForceU = "TRUE"
        .CellsSRC(11, 0, 1).FormulaForceU = "FALSE"
        .CellsSRC(11, 0, 2).FormulaForceU = "FALSE"
        .CellsSRC(11, 0, 3).FormulaForceU = "FALSE"
        .CellsSRC(11, 0, 5).FormulaForceU = "FALSE"
        .CellsSRC(11, 1, 0).FormulaU = "0"
        .CellsSRC(11, 1, 1).FormulaU = "0"
        .CellsSRC(11, 2, 0).FormulaU = "0"
        .CellsSRC(11, 2, 1).FormulaU = "0"

        'Add two additional rows for demonstration (could be programatically 
        'adjusted to however many points you need)

        .AddRow visSectionFirstComponent + 1, 2, visTagLineTo
        .CellsSRC(11, 2, 0).FormulaU = "0"
        .CellsSRC(11, 2, 1).FormulaU = "0"

        .AddRow visSectionFirstComponent + 1, 3, visTagLineTo
        .CellsSRC(11, 3, 0).FormulaU = "0"
        .CellsSRC(11, 3, 1).FormulaU = "0"

        'Adjust the geometry of the rows (the doubles given are percentages of the height/width of the original connector)
        'I recommend stepping through this to see how it moves the points:
        .CellsSRC(visSectionFirstComponent + 1, 2, 0).FormulaU = ".5"
        .CellsSRC(visSectionFirstComponent + 1, 3, 0).FormulaU = ".5"
        .CellsSRC(visSectionFirstComponent + 1, 3, 1).FormulaU = ".5"
        .CellsSRC(visSectionFirstComponent + 1, 4, 0).FormulaU = "1"
        .CellsSRC(visSectionFirstComponent + 1, 4, 1).FormulaU = "1"

    End With

End Sub

此自定义管线的端点仍然绑定到起点和终点形状。要完全终止所有自动路由,请使用
.layoutroutpassive
。(这可能会为您提供所需的内容,但需要进行一些修补)。

由Visio application core管理的Dynamic connector,我们没有任何文档说明它是如何工作的!您可以“正确地(根据需要)”重新路由,但Visio core可以更改您的更改,并创建新路径!那么,您的意思是,在我更改了Dynamic connector之后,Visio application core是否有可能最终更改它?此外,是否有任何关于重新路由Dynamic connector的示例或文档?是的,Visio core可以更改连接器的路由!您可以阅读相同的内容,也可以通过编程重新布局页面,这将强制所有连接器位于一条清晰的路径上。它可以生成一些看起来像意大利面条的图表,但是可以通过巧妙地选择形状的顺序将其最小化。这就是你们要找的吗?谢谢你们。SmrtGrunt,你真的用一种新方法激励了我。但我仍然想知道如何路由一个动态连接器的路径,我的意思是,除了fromShape和toShape的点之外,为动态连接器定义一些点,然后它的路径将是一条线,按顺序路径所有这些点。还有代理,谢谢你的链接,我会照顾好我的工作完成后。很抱歉,我最近很忙。动态连接器由Visio application core管理,我们没有任何文档说明它是如何工作的!您可以“正确地(根据需要)”重新路由,但Visio core可以更改您的更改,并创建新路径!那么,您的意思是,在我更改了Dynamic connector之后,Visio application core是否有可能最终更改它?此外,是否有任何关于重新路由Dynamic connector的示例或文档?是的,Visio core可以更改连接器的路由!您可以阅读相同的内容,也可以通过编程重新布局页面,这将强制所有连接器位于一条清晰的路径上。它可以生成一些看起来像意大利面条的图表,但是可以通过巧妙地选择形状的顺序将其最小化。这就是你们要找的吗?谢谢你们。SmrtGrunt,你真的用一种新方法激励了我。但我仍然想知道如何路由一个动态连接器的路径,我的意思是,除了fromShape和toShape的点之外,为动态连接器定义一些点,然后它的路径将是一条线,按顺序路径所有这些点。还有代理,谢谢你的链接,我会照顾好我的工作完成后。抱歉耽搁了,我最近很忙。由于某些原因,这里的代码突出显示不是很好,但它应该可以复制/粘贴。谢谢你这么关心我的问题。你的回答很好。然而,这个任务是我可能性测试中的一个不确定点。现在,它显示出太多难以解决的困难。我存储了你的答案,如果同样的需求再次出现,我会仔细看看。@Stevenchhuh别担心。我希望它在将来对你或其他人有所帮助。由于某些原因,这里的代码突出显示不是很好,但它应该可以复制/粘贴。谢谢你这么关心我的问题。你的回答很好。然而,这个任务是我可能性测试中的一个不确定点。现在,它显示出太多难以解决的困难。我存储了你的答案,如果同样的需求再次出现,我会仔细看看。@Stevenchhuh别担心。我希望它能在将来帮助你或其他人。