public TreeNode AddItem(TreeNode parent, Entry entry, Item item, string color) { var node = new TreeNode(); node.Tag = entry; node.Name = entry.Name; string text = string.Empty; if (item != null) { text = item.Name; string imageKeyBase = entry is DirEntry ? "Folder" : "Diamond"; node.ImageKey = imageKeyBase + color + ".png"; if (entry is FileEntry && color != null) { node.ForeColor = Color.FromName(color); } } else { node.ImageKey = "Blank.png"; } node.Text = text; node.SelectedImageKey = node.ImageKey; TreeNodeCollection collection = parent != null ? parent.Nodes : treeView.Nodes; collection.Add(node); return node; }
private void LoadModel(Entry entry, Func<Entry, Item> itemSelector, Node parentNode) { foreach (var childEntry in entry.ChildEntries) { var item = itemSelector(childEntry); string text = string.Empty; if (item != null) { text = item.Name; } var node = new Node(text); LoadModel(childEntry, itemSelector, node); parentNode.Nodes.Add(node); } }
private void LoadEntries(Entry entry, TreeNode leftParentNode, TreeNode rightParentNode) { foreach (var childEntry in entry.ChildEntries) { string color = null; var dirEntry = childEntry as DirEntry; if (dirEntry != null) { if (dirEntry.Left != null) { color = GetFolderColor(dirEntry, CompareStatus.LeftOrphant, CompareStatus.LeftNewer, CompareStatus.RightNewer); } var leftNode = sideLeft.AddItem(leftParentNode, dirEntry, dirEntry.Left, color); if (dirEntry.Right != null) { color = GetFolderColor(dirEntry, CompareStatus.RightOrphant, CompareStatus.RightNewer, CompareStatus.LeftNewer); } var rightNode = sideRight.AddItem(rightParentNode, dirEntry, dirEntry.Right, color); LoadEntries(dirEntry, leftNode, rightNode); } else { var fileEntry = (FileEntry)childEntry; if (fileEntry.Left != null) { color = GetFileColor(fileEntry, CompareStatus.LeftOrphant, CompareStatus.LeftNewer, CompareStatus.RightNewer); } var leftNode = sideLeft.AddItem(leftParentNode, fileEntry, fileEntry.Left, color); if (fileEntry.Right != null) { color = GetFileColor(fileEntry, CompareStatus.RightOrphant, CompareStatus.RightNewer, CompareStatus.LeftNewer); } var rightNode = sideRight.AddItem(rightParentNode, fileEntry, fileEntry.Right, color); } } }
private void OnSelectedNode(string nodePath, Entry entry) { if (SelectedNode != null) { var e = new EntryEventArgs { NodePath = nodePath, Entry = entry }; SelectedNode(this, e); } }
private void OnExpandingNode(string nodePath, Entry entry) { if (ExpandingNode != null) { var e = new EntryEventArgs { NodePath = nodePath, Entry = entry }; ExpandingNode(this, e); } }
private void OnCollapsingNode(string nodePath, Entry entry) { if (CollapsingNode != null) { var e = new EntryEventArgs { NodePath = nodePath, Entry = entry }; CollapsingNode(this, e); } }
internal void LoadData(Entry entry, Func<Entry, Item> itemSelector) { treeModel = new TreeModel(); treeView.Model = treeModel; LoadModel(entry, itemSelector, treeModel.Root); }