当前位置: 首页>>代码示例>>C#>>正文


C# DocumentNode.ComputeColumns方法代码示例

本文整理汇总了C#中System.Windows.Documents.DocumentNode.ComputeColumns方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentNode.ComputeColumns方法的具体用法?C# DocumentNode.ComputeColumns怎么用?C# DocumentNode.ComputeColumns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Documents.DocumentNode的用法示例。


在下文中一共展示了DocumentNode.ComputeColumns方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PreCoalesceTable

        // <Summary>
        //      Table column handling.  RTF tables allow each row to be arbitrarily aligned.  XAML (like HTML)
        //      doesn't allow that.  You can achieve that effect in HTML by inserting extra rows with spurious
        //      cells propped to a specific width, but I'm not going to do that.  Instead, I'm going to split
        //      the rows into separate tables when combining some set of rows into a table would force me
        //      to fabricate a column that doesn't contain any defined cell.
        // </Summary>

        private int PreCoalesceTable(DocumentNode dn)
        {
            int nInserted = 0;
            int nAt = dn.Index;
            ColumnStateArray cols = dn.ComputeColumns();

            // OK, now I have a set of columns and information about which row caused the column to
            // be instantiated.  The naive algorithm is to strip the first N rows from the table until
            // the row that caused an uninstantiated column, break the table there, and then run the
            // algorithm again on the trailing table.
            int nUnfilledRowIndex = cols.GetMinUnfilledRowIndex();

            if (nUnfilledRowIndex > 0)
            {
                // OK, Need to insert a new table and table group around the remaining rows.
                DocumentNode dnNewTable = new DocumentNode(DocumentNodeType.dnTable);
                DocumentNode dnNewTableBody = new DocumentNode(DocumentNodeType.dnTableBody);
                dnNewTable.FormatState = new FormatState(dn.FormatState);
                dnNewTable.FormatState.RowFormat = EntryAt(nUnfilledRowIndex).FormatState.RowFormat;
                int nChildrenOldTable = nUnfilledRowIndex - dn.Index - 1;
                int nChildrenNewTable = dn.ChildCount - nChildrenOldTable;
                dn.ChildCount = nChildrenOldTable;  // Update old table child count
                EntryAt(nAt + 1).ChildCount = nChildrenOldTable - 1;    // Update old TableBody child count
                InsertNode(nUnfilledRowIndex, dnNewTableBody);
                CloseAtHelper(nUnfilledRowIndex, nChildrenNewTable);
                InsertNode(nUnfilledRowIndex, dnNewTable);
                CloseAtHelper(nUnfilledRowIndex, nChildrenNewTable + 1);

                // Adjust parent pointers
                dnNewTableBody.Parent = dnNewTable;
                dnNewTable.Parent = dn.ClosedParent;
                for (DocumentNode dnPa = dnNewTable.ClosedParent; dnPa != null; dnPa = dnPa.ClosedParent)
                {
                    dnPa.ChildCount = dnPa.ChildCount + 2;
                }

                // Adjust the loop end to account for the newly inserted elements
                nInserted = 2;

                // Need to recompute the ColumnStateArray for the newly truncated table.
                dn.ColumnStateArray = dn.ComputeColumns();
            }
            else
            {
                dn.ColumnStateArray = cols;
            }

            return nInserted;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:57,代码来源:RtfToXamlReader.cs


注:本文中的System.Windows.Documents.DocumentNode.ComputeColumns方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。