Visio静态连接器 - 您如何放置它们?(Visio Static Connectors - How do you place them?)

我有两种形状,带有连接点。 我正在使用我自己的两个形状的主人,所以我知道连接点的名称。

我想制作一个箭头,将一个连接点(从)连接到第二个形状中的另一个连接点。 看起来像是一件基本的事情,但我只能找到动态连接器的文档或示例代码,它们不允许您选择连接点。 我下载并搜索了Visio代码示例库,但我找不到任何相关内容。

简而言之,我想要一个像这样的函数:

//drop a connector onto the page, then connect them public void dropStaticConnector(Shape sFrom, String connectionPointName1, Shape sTo, String connectionPointName2) { }

有人可以提供示例代码吗?

I have two shapes, with connection points. I am using my own master for the two shapes, so I know the names of the connection points.

I'd like to make an arrow that connects one connection point (from) to another connection point in the second shape. Seems like a basic thing to do, but I can only find documentation or sample code for dynamic connectors, which don't let you choose the connection points. I downloaded and searched the Visio Code Samples Library, and I can't find anything on this.

In short, I'd like a function that does something like this:

//drop a connector onto the page, then connect them public void dropStaticConnector(Shape sFrom, String connectionPointName1, Shape sTo, String connectionPointName2) { }

Can someone give sample code?

最满意答案

您可以尝试以下内容:

//drop a connector onto the page, then connect them
public void dropStaticConnector(
    Shape sFrom, String connectionPointName1, 
    Shape sTo, String connectionPointName2)
{
    // drop a default connector
    var conn = ActivePage.Drop(Application.ConnectorToolDataObject, 0, 0);

    // glue it to the connection points
    conn.Cells("BeginX").GlueTo(sFrom.Cells("Connections." + connectionPointName1));
    conn.Cells("EndX").GlueTo(sTo.Cells("Connections." + connectionPointName2));
}
 

意思是,你需要走“老式”的道路。 新的是Shape.AutoConnect,但是不能保证形状会粘在你选择的连接点上。

以下是DVS(开发Viso解决方案)一书中的相关文章 - 它仍然适用: http : //msdn.microsoft.com/en-us/library/office/aa201778.aspx

You could try something like the following:

//drop a connector onto the page, then connect them
public void dropStaticConnector(
    Shape sFrom, String connectionPointName1, 
    Shape sTo, String connectionPointName2)
{
    // drop a default connector
    var conn = ActivePage.Drop(Application.ConnectorToolDataObject, 0, 0);

    // glue it to the connection points
    conn.Cells("BeginX").GlueTo(sFrom.Cells("Connections." + connectionPointName1));
    conn.Cells("EndX").GlueTo(sTo.Cells("Connections." + connectionPointName2));
}
 

Means, you need to go the "old-fashioned" way. The new one is Shape.AutoConnect, but afaik it will not guarantee that the shapes will be glued to the connection point of your choice.

Here is the related article from DVS (Developing Viso Solutions) book - it still applies: http://msdn.microsoft.com/en-us/library/office/aa201778.aspx

Visio静态连接器 - 您如何放置它们?(Visio Static Connectors - How do you place them?)

我有两种形状,带有连接点。 我正在使用我自己的两个形状的主人,所以我知道连接点的名称。

我想制作一个箭头,将一个连接点(从)连接到第二个形状中的另一个连接点。 看起来像是一件基本的事情,但我只能找到动态连接器的文档或示例代码,它们不允许您选择连接点。 我下载并搜索了Visio代码示例库,但我找不到任何相关内容。

简而言之,我想要一个像这样的函数:

//drop a connector onto the page, then connect them public void dropStaticConnector(Shape sFrom, String connectionPointName1, Shape sTo, String connectionPointName2) { }

有人可以提供示例代码吗?

I have two shapes, with connection points. I am using my own master for the two shapes, so I know the names of the connection points.

I'd like to make an arrow that connects one connection point (from) to another connection point in the second shape. Seems like a basic thing to do, but I can only find documentation or sample code for dynamic connectors, which don't let you choose the connection points. I downloaded and searched the Visio Code Samples Library, and I can't find anything on this.

In short, I'd like a function that does something like this:

//drop a connector onto the page, then connect them public void dropStaticConnector(Shape sFrom, String connectionPointName1, Shape sTo, String connectionPointName2) { }

Can someone give sample code?

最满意答案

您可以尝试以下内容:

//drop a connector onto the page, then connect them
public void dropStaticConnector(
    Shape sFrom, String connectionPointName1, 
    Shape sTo, String connectionPointName2)
{
    // drop a default connector
    var conn = ActivePage.Drop(Application.ConnectorToolDataObject, 0, 0);

    // glue it to the connection points
    conn.Cells("BeginX").GlueTo(sFrom.Cells("Connections." + connectionPointName1));
    conn.Cells("EndX").GlueTo(sTo.Cells("Connections." + connectionPointName2));
}
 

意思是,你需要走“老式”的道路。 新的是Shape.AutoConnect,但是不能保证形状会粘在你选择的连接点上。

以下是DVS(开发Viso解决方案)一书中的相关文章 - 它仍然适用: http : //msdn.microsoft.com/en-us/library/office/aa201778.aspx

You could try something like the following:

//drop a connector onto the page, then connect them
public void dropStaticConnector(
    Shape sFrom, String connectionPointName1, 
    Shape sTo, String connectionPointName2)
{
    // drop a default connector
    var conn = ActivePage.Drop(Application.ConnectorToolDataObject, 0, 0);

    // glue it to the connection points
    conn.Cells("BeginX").GlueTo(sFrom.Cells("Connections." + connectionPointName1));
    conn.Cells("EndX").GlueTo(sTo.Cells("Connections." + connectionPointName2));
}
 

Means, you need to go the "old-fashioned" way. The new one is Shape.AutoConnect, but afaik it will not guarantee that the shapes will be glued to the connection point of your choice.

Here is the related article from DVS (Developing Viso Solutions) book - it still applies: http://msdn.microsoft.com/en-us/library/office/aa201778.aspx