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