void InsertIntoTree(GrhTreeView treeView) { Remove(); var folder = GrhTreeViewFolderNode.Create(treeView, GrhData.Categorization.Category.ToString()); folder.Nodes.Add(this); }
void Update(GrhTreeView treeView) { // Check that the GrhData still exists var gd = GrhInfo.GetData(GrhData.GrhIndex); if (gd != _grhData) { RemoveRecursive(); return; } // Update everything var v = GrhData.GrhIndex.ToString(); if (!StringComparer.Ordinal.Equals(v, Name)) { Name = v; } v = GrhData.Categorization.Title.ToString(); if (!StringComparer.Ordinal.Equals(v, Text)) { Text = v; } v = GetToolTipText(); if (!StringComparer.Ordinal.Equals(v, ToolTipText)) { ToolTipText = v; } InsertIntoTree(treeView); }
/// <summary> /// Initializes a new instance of the <see cref="GrhTreeViewNode"/> class. /// </summary> /// <param name="treeView">The <see cref="GrhTreeView"/> this node belongs to.</param> /// <param name="grhData">The <see cref="GrhData"/> this node contains.</param> GrhTreeViewNode(GrhTreeView treeView, GrhData grhData) { _grhData = grhData; Update(treeView); // If this is a root node, load the image immediately since our lazy-loading of images only triggers when // nodes expand, but the root nodes are never shown by expanding if (Parent == null) { EnsureImageIsSet(); } }
/// <summary> /// Creates a new <see cref="GrhTreeViewNode"/>. /// </summary> /// <param name="grhTreeView">The <see cref="GrhTreeView"/> that will contain the node.</param> /// <param name="grhData">The <see cref="GrhData"/> that the node will contain.</param> /// <returns>The new <see cref="GrhTreeViewNode"/>.</returns> public static GrhTreeViewNode Create(GrhTreeView grhTreeView, GrhData grhData) { var existingNode = grhTreeView.FindGrhDataNode(grhData); if (existingNode != null) { existingNode.Update(); return(existingNode); } return(new GrhTreeViewNode(grhTreeView, grhData)); }