External/Aga.Controls/Tree/ListModel.cs
author moel.mich
Sun, 27 May 2012 15:16:19 +0000
changeset 345 0c551e8818e0
permissions -rw-r--r--
Added the source code of Aga.Controls (TreeViewAdv for .Net) version 1.7.0.0.
moel@345
     1
using System;
moel@345
     2
using System.Collections.Generic;
moel@345
     3
using System.Text;
moel@345
     4
using System.Collections;
moel@345
     5
moel@345
     6
namespace Aga.Controls.Tree
moel@345
     7
{
moel@345
     8
	public class ListModel : TreeModelBase
moel@345
     9
	{
moel@345
    10
		private IList _list;
moel@345
    11
moel@345
    12
		public int Count
moel@345
    13
		{
moel@345
    14
			get { return _list.Count; }
moel@345
    15
		}
moel@345
    16
moel@345
    17
		public ListModel()
moel@345
    18
		{
moel@345
    19
			_list = new List<object>();
moel@345
    20
		}
moel@345
    21
moel@345
    22
		public ListModel(IList list)
moel@345
    23
		{
moel@345
    24
			_list = list;
moel@345
    25
		}
moel@345
    26
moel@345
    27
		public override IEnumerable GetChildren(TreePath treePath)
moel@345
    28
		{
moel@345
    29
			return _list;
moel@345
    30
		}
moel@345
    31
moel@345
    32
		public override bool IsLeaf(TreePath treePath)
moel@345
    33
		{
moel@345
    34
			return true;
moel@345
    35
		}
moel@345
    36
moel@345
    37
		public void AddRange(IEnumerable items)
moel@345
    38
		{
moel@345
    39
			foreach (object obj in items)
moel@345
    40
				_list.Add(obj);
moel@345
    41
			OnStructureChanged(new TreePathEventArgs(TreePath.Empty));
moel@345
    42
		}
moel@345
    43
moel@345
    44
		public void Add(object item)
moel@345
    45
		{
moel@345
    46
			_list.Add(item);
moel@345
    47
			OnNodesInserted(new TreeModelEventArgs(TreePath.Empty, new int[] { _list.Count - 1 }, new object[] { item }));
moel@345
    48
		}
moel@345
    49
moel@345
    50
		public void Clear()
moel@345
    51
		{
moel@345
    52
			_list.Clear();
moel@345
    53
			OnStructureChanged(new TreePathEventArgs(TreePath.Empty));
moel@345
    54
		}
moel@345
    55
	}
moel@345
    56
}