External/Aga.Controls/Tree/ListModel.cs
author StephaneLenclud
Sun, 03 Feb 2013 18:01:50 +0100
branchMiniDisplay
changeset 433 090259cfd699
permissions -rw-r--r--
Adding SoundGraphDisplay and SensorFrontView classes.
They were respectively based on SystemTray and SensorNotifyIcon.
SoundGraphDisplay is now able to load iMONDisplay.dll providing it lives on your PATH.
Adding option to sensor context menu for adding it into FrontView.
     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 }