Esempio n. 1
0
        public string GetFullPath()
        {
            LightCollection <string> paths = new LightCollection <string>();

            paths.Add(_id);
            TreeItem <T> parent = this.Parent;

            while (parent != null)
            {
                paths.Add(parent.Id);
                parent = parent.Parent;
            }
            paths.Reverse();
            string fullPath = string.Join("/", paths.GetItems());

            return(fullPath);
        }
Esempio n. 2
0
        public LightCollection <TreeItem <T> > Find(Predicate <TreeItem <T> > match)
        {
            LightCollection <TreeItem <T> > results = new LightCollection <TreeItem <T> >();

            for (int i = 0; i < _globalCollection.Count; i++)
            {
                if (match(_globalCollection[i]))
                {
                    results.Add(_globalCollection[i]);
                }
            }
            return(results);
        }
Esempio n. 3
0
        public TreeItem <T> Add(string id, T value)
        {
            if (_ownerCollection.GlobalCollection.Contains(id))
            {
                throw new Exception("key \"" + id + "\" already exist");
            }

            TreeItem <T> treeItem = new TreeItem <T>(id, _parent, ref _ownerCollection);

            _ownerCollection.Global_AddItem(id, treeItem);

            _items.Add(id);
            return(treeItem);
        }
Esempio n. 4
0
        public virtual void Add(string key, T item)
        {
            if (_keys.Contains(key))
            {
                throw new Exception("Key already exist");
            }
            _keys.Add(key);
            int index = _items.Add(item);

            if (ItemAdd != null)
            {
                ItemAdd(this, new KeyedCollectionAddEventArgs(_items[index], index, _keys[index]));
            }
            if (CollectionChanged != null)
            {
                CollectionChanged(this, new EventArgs());
            }
        }