moel@345: using System; moel@345: using System.Collections.Generic; moel@345: using System.Text; moel@345: using System.Collections; moel@345: moel@345: namespace Aga.Controls.Tree moel@345: { moel@345: public class ListModel : TreeModelBase moel@345: { moel@345: private IList _list; moel@345: moel@345: public int Count moel@345: { moel@345: get { return _list.Count; } moel@345: } moel@345: moel@345: public ListModel() moel@345: { moel@345: _list = new List(); moel@345: } moel@345: moel@345: public ListModel(IList list) moel@345: { moel@345: _list = list; moel@345: } moel@345: moel@345: public override IEnumerable GetChildren(TreePath treePath) moel@345: { moel@345: return _list; moel@345: } moel@345: moel@345: public override bool IsLeaf(TreePath treePath) moel@345: { moel@345: return true; moel@345: } moel@345: moel@345: public void AddRange(IEnumerable items) moel@345: { moel@345: foreach (object obj in items) moel@345: _list.Add(obj); moel@345: OnStructureChanged(new TreePathEventArgs(TreePath.Empty)); moel@345: } moel@345: moel@345: public void Add(object item) moel@345: { moel@345: _list.Add(item); moel@345: OnNodesInserted(new TreeModelEventArgs(TreePath.Empty, new int[] { _list.Count - 1 }, new object[] { item })); moel@345: } moel@345: moel@345: public void Clear() moel@345: { moel@345: _list.Clear(); moel@345: OnStructureChanged(new TreePathEventArgs(TreePath.Empty)); moel@345: } moel@345: } moel@345: }