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