string returnSearch(string typeSearch, string searchString, District[] arraySearch) { for (int i = 0; i <= arraySearch.Length - 1; i++) { for (int j = 0; j <= arraySearch[i].setAllNeighbourhoods.Length - 1; j++) { for (int x = 0; x <= arraySearch[i].setAllNeighbourhoods[j].setProperties.Length - 1; x++) { if (typeSearch == "Property ID") { if (arraySearch[i].setAllNeighbourhoods[j].setProperties[x].setPropID.ToString() == searchString) { TVEMainData.CollapseAll(); TVEMainData.SelectedNode = TVEMainData.Nodes[i].Nodes[j].Nodes[x]; return(returnPropertiesInfo(i, j, x)); } } else if (typeSearch == "Property Name") { if (arraySearch[i].setAllNeighbourhoods[j].setProperties[x].setPropertyName.ToString() == searchString) { //return function for getting this stuff TVEMainData.CollapseAll(); TVEMainData.SelectedNode = TVEMainData.Nodes[i].Nodes[j].Nodes[x]; return(returnPropertiesInfo(i, j, x)); } } } } } return("No Matches"); }
void populateData(string typePopulate, District[] inputDistricts) { TVEMainData.BeginUpdate(); TVEMainData.Nodes.Clear(); if (typePopulate == "Property Name" | typePopulate == "Host Name" | typePopulate == "Room Type") { for (int i = 0; i <= inputDistricts.Length - 1; i++) { TVEMainData.Nodes.Add(inputDistricts[i].setDistrictName); for (int j = 0; j <= inputDistricts[i].setAllNeighbourhoods.Length - 1; j++) { TVEMainData.Nodes[i].Nodes.Add(inputDistricts[i].setAllNeighbourhoods[j].setNeighbourhoodName); switch (typePopulate) { case "Host Name": //for (int x = 0; x <= inputDistricts[i].setAllNeighbourhoods[j].setProperties.Length - 1; x++) //{ // TVEMainData.Nodes[i].Nodes[j].Nodes.Add("'"+inputDistricts[i].setAllNeighbourhoods[j].setProperties[x].setHostName+"' "+ inputDistricts[i].setAllNeighbourhoods[j].setProperties[x].setHostID); //} for (int x = 0; x <= inputDistricts[i].setAllNeighbourhoods[j].setProperties.Length - 1; x++) { //string tempBranchName = inputDistricts[i].setAllNeighbourhoods[j].setProperties[x].setHostName; string treeHostName = "'" + inputDistricts[i].setAllNeighbourhoods[j].setProperties[x].setHostName + "' " + inputDistricts[i].setAllNeighbourhoods[j].setProperties[x].setHostID; bool tempRepeated = false; for (int z = 0; z <= TVEMainData.Nodes[i].Nodes[j].Nodes.Count - 1; z++) { if (treeHostName == TVEMainData.Nodes[i].Nodes[j].Nodes[z].Text) { //MessageBox.Show(TVEMainData.Nodes[i].Nodes[j].Nodes[z].Text); tempRepeated = true; TVEMainData.Nodes[i].Nodes[j].Nodes[z].Nodes.Add(inputDistricts[i].setAllNeighbourhoods[j].setProperties[x].setPropertyName); } } if (tempRepeated == false) { TVEMainData.Nodes[i].Nodes[j].Nodes.Add(treeHostName); TVEMainData.Nodes[i].Nodes[j].LastNode.Nodes.Add(inputDistricts[i].setAllNeighbourhoods[j].setProperties[x].setPropertyName); } } //if (!rootNode.Nodes.Contains(newNodeText)) break; case "Property Name": for (int x = 0; x <= inputDistricts[i].setAllNeighbourhoods[j].setProperties.Length - 1; x++) { TVEMainData.Nodes[i].Nodes[j].Nodes.Add(inputDistricts[i].setAllNeighbourhoods[j].setProperties[x].setPropertyName); } break; case "Room Type": //same method as HostName -- try to combine somehow for (int x = 0; x <= inputDistricts[i].setAllNeighbourhoods[j].setProperties.Length - 1; x++) { //string tempBranchName = inputDistricts[i].setAllNeighbourhoods[j].setProperties[x].setHostName; string treeHostName = inputDistricts[i].setAllNeighbourhoods[j].setProperties[x].setRoomType; bool tempRepeated = false; for (int z = 0; z <= TVEMainData.Nodes[i].Nodes[j].Nodes.Count - 1; z++) { if (treeHostName == TVEMainData.Nodes[i].Nodes[j].Nodes[z].Text) { //MessageBox.Show(TVEMainData.Nodes[i].Nodes[j].Nodes[z].Text); tempRepeated = true; TVEMainData.Nodes[i].Nodes[j].Nodes[z].Nodes.Add(inputDistricts[i].setAllNeighbourhoods[j].setProperties[x].setPropertyName); } } if (tempRepeated == false) { TVEMainData.Nodes[i].Nodes[j].Nodes.Add(treeHostName); TVEMainData.Nodes[i].Nodes[j].LastNode.Nodes.Add(inputDistricts[i].setAllNeighbourhoods[j].setProperties[x].setPropertyName); } } break; } } TVEMainData.Nodes[i].Expand(); } } //create temporary trees then add them to the district at the end TVEMainData.EndUpdate(); }