External/Aga.Controls/Tree/NodeControls/NodeControlsCollection.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.ComponentModel.Design;
     5 using System.Collections.ObjectModel;
     6 using System.ComponentModel;
     7 using System.Drawing.Design;
     8 
     9 namespace Aga.Controls.Tree.NodeControls
    10 {
    11 	internal class NodeControlsCollection : Collection<NodeControl>
    12 	{
    13 		private TreeViewAdv _tree;
    14 
    15 		public NodeControlsCollection(TreeViewAdv tree)
    16 		{
    17 			_tree = tree;
    18 		}
    19 
    20 		protected override void ClearItems()
    21 		{
    22 			_tree.BeginUpdate();
    23 			try
    24 			{
    25 				while (this.Count != 0)
    26 					this.RemoveAt(this.Count - 1);
    27 			}
    28 			finally
    29 			{
    30 				_tree.EndUpdate();
    31 			}
    32 		}
    33 
    34 		protected override void InsertItem(int index, NodeControl item)
    35 		{
    36 			if (item == null)
    37 				throw new ArgumentNullException("item");
    38 
    39 			if (item.Parent != _tree)
    40 			{
    41 				if (item.Parent != null)
    42 				{
    43 					item.Parent.NodeControls.Remove(item);
    44 				}
    45 				base.InsertItem(index, item);
    46 				item.AssignParent(_tree);
    47 				_tree.FullUpdate();
    48 			}
    49 		}
    50 
    51 		protected override void RemoveItem(int index)
    52 		{
    53 			NodeControl value = this[index];
    54 			value.AssignParent(null);
    55 			base.RemoveItem(index);
    56 			_tree.FullUpdate();
    57 		}
    58 
    59 		protected override void SetItem(int index, NodeControl item)
    60 		{
    61 			if (item == null)
    62 				throw new ArgumentNullException("item");
    63 
    64 			_tree.BeginUpdate();
    65 			try
    66 			{
    67 				RemoveAt(index);
    68 				InsertItem(index, item);
    69 			}
    70 			finally
    71 			{
    72 				_tree.EndUpdate();
    73 			}
    74 		}
    75 	}
    76 
    77 	internal class NodeControlCollectionEditor : CollectionEditor
    78 	{
    79 		private Type[] _types;
    80 
    81 		public NodeControlCollectionEditor(Type type)
    82 			: base(type)
    83 		{
    84 			_types = new Type[] { typeof(NodeTextBox), typeof(NodeIntegerTextBox), typeof(NodeDecimalTextBox), 
    85 				typeof(NodeComboBox), typeof(NodeCheckBox),
    86 				typeof(NodeStateIcon), typeof(NodeIcon), typeof(NodeNumericUpDown), typeof(ExpandingIcon)  };
    87 		}
    88 
    89 		protected override System.Type[] CreateNewItemTypes()
    90 		{
    91 			return _types;
    92 		}
    93 	}
    94 }