2012-05-22 55 views
1

我从代表流程图的分层数据集创建动态VSD。我不希望/不需要对这些元素的绝对定位进行干预 - 自动布局选项将工作得很好。操作指南:Visio SDK页面重新布局FlowChart顶部到底部

问题是我无法弄清楚如何通过代码执行此命令。在UI(Visio 2010)中,这些命令位于功能区中:设计(选项卡) - >布局(组) - >重新布局(SplitButton)。

任何这些都可以。仔细查看Visio SDK文档和谷歌搜索几天没有什么用处。

任何想法? (使用C#,但VB/VBA会这样做)

回答

3

Page.Layout()方法本身是不够的。

在WBSTreeView.sln样本项目(VB.Net)我发现如何做到这一点,但无法发布我的答案,直到8小时后:-x

其他的布局类型是可能通过寻找下面使用的枚举。 紧凑型 - > DownRight最终对我们创建的大多数流程都更好。

翻译成C#:

 // auto-layout, Compact Tree -> Down then Right 
     var layoutCell = this._page.PageSheet.get_CellsSRC(
      (short)VisSectionIndices.visSectionObject, 
      (short)VisRowIndices.visRowPageLayout, 
      (short)VisCellIndices.visPLOPlaceStyle); 
     layoutCell.set_Result(
      VisUnitCodes.visPageUnits, 
      (short)VisCellVals.visPLOPlaceCompactDownRight); 
     layoutCell = this._page.PageSheet.get_CellsSRC(
      (short)VisSectionIndices.visSectionObject, 
      (short)VisRowIndices.visRowPageLayout, 
      (short)VisCellIndices.visPLORouteStyle); 
     layoutCell.set_Result(
      VisUnitCodes.visPageUnits, 
      (short)VisCellVals.visLORouteFlowchartNS); 

     //// to change page orientation 
     //layoutCell = this._page.PageSheet.get_CellsSRC(
     // (short)VisSectionIndices.visSectionObject, 
     // (short)VisRowIndices.visRowPrintProperties, 
     // (short)VisCellIndices.visPrintPropertiesPageOrientation); 
     //layoutCell.set_Result(
     // VisUnitCodes.visPageUnits, 
     // (short)VisCellVals.visPPOLandscape); 

     // curved connector lines 
     layoutCell = this._page.PageSheet.get_CellsSRC(
      (short)VisSectionIndices.visSectionObject, 
      (short)VisRowIndices.visRowPageLayout, 
      (short)VisCellIndices.visPLOLineRouteExt); 
     layoutCell.set_Result(
      VisUnitCodes.visPageUnits, 
      (short)VisCellVals.visLORouteExtNURBS); 


     // perform the layout 
     this._page.Layout(); 
     // optionally resize the page to fit the space taken by its shapes 
     this._page.ResizeToFitContents(); 
     // 

更改连接线的颜色

如果你不熟悉的颜色的公式是如何工作的,这也可能是非常令人沮丧。 By default你可以给一个int作为一个字符串来获得预定义的颜色,但这不是很有帮助,因为没有一种简单的方法来找出每种颜色是什么。 (有一个Page.Colors集合,但您必须检查每个RGB值并根据它们计算颜色。)

相反,您可以使用自己的RGB值作为公式。

private void SetConnectorLineColor(Shape connector, string colorFormula) 
    { 
     var cell = connector.get_Cells("LineColor"); 
     cell.Formula = colorFormula; 
    } 

    internal static class AnswerColorFormula 
    { 
     public static string Green = "RGB(0,200,0)"; 
     public static string Orange = "RGB(255,100,0)"; 
     public static string Yellow = "RGB(255,200,0)"; 
     public static string Red = "RGB(255,5,5)"; 
    } 
1

Page对象上调用Layout方法。如果在此页面上选择了形状,则此方法仅对当前选择进行操作。您可以先致电ActiveWindow,致电DeselectAll