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.
     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 }