protected AdvancedDropdownItem RebuildTree() { m_SearchableElements = new List <AdvancedDropdownItem>(); AdvancedDropdownItem root = new ComponentDropdownItem(); var menuDictionary = GetMenuDictionary(); menuDictionary.Sort(CompareItems); for (var i = 0; i < menuDictionary.Count; i++) { var menu = menuDictionary[i]; if (menu.Value == "ADD") { continue; } var menuPath = menu.Key; var paths = menuPath.Split('/'); var parent = root; for (var j = 0; j < paths.Length; j++) { var path = paths[j]; if (j == paths.Length - 1) { var element = new ComponentDropdownItem(path, L10n.Tr(path), menuPath, menu.Value); element.SetParent(parent); parent.AddChild(element); m_SearchableElements.Add(element); continue; } var group = parent.children.SingleOrDefault(c => c.name == path); if (group == null) { group = new ComponentDropdownItem(path, L10n.Tr(path), -1); group.SetParent(parent); parent.AddChild(group); } parent = group; } } root = root.children.Single(); root.SetParent(null); var newScript = new ComponentDropdownItem("New script", L10n.Tr("New script"), -1); newScript.AddChild(new NewScriptDropdownItem()); newScript.SetParent(root); newScript.selectedItem = 0; root.AddChild(newScript); return(root); }
protected override AdvancedDropdownItem Search(string searchString) { var searchTree = base.Search(searchString); if (searchTree != null) { var addNewScriptGroup = new ComponentDropdownItem("New script", L10n.Tr("New script"), -1); var addNewScript = new NewScriptDropdownItem(); addNewScript.className = searchString; addNewScriptGroup.AddChild(addNewScript); addNewScript.SetParent(addNewScriptGroup); addNewScriptGroup.SetParent(searchTree); addNewScriptGroup.selectedItem = 0; searchTree.AddChild(addNewScriptGroup); } return(searchTree); }