在Visio形连接器 [英] Shape connectors in Visio

查看:868
本文介绍了在Visio形连接器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写于2010年Studio中加载项的Visio 2010年C#。我需要阅读目前在Visio打开了一个图。我知道如何阅读该图的形状。



现在的问题是




  1. 如果我有一个形状对象,它的属性可以给我协调的页面和其他形状(如果有的话)的形状,目前一个是与

  2. 连接,如果我有一个连接器对象,它的属性可以给我塑造它连接的连接和方向。


解决方案

在Visio连接是通过连接对象处理。每个形状具有传入连接的对象和传出连接的对象的集合。他们的名字分别为FromConnects并连接。



每个连接对象有一个FromSheet和ToSheet属性,它仅会指向形状对象时,FromSheet形状是连接形状到ToSheet形状。



所以,如果你有一个方形(shape1)连接到另一个方形(shape2)用连接器线(连接器),你实际已经是这样的:
连接器连接到shape1
连接器连接到shape2



于是就shape1,你看FromConnects和去看One连接项目与FromSheet引用接口,ToSheet指shape1。
式样2将是相同的。
。如果你看看上的连接器形状连接时,你会看到相同的连接项目,以引用的同一对象。



所以,搞清楚是否shape1所连接到shape2反之亦然是观察连接器上的顺序问题...连接对象1将是从形,并连接对象2将是要的形状。



下面是两个VBA例程,让您传递的形状传入和传出胶水,并返回一个集合对象。我知道你说你正在使用C#,但我的Visio做VBA。该代码只是说明原始连接信息。我建议你​​尝试在VBA中踱步,看到这一切是如何工作的,因为它仍然混淆了我。

 公共功能GetShapesThatConnectTo (TheShp作为Visio.Shape)为集合
昏暗的结果作为集合
组结果=新集合
。对于i = 1到TheShp.FromConnects.Count
Result.Add TheShp.FromConnects .Item(我).FromSheet
下一I
将GetShapesThatConnectTo =结果
端功能

公共功能GetWhatShapeConnectsTo(TheShp作为Visio.Shape)为集合
尺寸的结果集合
组结果=新集合
。对于i = 1到TheShp.Connects.Count
Result.Add TheShp.Connects.Item(I).ToSheet
下一页I
将GetWhatShapeConnectsTo =结果
端功能


I'm writing an Add-In to Visio 2010 in Studio 2010 on C#. I need to read a diagram currently opened in Visio. I know how to read shapes of the diagram.

The question is

  1. if I have a shape object, which properties can give me coordinates of the shape on the page and other shapes (if any), the current one is connected with,
  2. if I have a connector object, which properties can give me shapes it connects and direction of the connection.

解决方案

Connections in Visio are handled through Connect objects. Each shape has a collection of incoming connect objects and outgoing connect objects. Their names are FromConnects and Connects, respectively.

Each connect object has a FromSheet and ToSheet property, which are just pointers to Shape objects, the FromSheet shape being the shape that connects to the ToSheet shape.

So, if you have a square shape (shape1) connected to another square shape (shape2) with a connector line (connector), what you actually have is this: connector is connected to shape1 connector is connected to shape2

So on shape1, you'd look at FromConnects and see one Connects item, with FromSheet referencing connector, and ToSheet referring to shape1. Shape 2 would be the same. If you look at Connects on the connector shape, you'd see the same Connects item, with the same objects referenced.

So figuring out whether shape1 connects to shape2 or vice versa is a matter of looking at the order on connector...Connects object 1 would be the "From" shape and Connects object 2 would be the "To" shape.

Here are two VBA routines that get Incoming and Outgoing glues on a shape you pass in, and return a collection object. I know you said you're using C#, but I do VBA for Visio. The code just illustrates raw connection information. I'd suggest you try stepping around in VBA and see how this all works, because it still confuses me.

Public Function GetShapesThatConnectTo(TheShp As Visio.Shape) As Collection
    Dim Result As Collection
    Set Result = New Collection
    For i = 1 To TheShp.FromConnects.Count
        Result.Add TheShp.FromConnects.Item(i).FromSheet
    Next i
    Set GetShapesThatConnectTo = Result
End Function

Public Function GetWhatShapeConnectsTo(TheShp As Visio.Shape) As Collection
    Dim Result As Collection
    Set Result = New Collection
    For i = 1 To TheShp.Connects.Count
        Result.Add TheShp.Connects.Item(i).ToSheet
    Next i
    Set GetWhatShapeConnectsTo = Result
End Function

这篇关于在Visio形连接器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆