예제 #1
0
        protected AdvancedDropdownItem RebuildTree()
        {
            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(LocalizationDatabase.GetLocalizedString(path), menuPath, menu.Value);
                        element.searchable = true;
                        element.SetParent(parent);
                        parent.AddChild(element);
                        continue;
                    }
                    var group = parent.children.SingleOrDefault(c => c.name == path);
                    if (group == null)
                    {
                        group = new ComponentDropdownItem(path, -1);
                        group.SetParent(parent);
                        parent.AddChild(group);
                    }
                    parent = group;
                }
            }
            root = root.children.Single();
            root.SetParent(null);
            var newScript = new ComponentDropdownItem("New script", -1);

            newScript.AddChild(new NewScriptDropdownItem());
            newScript.SetParent(root);
            root.AddChild(newScript);
            return(root);
        }
예제 #2
0
        protected override AdvancedDropdownItem Search(string searchString)
        {
            var searchTree = base.Search(searchString);

            if (searchTree != null)
            {
                var addNewScriptGroup = new ComponentDropdownItem("New script", -1);
                var addNewScript      = new NewScriptDropdownItem();
                addNewScript.className = searchString;
                addNewScriptGroup.AddChild(addNewScript);
                addNewScript.SetParent(addNewScriptGroup);
                addNewScriptGroup.SetParent(searchTree);
                searchTree.AddChild(addNewScriptGroup);
            }
            return(searchTree);
        }