public override void ConfigureContainerNode(MultiSyncTreeNode node, string path) { ConfigureStandardNode(node); string text = GetContainerNodeNameFromPath(path); if (node.Text != text) { node.Text = text; } // TODO: Add font configuration. // TODO: Extend BetterTreeNode to support font style changes inside // a single text string. (ex: <i>This is <b>bold</b></i>) // Add the NodeInformation to this node. if (node.NodeInformation == null) { node.NodeInformation = new NodeInformation(NodeType.Container); } node.NodeInformation.PathItems.Add(new PathItem(this, path)); if (!nodes.Contains(node)) { nodes.Add(node); } // TODO: Implement dependency paths from object view paths. // Ex: objects[Bipeds]:\cyborg_mp.biped\dependencies:\characters\cyborg\cyborg.model_animations node.CollapsedImageIndex = ParentTreeView.Bitmaps.IndexOf(NodeDefinitions["container"].CollapsedIcon); node.ExpandedImageIndex = ParentTreeView.Bitmaps.IndexOf(NodeDefinitions["container"].ExpandedIcon); node.ImageIndex = node.CollapsedImageIndex; node.SelectedImageIndex = node.CollapsedImageIndex; }
public override void ConfigureObjectNode(MultiSyncTreeNode node, string path) { ConfigureStandardNode(node); string text = GetObjectNodeNameFromPath(path); if (node.Text != text) { node.Text = text; } // Add the NodeInformation to this node. if (node.NodeInformation == null) { node.NodeInformation = new NodeInformation(NodeType.Object); } node.NodeInformation.PathItems.Add(new PathItem(this, path)); if (!nodes.Contains(node)) { nodes.Add(node); } node.CollapsedImageIndex = ParentTreeView.Bitmaps.IndexOf(NodeDefinitions["object"].CollapsedIcon); node.ExpandedImageIndex = node.CollapsedImageIndex; node.ImageIndex = node.CollapsedImageIndex; node.SelectedImageIndex = node.CollapsedImageIndex; }
/// <summary> /// Creates the direct children of the specified node. /// Children are constrained to those that exist in the specified PathItem. /// </summary> protected virtual void CreateChildren(MultiSyncTreeNode parentNode, PathItem pathItem) { string path = pathItem.Path; // Load folders first so they will be at the top. string[] folders = pathItem.NodeHelper.Library.GetFolderList(path); if (folders != null) { Array.Sort(folders); foreach (string folder in folders) { // If a node with this name and type does not already exist, create it. string nodeName = pathItem.NodeHelper.GetContainerNodeNameFromPath(folder); MultiSyncTreeNode newNode = GetOrCreateNode(parentNode, nodeName); if (!parentNode.Nodes.Contains(newNode)) { parentNode.Nodes.Add(newNode); } if (newNode.Nodes.Count == 0) { newNode.Nodes.Add(new TreeNode("dummy")); } pathItem.NodeHelper.ConfigureContainerNode(newNode, folder); } } if (this.showFiles) { string[] files = pathItem.NodeHelper.Library.GetFileList(path); if (files != null) { Array.Sort(files); foreach (string file in files) { // If a node with this name does not already exist, create it. string nodeName = pathItem.NodeHelper.GetObjectNodeNameFromPath(file); MultiSyncTreeNode newNode = GetOrCreateNode(parentNode, nodeName); if (!parentNode.Nodes.Contains(newNode)) { parentNode.Nodes.Add(newNode); } pathItem.NodeHelper.ConfigureObjectNode(newNode, file); } } } parentNode.NodeInformation.ChildrenCreated = true; }
private void tagTree_AfterSelect(object sender, TreeViewEventArgs e) { MultiSyncTreeNode node = e.Node as MultiSyncTreeNode; ArrayList menus = new ArrayList(); foreach (PathItem item in node.NodeInformation.PathItems) { if (node.NodeInformation.NodeType == NodeType.Container) { if (item.NodeHelper.NodeDefinitions["container"].PopupMenu != null) { menus.Add(item.NodeHelper.NodeDefinitions["container"].PopupMenu); } } else { if (item.NodeHelper.NodeDefinitions["object"].PopupMenu != null) { menus.Add(item.NodeHelper.NodeDefinitions["object"].PopupMenu); } } } CreatePopupMenu(menus.ToArray(typeof(PopupMenu)) as PopupMenu[]); // Raise the FolderSelected event so that any sub controls that need to // display files (listview for example) can do so. // TODO: Figure out the best way to go about doing this, since a single node can // contain multiple lists of children. // FileEntryInformation entryInfo = (e.Node.Tag as FileEntryInformation) ; // if (entryInfo != null) // { // if (entryInfo.FileType == FileEntryType.Folder) // { // string[] files = tagLibrary.GetFileList(entryInfo.FullPath); // if (ContainerSelected != null) // { // ContainerSelected(new FolderSelectedEventArgs(files, entryInfo.FullPath)); // } // } // // if (NodeSelected != null) // { // if (!IgnoreNodeSelectionEvents) // NodeSelected(sender, e); // } // } }
/// <summary> /// Performs the standard node configuration. /// </summary> /// <param name="node"></param> protected virtual void ConfigureStandardNode(MultiSyncTreeNode node) { if ((node.TreeView.Font.Style & FontStyle) == 0) { Font f = new Font(node.TreeView.Font, node.TreeView.Font.Style | FontStyle); node.NodeFont = f; } if (ForeColor != Color.Empty) { if (node.ForeColor != this.ForeColor) { node.ForeColor = this.ForeColor; } } }
public override void ConfigureContainerNode(MultiSyncTreeNode node, string path) { ConfigureStandardNode(node); // "[vehicles]" // "[vehicles]vehicles\warthog\warthog.vehicle" // "[vehicles]vehicles\warthog\warthog.vehicle[dependencies] // "[vehicles]vehicles\warthog\warthog.vehicle[dependencies]vehicles\warthog\warthog.gbxmodel" // path = @"[vehicles]vehicles\warthog\warthog.vehicle[dependencies]vehicles\warthog\warthog.gbxmodel"; ObjectViewTagLibrary.ObjectViewPath objPath = new ObjectViewTagLibrary.ObjectViewPath(path); string text = ""; string definition = "container"; if (objPath.Category != "") { text = objPath.Category; } if (objPath.Tag != "") { definition = "child"; text = GetObjectNodeNameFromPath(objPath.Tag); } if (node.Text != text) { node.Text = text; } // Add the NodeInformation to this node. if (node.NodeInformation == null) { node.NodeInformation = new NodeInformation(NodeType.Container); } node.NodeInformation.PathItems.Add(new PathItem(this, path)); if (!nodes.Contains(node)) { nodes.Add(node); } // TODO: Possibly implement this path structure. // Ex: objects[Bipeds]:\cyborg_mp.biped\dependencies:\characters\cyborg\cyborg.model_animations node.CollapsedImageIndex = ParentTreeView.Bitmaps.IndexOf(NodeDefinitions[definition].CollapsedIcon); node.ExpandedImageIndex = ParentTreeView.Bitmaps.IndexOf(NodeDefinitions[definition].ExpandedIcon); node.ImageIndex = node.CollapsedImageIndex; node.SelectedImageIndex = node.CollapsedImageIndex; }
protected void InitializeTree() { Console.WriteLine("Initializing MultiSyncTreeView"); BeginUpdate(); Nodes.Clear(); MultiSyncTreeNode rootNode = new MultiSyncTreeNode("Archive"); rootNode.CollapsedImageIndex = 0; rootNode.ExpandedImageIndex = 0; rootNode.NodeInformation = new NodeInformation(NodeType.Container); foreach (NodeHelper helper in nodeHelpers) { // Need to determine where to put this NodeHelper's root PathItem. // If it has a definition for its own rootnode, create that node and place it under the // treeview's rootNode. Otherwise, place this PathItem directly under the TreeView's rootNode. // TODO: Implement the above functionality. if (helper == null) { continue; } if (helper.OptionalRootNode != null) { rootNode.Nodes.Add(helper.OptionalRootNode); helper.OptionalRootNode.NodeInformation.PathItems.Add(new PathItem(helper, "\\")); if (helper.OptionalRootNode.Nodes.Count == 0) { helper.OptionalRootNode.Nodes.Add(new TreeNode("dummy")); } } else { rootNode.NodeInformation.PathItems.Add(new PathItem(helper, "\\")); } } Nodes.Add(rootNode); foreach (PathItem item in rootNode.NodeInformation.PathItems) { CreateChildren(rootNode, item); } //CreateGrandChildren(rootNode); Nodes[0].Expand(); SelectedNode = Nodes[0]; EndUpdate(); }
/// <summary> /// Returns the node with the specified text if it exists. /// Otherwise, creates a new node with the specified text. /// </summary> /// <param name="parentNode">The parent node whose children to search.</param> private MultiSyncTreeNode GetOrCreateNode(MultiSyncTreeNode parentNode, string text) { MultiSyncTreeNode newNode = null; foreach (MultiSyncTreeNode node in parentNode.Nodes) { if (node.Text == text) { newNode = node; break; } } if (newNode == null) { newNode = new MultiSyncTreeNode(text); } return(newNode); }
/// <summary> /// Creates the child nodes of the specified node's child nodes. /// Used for on-the-fly loading of tree nodes. /// </summary> protected void CreateGrandChildren(MultiSyncTreeNode parentNode) { // TODO: Look into a better method of handling on the fly loading. // In the CreateGrandChildrenMethod, rather than physically creating // all of the grandchild nodes, simply see if child nodes exist for // each child of the parent. If so, create a dummy node (so that the // node is collapsable), and remove it before expansion. // TODO: On the above method, look for a way to make a node expandable // without it having to actually contain child nodes. foreach (MultiSyncTreeNode node in parentNode.Nodes) { if (node.NodeInformation.NodeType == NodeType.Container) { if (!node.NodeInformation.ChildrenCreated) { foreach (PathItem item in node.NodeInformation.PathItems) { CreateChildren(node, item); } } } } }
/// <summary> /// Configures the specified MultiSyncTreeNode as an Object node when overriden in a derived class. /// </summary> public abstract void ConfigureObjectNode(MultiSyncTreeNode node, string path);
/// <summary> /// Configures the specified MultiSyncTreeNode as a Container node when overriden in a derived class. /// </summary> public abstract void ConfigureContainerNode(MultiSyncTreeNode node, string path);