2012-09-19 79 views
1

我在我的C#应用​​程序中使用Microsoft Visio作为COM对象。我想在Visio页面上自动排列形状。我应该为这项任务编码?形状是数据库实体。通过C自动排列Visio形状

userView.Shapes.SomeMethod(); 

userView是COM对象的名称,但是SomeMethod应该是什么?

回答

0

This可能有助于

相关报价

奠定了一个网页,船长或组的形状的子集, 建立在其中铺设的形状出来的一个选择对象选中 ,然后调用Layout方法。如果在选择对象上执行布局方法 ,并且该对象没有选择任何形状,则页面,主体或选择组中的所有形状均排列在 之外。

编辑:noonand有关LayoutIncremental方法

刚把再看看对象模型,它似乎你想要的方法是LayoutIncremental方法

摘自2012年9月21日新增信息从relevant help topic说:

Page.LayoutIncremental(AlignOrSpace, AlignHorizontal, AlignVertical, SpaceHorizontal, SpaceVertical, UnitsNameOrCode) 
+0

这不起作用 –

0

我需要做类似前一阵子东西..

我用布局的微软Glee库。下载中包含非常好的示例,向您展示如何添加节点和关系并使其“自动排列”。但请注意,Glee不适用于商业用途。

然后我用于转换从吉利所计算的位置来Visio绘图这个例子。

基本上我要做的就是添加我的所有节点和关系太欢乐合唱团,然后让节点和它们的位置的列表,并使用第二个链接将他们添加到Visio。

这里是一个什么吉利可以做一个图形例如:

Glee image example

2

我知道这是一个“较老”的问题,但 我的工作非常类似的东西,并已成功地“自动布局'流程图:

public enum GraphStyles { TopDown, LeftRight }; 
public void ArrangeGraph(GraphStyles Style) 
{ 
    if (Style == GraphStyles.TopDown) 
    { 
     // set 'PlaceStyle' 
     var placeStyleCell = VisApp.ActivePage.PageSheet.get_CellsSRC(
      (short)VisSectionIndices.visSectionObject, 
      (short)VisRowIndices.visRowPageLayout, 
      (short)VisCellIndices.visPLOPlaceStyle).ResultIU = 1; 
     // set 'RouteStyle' 
     var routeStyleCell = VisApp.ActivePage.PageSheet.get_CellsSRC(
      (short)VisSectionIndices.visSectionObject, 
      (short)VisRowIndices.visRowPageLayout, 
      (short)VisCellIndices.visPLORouteStyle).ResultIU = 5; 
     // set 'PageShapeSplit' 
     var pageShapeSplitCell = VisApp.ActivePage.PageSheet.get_CellsSRC(
      (short)VisSectionIndices.visSectionObject, 
      (short)VisRowIndices.visRowPageLayout, 
      (short)VisCellIndices.visPLOSplit).ResultIU = 1; 
    } 
    else if (Style == GraphStyles.LeftRight) 
    { 
     // set 'PlaceStyle' 
     var placeStyleCell = VisApp.ActivePage.PageSheet.get_CellsSRC(
      (short)VisSectionIndices.visSectionObject, 
      (short)VisRowIndices.visRowPageLayout, 
      (short)VisCellIndices.visPLOPlaceStyle).ResultIU = 2; 
     // set 'RouteStyle' 
     var routeStyleCell = VisApp.ActivePage.PageSheet.get_CellsSRC(
      (short)VisSectionIndices.visSectionObject, 
      (short)VisRowIndices.visRowPageLayout, 
      (short)VisCellIndices.visPLORouteStyle).ResultIU = 6; 
     // set 'PageShapeSplit' 
     var pageShapeSplitCell = VisApp.ActivePage.PageSheet.get_CellsSRC(
      (short)VisSectionIndices.visSectionObject, 
      (short)VisRowIndices.visRowPageLayout, 
      (short)VisCellIndices.visPLOSplit).ResultIU = 1; 
    } 
    else { throw new NotImplementedException("GraphStyle " + Style.ToString() + " is not supported"); } 
    VisApp.ActivePage.Layout(); 
} 

希望这可以节省一些人一些时间。 我花了一段时间才弄明白。

我使用的是Visio 2010和visual studio 2010