External/Aga.Controls/Tree/ListModel.cs
author StephaneLenclud
Thu, 18 Apr 2013 23:25:10 +0200
branchMiniDisplay
changeset 444 9b09e2ee0968
permissions -rw-r--r--
Front View plug-in does not init if no sensor added.
Fixing some format to make strings shorter.
Now trying to start SoundGraphAccess.exe process from same directory.
Packed mode now can display three sensors along with the current time.
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
}