Ejemplo n.º 1
0
        protected override TreeViewItem BuildRoot()
        {
            var root = new SeanLibIndexItem {
                id = 0, depth = -1, displayName = "SeanLib"
            };
            List <List <SeanLibIndexItem> > Map = new List <List <SeanLibIndexItem> >();
            int id = 1;

            foreach (var editor in editors)
            {
                CustomSeanLibEditor att    = ReflecTool.GetAttribute <CustomSeanLibEditor>(editor.GetType());
                string[]            pathes = att.Path.Split('/');
                if (Map.Count < pathes.Length)
                {
                    int c = pathes.Length - Map.Count;
                    for (int i = 0; i < c; i++)
                    {
                        Map.Add(new List <SeanLibIndexItem>());
                    }
                }
                SeanLibIndexItem parent = root;
                for (int i = 0; i < pathes.Length; i++)
                {
                    string node      = pathes[i];
                    var    existItem = Map[i].Find(e => e.displayName == node && e.parent == parent);
                    if (existItem == null)
                    {
                        existItem = new SeanLibIndexItem {
                            id = id++, displayName = node
                        };
                        Map[i].Add(existItem);
                        if (i == 0)
                        {
                            root.AddChild(existItem);
                        }
                        else
                        {
                            var parentItem = Map[i - 1].Find(e => e.displayName == pathes[i - 1]);
                            parentItem.AddChild(existItem);
                        }
                        if (i == pathes.Length - 1)
                        {
                            existItem.editor = editor;
                        }
                    }
                    else
                    {
                        if (i == pathes.Length - 1)
                        {
                            existItem.editor = editor;
                        }
                    }
                    parent = existItem;
                }
            }
            SetupDepthsFromParentsAndChildren(root);
            return(root);
        }
Ejemplo n.º 2
0
        public SeanLibEditor GetEditor(int id)
        {
            SeanLibIndexItem item = FindItem(id, rootItem) as SeanLibIndexItem;

            if (item != null)
            {
                return(item.editor);
            }
            return(null);
        }