本文整理汇总了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;
}