public TreeNode CloneShallow() { var treeNode = new TreeNodeWithConnectionInfo(this.Text, this.Provider); TreeNodeUtils.CopyContent(this, treeNode); return(treeNode); }
// since we have data in _treeData, but are displaying _tree, // we need to copy data from treedata to trees (according to applied filter) private void UpdateDrawnNodes() { _treeData.SelectedNode = _treeBindings.FindDataNode(_tree.SelectedNode); _treeIsUnderUpdate = true; _tree.BeginUpdate(); try { var filters = new NodeFilter(_treeData, _filter); _treeBindings = TreeNodeUtils.CopyTree(_treeData, _tree, filters.FilterAction, filters.UpdateAction); _tree.SetHorizontalScroll(0); UpdateDrawnNodesSelection(); } finally { _tree.EndUpdate(); _treeIsUnderUpdate = false; } }
// since we have data in _treeData, but are displaying _tree, // we need to copy data from treedata to trees (according to applied filter) private void UpdateDrawnNodes() { _treeData.SelectedNode = _treeBindings.FindDataNode(_tree.SelectedNode); _treeIsUnderUpdate = true; _tree.BeginUpdate(); _tree.Nodes.Clear(); try { // quick path if (_filter == null) { _treeBindings = TreeNodeUtils.CopyTree(_treeData, _tree, null, null); } else { var visibility = new TreeNodeUtils.NodeVisibility(); TreeNodeUtils.IterateNodes(_treeData, node => { if (PassesFilter(node)) { visibility.SetVisible(node); } }); _treeBindings = TreeNodeUtils.CopyTree(_treeData, _tree, node => visibility.GetVisibility(node) != TreeNodeUtils.NodeVisibility.VisibilityStatus.NotVisible, (data, display) => { var nodeVisibility = visibility.GetVisibility(data); if (nodeVisibility == TreeNodeUtils.NodeVisibility.VisibilityStatus.ChildVisible) { // this one is not directly visible, gray it out display.ForeColor = Color.LightBlue; } if (nodeVisibility == TreeNodeUtils.NodeVisibility.VisibilityStatus.ParentVisible) { // this one is not directly visible, gray it out display.ForeColor = Color.DarkGray; } // this one is visible directly, ensure it is visible (parents are expanded). // it's children are visible as well, but may be not expanded if (nodeVisibility == TreeNodeUtils.NodeVisibility.VisibilityStatus.Visible) { display.EnsureVisible(); } }); _tree.SetHorizontalScroll(0); } UpdateDrawnNodesSelection(); } finally { _tree.EndUpdate(); _treeIsUnderUpdate = false; } }