/////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// A message handler called when the user selects a new tree node /// </summary> /////////////////////////////////////////////////////////////////////////////////////////// private void treeViewResources_AfterSelect(object sender, TreeViewEventArgs e) { // If the user selected a resource if (e.Node is TreeNodeResource) { TreeNodeResource selNode = e.Node as TreeNodeResource; m_ResID = selNode.resID; } // Else store a bad value else { m_ResID = -1; } }
/////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// A message handler called when the form is loaded. /// </summary> /////////////////////////////////////////////////////////////////////////////////////////// private void ResChooser_Load(object sender, EventArgs e) { // Ensure an empty tree treeViewResources.BeginUpdate(); treeViewResources.Nodes.Clear(); // Go through all of the filter types foreach (ResourceType curResType in m_Filters) { // Create the base item for this type TreeNode typeRootNode = new TreeNode(curResType.ToString()); treeViewResources.Nodes.Add(typeRootNode); // Get all of the resources of this type List <uint> resIDList = m_ResDB.GetResourcesOfType(curResType); // If there are no resources by this type then bail if (resIDList.Count == 0) { continue; } // Go through all of the resource IDs found foreach (uint curResID in resIDList) { // Get the current resource's info ResourceToolsDB.ResourceIndexItem curResInfo = m_ResDB.GetResourceInfo(curResID); // Create the node item with the parent set to the current type's root node TreeNodeResource newResNode = new TreeNodeResource(curResInfo.sFileName, curResID); typeRootNode.Nodes.Add(newResNode); } } // Display the changes treeViewResources.EndUpdate(); }