【问题标题】:HowTo: Visio SDK page Re-Layout FlowChart Top to Bottom操作方法:Visio SDK 页面从上到下重新布局流程图
【发布时间】:2012-05-22 20:14:49
【问题描述】:

我正在从代表流程图的分层数据集创建动态 VSD。我不想/不需要弄乱这些元素的绝对定位——自动布局选项就可以了。

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

这些都可以。通过几天的 Visio SDK 文档和谷歌搜索,发现没有什么用处。

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

【问题讨论】:

    标签: layout sdk visio flowchart autolayout


    【解决方案1】:

    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)";
        }
    

    【讨论】:

      【解决方案2】:

      Page 对象上调用Layout 方法。如果在此页面上选择了形状,则此方法将仅对当前选择进行操作。您可能想先拨打ActiveWindow 上的DeselectAll

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-02-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-09-21
        相关资源
        最近更新 更多