Little Registry Cleaner/Common Tools/TreeViewAdv/Tree/TreeModel.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;
namespace Common_Tools.TreeViewAdv.Tree
{
/// <summary>
/// Provides a simple ready to use implementation of <see cref="ITreeModel"/>. Warning: this class is not optimized
/// to work with big amount of data. In this case create you own implementation of <c>ITreeModel</c>, and pay attention
/// on GetChildren and IsLeaf methods.
/// </summary>
public class TreeModel : ITreeModel
{
private Node _root;
public Node Root
{
get { return _root; }
}
public Collection<Node> Nodes
{
get { return _root.Nodes; }
}
public TreeModel()
{
_root = new Node();
_root.Model = this;
}
public TreePath GetPath(Node node)
{
if (node == _root)
return TreePath.Empty;
else
{
Stack<object> stack = new Stack<object>();
while (node != _root)
{
stack.Push(node);
node = node.Parent;
}
return new TreePath(stack.ToArray());
}
}
public Node FindNode(TreePath path)
{
if (path.IsEmpty())
return _root;
else
return FindNode(_root, path, 0);
}
private Node FindNode(Node root, TreePath path, int level)
{
foreach (Node node in root.Nodes)
if (node == path.FullPath[level])
{
后面还有 67 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。