External/Aga.Controls/Tree/ListModel.cs
author moel.mich
Sun, 23 Sep 2012 18:37:43 +0000
changeset 380 573f1fff48b2
permissions -rw-r--r--
Fixed Issue 387. The new implementation does not try to start a ring 0 driver that already exists, but could not be opened. It tries to delete the driver and install it new. The driver is now stored temporarily in the application folder. The driver is not correctly removed on system shutdown.
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
}