Visio二次开发(二)----Shape的添加和连接
2015-09-29 16:06
435 查看
先说一说为什么我要用到Visio的二次开发,现在做的项目设计到了一些电子地图,下面的这张图片是美工画的一张地铁里面门禁布局图,而这些图在做项目的时候是需要用Visio画的,有提前画好的直接加载到项目中就可以使用,但是有些是需要通过代码也就是二次开发来实现的!
下面说说具体的实现过程:
shape的添加
你只需要找到相应的模板,模板下的形状,就可以加载形状,没有什么困难的,如果你实在不知道,那么就学者去用用Visio宏,对你的学习很有帮助(Visio二次开发(一)—-巧用Visio宏 )
Shape的连接
从上面的途中可以看出,两个门Shape之间有的是通过线连接的,那么我们能够通过代码来实现连接的功能吗?当然,必须的可以:
然后再在定义形状的代码下边加上一句话
下面展示一下效果:
下面说说具体的实现过程:
shape的添加
你只需要找到相应的模板,模板下的形状,就可以加载形状,没有什么困难的,如果你实在不知道,那么就学者去用用Visio宏,对你的学习很有帮助(Visio二次开发(一)—-巧用Visio宏 )
'''新建一个documents集合''' Visio.Documents visDocs = adcVisio.Document.Application.Documents; '''加载模板并将其加载到一个停靠的窗口中''' Visio.Document visStencil = visDocs.OpenEx("BASIC_M.VSS", (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenDocked); '''加载一个当前活动的Page绘图区域''' Visio.Page visPage = adcVisio.Document.Application.ActivePage; '''加载三角形''' Visio.Master visioRectMaster = visStencil.Masters.get_ItemU(@"Triangle"); Visio.Shape visioRectShape = visPage.Drop(visioRectMaster, 3.25, 4.5); '''加载圆形''' Visio.Master visioRect1Master = visStencil.Masters.get_ItemU(@"Square"); Visio.Shape visioRect1Shape = visPage.Drop(visioRect1Master, 1.25, 2.5); '''加载动态链接线''' Visio.Master visioWallMaster = visStencil.Masters.get_ItemU(@"Line-curve connector"); Visio.Shape visioWallShape = visPage.Drop(visioWallMaster, 5.5, 6.5);
Shape的连接
从上面的途中可以看出,两个门Shape之间有的是通过线连接的,那么我们能够通过代码来实现连接的功能吗?当然,必须的可以:
''' <summary>''' ''' 将两个形状进行连接''' ''' </summary>''' '''<param name="shape1"></param>''' ''' <param name="shape2"></param>''' ''' <param name="connector"></param>''' private static void ConnectShapes(Visio.Shape shape1, Visio.Shape shape2, Visio.Shape connector) { ''' get the cell from the source side of the connector ''' Cell beginXCell = connector.get_CellsSRC( (short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowXForm1D, (short)Visio.VisCellIndices.vis1DBeginX); '''glue the source side of the connector to the first shape ''' beginXCell.GlueTo(shape1.get_CellsSRC( (short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowXFormOut, (short)Visio.VisCellIndices.visXFormPinX)); ''' get the cell from the destination side of the connector''' Cell endXCell = connector.get_CellsSRC( (short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowXForm1D, (short)Visio.VisCellIndices.vis1DEndX); ''' glue the destination side of the connector to the second shape ''' endXCell.GlueTo(shape2.get_CellsSRC( (short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowXFormOut, (short)Visio.VisCellIndices.visXFormPinX)); }
然后再在定义形状的代码下边加上一句话
'''将两个图形用动态链接线链接起来''' ConnectShapes(visioRectShape, visioRect1Shape, visioWallShape);
下面展示一下效果:
相关文章推荐
- 三大UML建模工具Visio、Rational Rose、PowerDesign的区别比较
- destoon二次开发入门示例
- Visio技巧总结
- visio画UML用例图没有include关系的解决方法
- 七电子商务模式帮助您了解电子商业更好
- 教你轻松明白音视频同步技术
- 即时通讯SDK(转)
- 音视频P2P交流技术(转)
- 音视频即时通讯解决方案
- 即时通讯系统开发
- 什么是二次开发?
- 二次开发学习感受
- PHPCMS 使用图示
- 音视频技术--H.264代码与标准如何对应
- ecshop 数据库表结构 全
- visio 图转换为 EPS
- [转载]Office System 2003/Visio 2003/Project Server 2003 MUI 的SP1更新
- 使用Microsoft Office Visio 2007 绘图
- Rational Rose、PowerDesign、visio的比较
- WPS2013版(V9版)二次开发所遇问题及解决方法小结