layout - 如何: Visio SDK page Re-Layout FlowChart Top to Bottom

标签 layout sdk visio flowchart autolayout

我正在根据表示流程图的分层数据集创建动态 VSD。我不想/不需要搞乱这些元素的绝对定位 - 自动布局选项将工作得很好。

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

其中任何一个都可以。浏览了 Visio SDK 文档并用谷歌搜索了几天,没有发现任何有用的东西。

有什么想法吗? (使用 C#,但 VB/VBA 也可以)

最佳答案

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

在 WBSTreeView.sln 示例项目 (VB.Net) 中,我找到了如何完成此操作,但直到 8 小时后才能发布我的答案:-x

通过查看下面使用的枚举可以实现其他布局类型。 对于我们正在创建的大多数流程来说,Compact -> 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)";
    }

关于layout - 如何: Visio SDK page Re-Layout FlowChart Top to Bottom,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10709485/

相关文章:

java - 来自 xml 文件的 vsdx (visio) 类图生成器,Java

uml - 如何在 Visio 2007 中使用替代组合片段?

android - 图像在另一台设备上模糊

layout - 创建键盘的程序 "CheatSheet"

java - 使用SDk清除azure门户中定义的容器的现有策略后如何上传新创建的sharedAccessPolicy?

ios - Facebook SDK iOS 错误

java - Java EE SDK 的问题

64-bit - 64 位 visio 上不支持无窗口 ActiveX 控件异常(exception)

java - 将 TextView 动态添加到相对布局。

Android 仪表板模式