本文整理汇总了C#中ICSharpCode.TreeView.SharpTreeNode.ReplaceWith方法的典型用法代码示例。如果您正苦于以下问题:C# SharpTreeNode.ReplaceWith方法的具体用法?C# SharpTreeNode.ReplaceWith怎么用?C# SharpTreeNode.ReplaceWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.TreeView.SharpTreeNode
的用法示例。
在下文中一共展示了SharpTreeNode.ReplaceWith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteNode
static void DeleteNode(SharpTreeNode node)
{
SharpTreeNode balancingNode;
if (node.left == null) {
balancingNode = node.listParent;
node.ReplaceWith(node.right);
node.right = null;
} else if (node.right == null) {
balancingNode = node.listParent;
node.ReplaceWith(node.left);
node.left = null;
} else {
SharpTreeNode tmp = node.right;
while (tmp.left != null)
tmp = tmp.left;
// First replace tmp with tmp.right
balancingNode = tmp.listParent;
tmp.ReplaceWith(tmp.right);
tmp.right = null;
Debug.Assert(tmp.left == null);
Debug.Assert(tmp.listParent == null);
// Now move node's children to tmp:
tmp.left = node.left; node.left = null;
tmp.right = node.right; node.right = null;
if (tmp.left != null) tmp.left.listParent = tmp;
if (tmp.right != null) tmp.right.listParent = tmp;
// Then replace node with tmp
node.ReplaceWith(tmp);
if (balancingNode == node)
balancingNode = tmp;
}
Debug.Assert(node.listParent == null);
Debug.Assert(node.left == null);
Debug.Assert(node.right == null);
node.height = 1;
node.totalListLength = -1;
if (balancingNode != null)
RebalanceUntilRoot(balancingNode);
}