首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >HowTo: Visio SDK页面从上到下重新布局FlowChart

HowTo: Visio SDK页面从上到下重新布局FlowChart
EN

Stack Overflow用户
提问于 2012-05-23 04:14:49
回答 2查看 2.4K关注 0票数 2

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

问题是我不知道如何通过代码执行这个命令。在UI (Visio2010)中,这些命令位于功能区中的以下位置:设计(选项卡) -> Layout (组) -> Re (SplitButton)。

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

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

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-05-23 13:09:03

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

在WBSTreeView.sln示例项目(VB.Net)中,我找到了如何实现这一点,但直到8小时后才能发布我的答案:-x

通过查看下面使用的枚举,可以使用其他布局类型。对于我们正在创建的大多数流来说,Compact -> DownRight最终变得更好了。

翻译成C#:

代码语言:javascript
复制
        // 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你可以给一个整数作为字符串来获取预定义的颜色,但是这不是很有帮助,因为没有一种简单的方法来弄清楚每种颜色是什么。(有一个Page.Colors集合,但您必须检查它们的每个RGB值并从中找出颜色。)

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

代码语言:javascript
复制
    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)";
    }
票数 2
EN

Stack Overflow用户

发布于 2012-05-23 10:59:41

Page对象上调用Layout方法。如果在此页面上选择了形状,则此方法将仅对当前所选内容起作用。您可能想先在ActiveWindow上调用DeselectAll

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10709485

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档